so here the if inside the loop is it possible to write the if statement in an optimized way or should I just split the two conditions?
#include <iostream>
using namespace std;
int main()
{
int grade, counter = 1, total = 0, average;
while (counter <= 10)
{
cout << "Enter grade /100: ";
cin >> grade;
if (grade < 0 && grade > 100) //HERE PLEASE
{
cout << "invalid grade value." << endl;
cout << "Reenter grade value */100*: ";
cin >> grade;
}
total = total + grade;
counter++;
}
average = total / 10;
cout << "\nThe class average is: " << average << endl;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire