Allow user to add 4 Subjects

Ok, i am have trouble getting my head around on what way should i do a loop for this part of my Program.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
for (n = 0; n < N_STUDENT;n++)
    {
       	while((cout<<"Enter Student Number: ")&&(!(cin>>record[n].student_number)||record[n].student_number<0)){
            cout<<"Invalid Input! Please Enter Student Number "<<endl;
            cin.clear();
            cin.ignore(1000,'\n'); 
		}
        
        cout << "Enter Student  Name: ";
        cin >> record[n].studentname;
        
        cout << "Enter Student Address: ";
        cin >> record[n].Address;        
        
		while((cout<<"Enter Date: ")&&(!(cin>>record[n].date_registered)||record[n].date_registered<0)){
            cout<<"Invalid Input! Please Enter Date"<<endl;
            cin.clear();
            cin.ignore(1000,'\n'); 
		}
        
        cout << "Enter Course Name: ";
        cin >> record[n].CourseName;
        
        	while((cout<<"Enter Marks: ")&&(!(cin>>record[n].Marks)||record[n].Marks<0)){
            cout<<"Invalid Input! Please Enter Marks"<<endl;
            cin.clear();
            cin.ignore(1000,'\n'); 
	}


I can Add up to Ten Students, but i Cant seem to allow them to enter up to 4 Courses within Course Name, And Enter their Marks for the 4 if they Added four Course to their Name.

I believe the problem is with your definition of the student struct or class. May I take a look at that part of your code? If the problem isn't related to your definition of student then it is related to how you are using it. In either of those cases I will need to see how you are storing your student data.
Topic archived. No new replies allowed.