Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,262 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,514 people online right now. Registration is fast and FREE... Join Now!




help with creating a for loop with in a called function

 
Reply to this topicStart new topic

help with creating a for loop with in a called function

joelw
13 Dec, 2006 - 06:26 AM
Post #1

New D.I.C Head
*

Joined: 13 Dec, 2006
Posts: 2


My Contributions
ok so far this is what ive got for my code im trying to figure out how to start my for loop that will receive the array and the int that represents the count(2)?
CODE
#include<iostream>
using namespace std;
struct Student
{
       char Name[30];
       float GPA;
       int Major;
};

//Function Prototype
Student studentdata(Student&);

//Function Prototype
Student changeData(Student&);

//Function Prototype
Student GetStudents(Student&);

int main()
{
    struct Student s1;
    struct Student s2;
    struct Student s3;
    
    s2 = studentdata(s1);
    s2 = changeData(s2);
    s2 = GetStudent(s3);
    cout << "GPA: " << s2.GPA <<endl;
    cout << "Major: " << s2.Major << endl;
    cout << "Students Name: " << s2.Name << endl;
      
     return 0;

}
Student studentdata(Student &s1)
{
    cout << "please enter your name: ";
    cin >> s1.Name;
    cout << "please enter your GPA: ";
    cin >> s1.GPA;
    cout << "please enter your major: ";
    cin >> s1.Major;
    return s1;
}

Student changeData(Student &s2)
{
   s2.GPA = 3;
   s2.Major = 1;
   return s2;  
}

Student GetStudents(Student &s3)
{
        for (
        {
            cout << "Please enter your name: ";
            cin.getline Student[index].Name);
            cout << "Please enter your GPA: ";
            cin.getline Student[index].GPA;
            cout << "Please enter your Major: ";
            cin.ignore Student[index].Major;
        }

}





User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 07:09PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month