I have been asked to write a coding for calculate GPA by using struct and array.
I want to display the ouput for every subjects's name, subjects' code, grade for every subject and GPA for every sem but i coulds't get the ouput i want. I think i had done some mistake in my coding especially for my array part but still i can't clearly see the exact mistakes i had make. Hope that i'm able to get some guidance on solving my problem...Thanks for offering help ya!!XD...Here is my coding,pls take a look on it...

#include<iostream.h>
#include<string.h>
using namespace std;

struct student{
    string name,no_matric;
    string sub_code[10],sub_name[10],sub_grade[10];
    float sub_hrs[10];

}student1;

main()
{
    string name,no_matric;
    int n, i,j,sem,sum_hr[10];
    float gpa[10],darab[10],sum_darab[10];
    float value[10];
    cin.ignore();
    cout<<"Enter student's name : ";
    getline(cin,student1.name);
    cout<<"Enter student's matric number: ";
    getline(cin,student1.no_matric);

    cout<<"Enter semester taken:";
    cin>>sem;
    sum_darab[0]=0;
    sum_hr[0]=0;

    for (j=0; j<sem; j++)
    {
        cout<<"Enter total subject taken for semester "<<j+1<<" :";
        cin>>n;

        for(i=0; i<n; i++)

        {
            cin.ignore();
            cout<<"Enter subject code: ";
            getline(cin,student1.sub_code[i]);
            cout<<"Enter subject name: ";
            getline(cin,student1.sub_name[i]);
            cout<<"Enter subject's credit hours: ";
            cin>>student1.sub_hrs[i];
            cin.ignore();
            cout<<"Enter subject gred: ";
            getline(cin,student1.sub_grade[i]);


            if(student1.sub_grade[i]=="A")
            value[i]=4;
            else if(student1.sub_grade[i]=="A-")
            value[i]=3.75;
            else if(student1.sub_grade[i]=="B+")
            value[i]=3.5;
            else if(student1.sub_grade[i]=="B")
            value[i]=3;
            else if(student1.sub_grade[i]=="B-")
            value[i]=2.75;
            else if(student1.sub_grade[i]=="C+")
            value[i]=2.5;
            else if(student1.sub_grade[i]=="C")
            value[i]=2;
            else if(student1.sub_grade[i]=="C-")
            value[i]=1.75;
            else if(student1.sub_grade[i]=="D+")
            value[i]=1.5;
            else if(student1.sub_grade[i]=="D")
            value[i]=1;
            else 
            value[i]=0;

            darab[i]=value[i]*student1.sub_hrs[i];
            sum_darab[j]+=darab[i];
            sum_hr[j]+=student1.sub_hrs[i];
        }
            gpa[j]=sum_darab[j]/sum_hr[j];
    }
        cout<<"Name: "<<student1.name<<endl;
        cout<<"No Matric: "<<student1.no_matric<<endl;
        for(j=0; j<sem; j++)
        {
            for(i=0; i<n; i++)
            {
                        cout<<student1.sub_code[i]<<" : "<<student1.sub_name[i]<<" : "<<student1.sub_grade[i]<<endl;
            }   

                    cout<<"GPA for sem "<<j+1<<":"<<gpa[j]<<endl;
                    cout<<"Sum Darab for sem "<<j+1<<":"<<sum_darab[j]<<endl;
                    cout<<"Sum hour for sem "<<j+1<<":"<<sum_hr[j]<<endl;
        }
}

What is your expected output and what are getting now? Please specify the error(s).

