trouble with loops

I cannot get these loops to work correctly, I am a beginner. Can anyone help me out? Thanks in advanced.






#include <iostream>

int main() {

int num_students; //number of students in class
std::cout << "Please enter the number of students in the class: ";
std::cin >> num_students;


int num_quiz;
std::cout<< std::endl << "Please enter the number of quizzes the students have taken: ";
std::cin >> num_quiz;


unsigned int num_loops, students_num, quiz_num; //number of loops and student prompt

char name[50];


for (students_num=0; students_num != num_students; students_num++)
{

students_num++;
std::cout << "Please enter the name for student " <<
students_num;
std::cout << ": ";
std::cin >> name;

for (quiz_num=0; quiz_num != num_quiz ; quiz_num++ )
{

unsigned int grade[5];
std::cout << "Please enter the grade for student " <<
name << ": ";
std::cin >> grade[5];

}
}








return 0;
}
The code would be easier to read in code tags, and indented.

Anyway, there is this students_num++; within the for loop, it seems unnecessary.
i have tried it both ways and neither way seems to work.
Well, it is not necessary and ought to be removed.

But the question is this: what are you trying to achieve?

The name of each student is entered and stored in the same field: name. After all the data is entered, it will hold the name of the last student.

Array unsigned int grade[5]; is defined within the inner for loop, so will disappear from scope when the loop is completed.

So after all the data has been entered, you have one student name, and no grades.

But then the program ends, so ...



the program needs to store the name of the student and the quizzes then i will print out the average of the quizzes after they are all inputed, but i cannot get the loop to occur the amount of times the user specifies.
Topic archived. No new replies allowed.