having an issue

Working on an assignment for my C++ homework. Writing a loop that calls a function out of main in order to complete it. However, whenever I begin the loop it just freezes. Anyone have any clue what's wrong?


#include <iostream>

using namespace std;

void AvgGrade(int, int);

int main()
{
int student_id;
int counter, student_number, test1, test2, lab1, lab2, lab3, lab4, final_score, average_score;


cout << "Please enter the number of students: ";
cin >> student_number;
cout << endl;

counter = 0;
while (counter < student_number);
{
cout << "Please enter your Student ID number:";
cin >> student_id;
cout << "Please enter the score for your first test: ";
cin >> test1;
cout << "Please enter the score for your second test: ";
cin >> test2;
cout << "Please enter the score for lab 1: ";
cin >> lab1;
cout << "Please enter the score for lab 2: ";
cin >> lab2;
cout << "Please enter the score for lab 3: ";
cin >> lab3;
cout << "Please enter the score for lab 4: ";
cin >> lab4;


final_score = test1 + test2 + lab1 + lab2 + lab3 + lab4;
average_score = final_score / 6;
AvgGrade(average_score, student_id);
counter++;

}


return 0;
}

void AvgGrade(int average, int student)
{
char grade;

if (average >= 90)
{
grade = 'A';
}
else if (average >= 80)
{
grade = 'B';
}
else if (average >= 70)
{
grade = 'C';
}
else if (average >= 60)
{
grade = 'D';
}
else if (average >= 0)
{
grade = 'F';
}

cout << student << endl;
cout << "Your Average Score is: " << average << endl;
cout << "Your final grade is: " << grade << endl;

}

Please use code tags when posting code.
https://www.cplusplus.com/articles/jEywvCM9/

> while (counter < student_number);
That ; at the end is a killer.

You wrote this.
1
2
3
while (counter < student_number) {
  // do nothing
}


Just delete that one ; and you should be fine.
Last edited on
Sorry sort of new to this site. Also wow am I dumb. Thanks!
Topic archived. No new replies allowed.