A few observations at a glance:
If you're using any standard compiler, your code may not compile.

  1. Use #include <iostream> (no .h)
  2. Same for #include <string>
  3. Also, specify main to be returning int (c++ doesn't assume int by default): int main (void)

The ouput i wish to get including the student's name, student's matric number, subjects' name, subjects' code, and grade for each subjects and GPA for each semester.
I'm using jGrasp.
So far, i'm able to display the student's name and matric number but others i can't get it.

For example,here is my input for my coding:
Enter student's name: Elle Yiew
Enter student's matric number: D047777
Enter semester taken: 2

Enter total subject taken for semester 1: 2
Enter subject code:SFL3011
Enter subject name:Physics Lab
Enter subject's credit hours:1
Enter subject gred:A

Enter subject code:SFU3044
Enter subject name:Physics
Enter subject's credit hours:4
Enter subject gred:B

Enter total subject taken for semester 2: 2
Enter subject code:MTS3023
Enter subject name:Data Struct
Enter subject's credit hours:3
Enter subject gred:B

Enter subject code:MMP3013
Enter subject name:Multimedia
Enter subject's credit hours:3
Enter subject gred:C

Here is the ouput it displays:
Name:Elle Yiew
No Matric: D047777
MTS3023 : Data Struct : B
MMP3013 : Multimedia : C
GPA for sem 1 : 3.2
Sum Darab for sem 1 : 16
Sum hour for sem 1 : 5
MTS3023 : Data Struct : B
MMP3013 : Multimedia : C
GPA for sem 2 : 7.60348e-09
Sum Darab for sem 2 : 15
Sum hour for sem 2 : 1972780815

May i know what is getting wrong with the looping i had done??
Pls provide some guidance...thanks.

The sample output you gave above includes all that you want, may be not in a neat format, and sem 2's subjects are printed first, but apart from that I don't see where the problem is!

But if you're not getting the above output and it is what you want to get, well, I copy pasted your code and did the changes i suggested earlier to compile it and in my compiler, Visual Studio 2010, it does give the output in the above format.

I think you had misunderstand my meaning...but nevermind,by refering to the guidance of my lecturer, I think i know the exact mistake i had make. I missused the array concept that's why i can't even get the ouput i want. The ouput i had shown above got problem one. The ouput i want supposed to be like this:

Name:Elle Yiew
No Matric: D047777
SFL3011 : Physics Lab : A
SFU3044 : Physics : B
GPA for sem 1 : 3.2
Sum Darab for sem 1 : 16
Sum hour for sem 1 : 5
MTS3023 : Data Struct : B
MMP3013 : Multimedia : C
GPA for sem 2 : 2.5
Sum Darab for sem 2 : 15
Sum hour for sem 2 : 6

but it comes out to be like this:
Name:Elle Yiew
No Matric: D047777
MTS3023 : Data Struct : B
MMP3013 : Multimedia : C
GPA for sem 1 : 3.2
Sum Darab for sem 1 : 16
Sum hour for sem 1 : 5
MTS3023 : Data Struct : B
MMP3013 : Multimedia : C
GPA for sem 2 : 7.60348e-09
Sum Darab for sem 2 : 15
Sum hour for sem 2 : 1972780815

Sorry ya,making you confused.....i'm not very good in express out the things i want for my coding...heheh...esp if using english...anyway,still appreciate your guidance.Thank you very much for your help...n.n

And by refering to my lecturer's guidance, here is the algorithm she had suggested to me:

The idea is like this:

`

start
total_point_sem = 0;
total_credit_hours_sem = 0;

Enter total of sem;
for(i = 0; i< sem ; i++) //loop for different sem
{  
  total_credit_hours = 0; //initial value
  total_point = 0; //initial value

  Enter how many subjects;
  for(j = 0; j< total_subject <j++) //loop for the courses
  {
      Enter subject;
      Enter credit_hours;
      Enter gred;
      get_point = (credit_hour * point(from gred));
      total_credit_hours += credit_hours;
      total_point += get_point;
  } 
  gpa[i] = total_point / total_credit_hours;

  total_point_sem += total_point;
  total_credit_hours_sem += total_credit_hours;
}
cgpa = total_point_sem / total_credit_hours_sem;
end

`

By tracing the above algorithm, it should be work...

You need to initialise all the values of the arrays sum_darab and sum_hr, not just the first element of each. I would do the initialisation inside the for (j=0; j<sem; j++) loop, not before as you have it currently.

You will also have a divide-by-zero problem if you have a really bad student that only gets E-grades :)

Ravenous, thanks for your guidance.
I had done my initialisation inside the looping of semester but i realise that i'm still unable to get the ouput i want.For example after enter all information for 3 semester, but i can only display the ouput for things i had entered for semester 3 only.Below is my coding,hope that you are able to point out the mistake i had made....

Example:
Here are the information i had entered:
Enter student's name : Sing Lin
Enter student's matric number : D048224
Enter total sem taken : 2

Enter how many subject take for sem 1 : 2
Enter subject code : A001
Enter subject name : a001
Enter subject's credit hours : 1
Enter subject grade : A

Enter subject code : A002
Enter subject name : a002
Enter subject's credit hours : 2
Enter subject grade : B

Enter how many subject take for sem 2 : 2
Enter subject code : B001
Enter subject name : b001
Enter subject's credit hours : 1
Enter subject grade : B

