#include <iostream>
using namespace std;
int main()
{
int grade;
do {
cout << "Enter grade: ";
cin >> grade;
} while ((grade < 0) || (grade > 100));
cout << grade;
system("pause");
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int grade;
do {
cout << "Enter grade: ";
cin >> grade;
if ((grade < 0) || (grade > 100))
cout << "Invalid grade has been entered \n";
} while ((grade < 0) || (grade > 100));
cout << grade << endl;
system("pause");
return 0;
}
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
int grade;
do {
cout << "Enter grade: ";
cin >> grade;
if (grade == 999) {
exit(0);
}
if ((grade < 0) || (grade > 100))
cout << "Invalid grade has been entered \n";
} while ((grade < 0) || (grade > 100));
cout << grade << endl;
system("pause");
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int grade;
int k = 0;
do {
cout << "Enter grade: ";
cin >> grade;
k++;
if ((grade < 0) || (grade > 100))
cout << "Invalid grade has been entered \n";
} while (((grade < 0) || (grade > 100)) && (k<5)) ;
if ((grade >= 0) && (grade <= 100)) {
cout << grade << endl;
}
system("pause");
return 0;
}
http:
Comments