Enter subject code : B002
Enter subject name : b002
Enter subject's credit hours : 2
Enter subject grade : C

Here is the ouput i get:
Name : Sing Lin
No Matric : D048224

Subject Code Subject Name Subject credits hours
B001 : b001 : 1
B002 : b002 : 2
GPA1 : 6.165714-44
Subject Code Subject Name Subject credits hours
B001 : b001 : 1
B002 : b002 : 2
GPA2 : 1.74374+34
CGPA : 2.8333
The only things correct for above ouput are Name, No matric and CGPA. The looping for subject for semester 2 is repeated for 2 times...

The ouput i wish to get is:
Name : Sing Lin
No Matric : D048224

Subject Code Subject Name Subject credits hours
A001 : a001 : 1
A002 : a002 : 2
GPA1 : 3.3333
Subject Code Subject Name Subject credits hours
B001 : b001 : 1
B002 : b002 : 2
GPA2 : 2.3333
CGPA : 2.8333

#include<iostream.h>
#include<string.h>

using namespace std;

struct student{
    string name,no_matric;
    string sub_code[10],sub_name[10],sub_grade[10];
    float credit_hour[10];

}student1;

main()
{
    int credit_hours[10];
    int total_credit_hours,sem,i,j,total_subject,total_credit_hours_sem;
    float value[10],gpa[10],get_point[10];
    float total_point,total_point_sem,cgpa;

    total_point_sem = 0;                                //Initialise value
    total_credit_hours_sem = 0;                 //Initialise value

    cin.ignore();
    cout<<"Enter student's name : ";                  //Enter student's name
    getline(cin,student1.name);
    cout<<"Enter student's matric number: ";      //Enter student's matric number
    getline(cin,student1.no_matric);


    cout<<"Enter total of sem taken:";                //Total semester taken by the student
    cin>>sem;


    for(j = 0; j< sem ; j++)             //loop for different semester
    {  
      total_credit_hours = 0; //initial value
      total_point = 0; //initial value

        cout<<"Enter how many subjects take for sem "<<j+1<<":"; //Enter total 
                                                                  number of subject 
                                                                  taken for each sem
        cin>>total_subject;
        for(i = 0; i< total_subject; i++) //loop for the courses
        {
            cin.ignore();
            cout<<"Enter subject code: ";                     //Enter subject code
            getline(cin,student1.sub_code[i]);
            cout<<"Enter subject name: ";                     //Enter subject name
            getline(cin,student1.sub_name[i]);
            cout<<"Enter subject's credit hours: ";       //Enter credit hours of the 
                                                           subject
            cin>>student1.credit_hour[i];
            cin.ignore();
            cout<<"Enter subject gred: ";         //Enter grade gained by student 
                                                     for every subject

            getline(cin,student1.sub_grade[i]);

            if(student1.sub_grade[i]=="A")
            value[i]=4;
            else if(student1.sub_grade[i]=="A-")
            value[i]=3.75;
            else if(student1.sub_grade[i]=="B+")
            value[i]=3.5;
            else if(student1.sub_grade[i]=="B")
            value[i]=3;
            else if(student1.sub_grade[i]=="B-")
            value[i]=2.75;
            else if(student1.sub_grade[i]=="C+")
            value[i]=2.5;
            else if(student1.sub_grade[i]=="C")
            value[i]=2;
            else if(student1.sub_grade[i]=="C-")
            value[i]=1.75;
            else if(student1.sub_grade[i]== "D+")
            value[i]=1.5;
            else if(student1.sub_grade[i]=="D")
            value[i]=1;
            else 
            value[i]=0;


            get_point[i] = student1.credit_hour[i] * value[i];   //multiply of 
                                                                 credit hours and  
                                                                 grade get for each 
                                                                 subject

            total_credit_hours +=student1.credit_hour[i];       //total cerdit hours 
                                                                  for a sem

       total_point += get_point[i];             //total points(multiple of credits 
                                                  hours and grade)get for a sem 
        } 
    /*for(i=0; i<total_subject; i++) //looping for subject
            {
                cout<<student1.sub_code[i]<<" : "<<student1.sub_name[i]<<" : "<<student1.credit_hour[i]<<endl;
            }*/

        if(total_point==0)

            cout<<"You fail all of the subject in this semester.You are terminated."<<endl;

        else
            {
                gpa[i] = total_point / total_credit_hours;      //calculate GPA for 
                                                                  each sem
            }

            total_point_sem += total_point;         //Total points(multiple of grade  
                                                    and credit hours) get for all    
                                                     semester

             total_credit_hours_sem += total_credit_hours;  //credits hour get for   
                                                              all semester
    }
            cgpa = total_point_sem / total_credit_hours_sem;    //calculate CGPA

            cout<<"Name: "<<student1.name<<endl;          //display name of student
            cout<<"No Matric: "<<student1.no_matric<<endl;
        for(j = 0; j< sem ; j++)                     //looping for sem
        {   
            cout<<"Subject Code\t"<<"Subject Name\t"<<"Subject Credit Hours"<<endl;

            for(i=0; i<total_subject; i++)                //looping for subject
            {
                cout<<student1.sub_code[i]<<" : "<<student1.sub_name[i]<<" : "<<student1.credit_hour[i]<<endl;
            }
                cout<<"GPA"<<j+1<<" : "<<gpa[j]<<endl;    

        }   
        cout<<"CGPA : "<<cgpa<<endl;
}

Your problem here stems from the fact that you're not controlling the scope of your variables properly. You should only decalare variables so that they're valid for the minimum possible scope.

For example, you should use the following for your loops:

for ( int i = 0; i < n; ++i )
{
    /* Loop stuff here... */
}

Notice how the loop variable i is defined in the loop (as int i = 0), I'm not using for ( i = 0.... This will help the compiler catch issues where you do things like this:

int i;

/* stuff */

for ( i = 0; i < n; ++i )
{
    /* loop stuff */
}

myArray[i] = /* some value */;

Try this for all the i and j variables in your code and see what compiler errors you get :) (don't forget to delete the ones on line 16).

The same is true for your variables total_credit_hours and total_point, you're only supposed to use them inside the semester loop, so put your money where your mouth is and decalare them inside the loop as well. This way the compiler will tell you if you're using them where you're not supposed to. Change lines 36 & 37 to:

int total_credit_hours = 0;
int total_point = 0;

( and delete their declarations on line 16. The compiler should then point out your problems for you :)

In general, declare variables as close as possible to where they're needed and try to limit their scope (via curly brackets, {}) to only the bits of code that they make sense in. Otherwise, you can be guaranteed that they will be used at some point when they don't make sense.

Revenous,
I'm following your guidance by deleting the declaration for i and j on line 16 but once i do that, the i for 'gpa[i] = total_point / total_credit_hours' on line 105 will become undefined. So, i add the line int i in loop for sem.But stil the same problem occurs once i run my coding....Pls take a look at my coding again see what's wrong...honestly i'm really poor in coding cz i'm still quite a new learner....XP..Here is my coding:

#include<iostream.h>
#include<string.h>

using namespace std;

struct student{
    string name,no_matric;
    string sub_code[10],sub_name[10],sub_grade[10];
    float credit_hour[10];

}student1;

main()
{
    int credit_hours[10];
    int sem,total_subject;              //i, j,total_credit_hours and total_point 
                                        //are removed

    float value[10],gpa[10],get_point[10];
    float cgpa;

    float total_point_sem = 0;                              //Initialise value
    int total_credit_hours_sem = 0;                 //Initialise value

    cin.ignore();
    cout<<"Enter student's name : ";                  //Enter student's name
    getline(cin,student1.name);
    cout<<"Enter student's matric number: ";      //Enter student's matric number
    getline(cin,student1.no_matric);


    cout<<"Enter total of sem taken:";                //Total semester taken by the       
                                                   //student
    cin>>sem;


    for(int j = 0; j< sem ; j++)         //j declared as int in for()[newly added]
    {  
        int i;          //newly added line....i choose to add it here because if i 
                        //don't add this line here, error will be //occured : i for 
                        //gpa[i] will become undefined...

      int total_credit_hours = 0;       //newly added
          float total_point = 0;       //newly added

        cout<<"Enter how many subjects take for sem "<<j+1<<":"; //Enter total number of subject taken for each sem
        cin>>total_subject;
        for(int i = 0; i< total_subject; i++) //loop for the courses
        {
            cin.ignore();
            cout<<"Enter subject code: ";                     //Enter subject code
            getline(cin,student1.sub_code[i]);
            cout<<"Enter subject name: ";                     //Enter subject name
            getline(cin,student1.sub_name[i]);
                cout<<"Enter subject's credit hours: ";       //Enter credit hours of
                                                            //the subject
            cin>>student1.credit_hour[i];
            cin.ignore();
            cout<<"Enter subject gred: ";     //Enter grade gaineb 
                                                //by student for every subject
            getline(cin,student1.sub_grade[i]);

            if(student1.sub_grade[i]=="A")
            value[i]=4;
            else if(student1.sub_grade[i]=="A-")
            value[i]=3.75;
            else if(student1.sub_grade[i]=="B+")
            value[i]=3.5;
            else if(student1.sub_grade[i]=="B")
            value[i]=3;
            else if(student1.sub_grade[i]=="B-")
            value[i]=2.75;
            else if(student1.sub_grade[i]=="C+")
            value[i]=2.5;
            else if(student1.sub_grade[i]=="C")
            value[i]=2;
            else if(student1.sub_grade[i]=="C-")
            value[i]=1.75;
            else if(student1.sub_grade[i]== "D+")
            value[i]=1.5;
            else if(student1.sub_grade[i]=="D")
            value[i]=1;
            else 
            value[i]=0;


            get_point[i] = student1.credit_hour[i] * value[i];   //multiply of 
                                                                //credit hours and 
                                                                //grade get for each 
                                                                //subject

            total_credit_hours +=student1.credit_hour[i];       //total cerdit hours 
                                                                //for a sem

       total_point += get_point[i];         //total points(multiple of credits hours 
                                            //and grade)get for a sem 
        }


                gpa[i] = total_point / total_credit_hours;      //calculate GPA for 
                                                                 //each sem


            total_point_sem += total_point;     //Total points(multiple of grade and 
                                                //credit hours) get for all semester

             total_credit_hours_sem += total_credit_hours;  //credits hour get for 
                                                            //all semester
    }
            cgpa = total_point_sem / total_credit_hours_sem;    //calculate CGPA

            cout<<"Name: "<<student1.name<<endl;          //display name of 
                                                            //student

            cout<<"No Matric: "<<student1.no_matric<<endl;
        for(int j = 0; j< sem ; j++)     //Declaration of j as int in for()
        {   
            cout<<"Subject Code\t"<<"Subject Name\t"<<"Subject Credit Hours"<<endl;

            for(int i=0; i<total_subject; i++)   //Declaration of i as int in for()
            {
                cout<<student1.sub_code[i]<<" : "<<student1.sub_name[i]<<" : "<<student1.credit_hour[i]<<endl;
            }
                cout<<"GPA"<<j+1<<" : "<<gpa[j]<<endl;    

        }   
        cout<<"CGPA : "<<cgpa<<endl;
}

Revenous,
I'm following your guidance by deleting the declaration for i and j on line 16 but once i do that, the i for 'gpa[i] = total_point / total_credit_hours' on line 105 will become undefined. So, i add the line int i in loop for sem.But stil the same problem occurs once i run my coding....Pls take a look at my coding again see what's wrong and points out the mistake...honestly i'm poor in coding cz i'm still quite a new learner....XP..Here is my coding:

#include<iostream.h>
    #include<string.h>

    using namespace std;

    struct student{
        string name,no_matric;
        string sub_code[10],sub_name[10],sub_grade[10];
        float credit_hour[10];

    }student1;

    main()
    {
        int credit_hours[10];
        int sem,total_subject;              //i, j,total_credit_hours and total_point 
                                            //are removed

        float value[10],gpa[10],get_point[10];
        float cgpa;

        float total_point_sem = 0;                              //Initialise value
        int total_credit_hours_sem = 0;                 //Initialise value

        cin.ignore();
        cout<<"Enter student's name : ";                  //Enter student's name
        getline(cin,student1.name);
        cout<<"Enter student's matric number: ";      //Enter student's matric number
        getline(cin,student1.no_matric);


        cout<<"Enter total of sem taken:";                //Total semester taken by the       
                                                       //student
        cin>>sem;


        for(int j = 0; j< sem ; j++)         //j declared as int in for()[newly added]
        {  
            int i;          //newly added line....i choose to add it here because if i 
                            //don't add this line here, error will be //occured : i for 
                            //gpa[i] will become undefined...

          int total_credit_hours = 0;       //newly added
              float total_point = 0;       //newly added

            cout<<"Enter how many subjects take for sem "<<j+1<<":"; //Enter total number of subject taken for each sem
            cin>>total_subject;
            for(int i = 0; i< total_subject; i++) //loop for the courses
            {
                cin.ignore();
                cout<<"Enter subject code: ";                     //Enter subject code
                getline(cin,student1.sub_code[i]);
                cout<<"Enter subject name: ";                     //Enter subject name
                getline(cin,student1.sub_name[i]);
                    cout<<"Enter subject's credit hours: ";       //Enter credit hours of
                                                                //the subject
                cin>>student1.credit_hour[i];
                cin.ignore();
                cout<<"Enter subject gred: ";     //Enter grade gaineb 
                                                    //by student for every subject
                getline(cin,student1.sub_grade[i]);

                if(student1.sub_grade[i]=="A")
                value[i]=4;
                else if(student1.sub_grade[i]=="A-")
                value[i]=3.75;
                else if(student1.sub_grade[i]=="B+")
                value[i]=3.5;
                else if(student1.sub_grade[i]=="B")
                value[i]=3;
                else if(student1.sub_grade[i]=="B-")
                value[i]=2.75;
                else if(student1.sub_grade[i]=="C+")
                value[i]=2.5;
                else if(student1.sub_grade[i]=="C")
                value[i]=2;
                else if(student1.sub_grade[i]=="C-")
                value[i]=1.75;
                else if(student1.sub_grade[i]== "D+")
                value[i]=1.5;
                else if(student1.sub_grade[i]=="D")
                value[i]=1;
                else 
                value[i]=0;


                get_point[i] = student1.credit_hour[i] * value[i];   //multiply of 
                                                                    //credit hours and 
                                                                    //grade get for each 
                                                                    //subject

                total_credit_hours +=student1.credit_hour[i];       //total cerdit hours 
                                                                    //for a sem

           total_point += get_point[i];         //total points(multiple of credits hours 
                                                //and grade)get for a sem 
            }


                    gpa[i] = total_point / total_credit_hours;      //calculate GPA for 
                                                                     //each sem


                total_point_sem += total_point;     //Total points(multiple of grade and 
                                                    //credit hours) get for all semester

                 total_credit_hours_sem += total_credit_hours;  //credits hour get for 
                                                                //all semester
        }
                cgpa = total_point_sem / total_credit_hours_sem;    //calculate CGPA

                cout<<"Name: "<<student1.name<<endl;          //display name of 
                                                                //student

                cout<<"No Matric: "<<student1.no_matric<<endl;
            for(int j = 0; j< sem ; j++)     //Declaration of j as int in for()
            {   
                cout<<"Subject Code\t"<<"Subject Name\t"<<"Subject Credit Hours"<<endl;

                for(int i=0; i<total_subject; i++)   //Declaration of i as int in for()
                {
                    cout<<student1.sub_code[i]<<" : "<<student1.sub_name[i]<<" : "<<student1.credit_hour[i]<<endl;
                }
                    cout<<"GPA"<<j+1<<" : "<<gpa[j]<<endl;    

            }   
            cout<<"CGPA : "<<cgpa<<endl;
    }

I'm following your guidance by deleting the declaration for i and j on line 16 but once i do that, the i for 'gpa[i] = total_point / total_credit_hours' on line 105 will become undefined.

Why do you think that is? You don't need to add that extra variable i, it's masking the actual problem in your code. The compiler is now catching the problem. This is a lesson about naming variables sensibly. i and j are meaningless names. What if you changed i to subjectIndex and j to semesterIndex in your loops?

honestly i'm poor in coding cz i'm still quite a new learner

Don't worry, we were all new to coding once. The aim of the game is to name things clearly (even if it's sometimes longer to type) because the names are there to help you know what's what :)

Ravenous,
Hahhaha...only now i get to know the reason for you to ask me remove the int i...
I have replace the i and j with subjectIndex and semesterIndex in loops but still i can't see where is the problem. There are 3 types of errors occured after i run my coding:
1. Error E2451Assignment2Que2Remend1.cpp 41: Undefined symbol 'j' in function main()
2. Error E2451 Assignment2Que2Remend1.cpp 51: Undefined symbol 'i' in function main()
3. Error E2285 Assignment2Que2Remend1.cpp 55: Could not find a match for 'getline<charT,traits,Allocator>(istream,undefined)' in function main()

haiz...but for me, it's really not very easy start to learnt about coding without basic...some of my friends especially guy can write coding well....sometimes really feel frustrated....T.T.

Ignore the last error for now. Concentrating on the first two errors, if you're still getting error messages referring to i and j then you haven't successfully replaced them with the names suggested in the previous post. Check again (it tells you which lines are causing the problem)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.