>void main()
This is very wrong, main returns an int and anything else is undefined. This is better:
Code:
#include <iostream>
#include <cctype>
using std::cin;
using std::cout;
int main()
{
int id, mark = 0;
char yesno = 'y';
do {
do {
cout<<"Please enter student id: ";
cin>>id;
cout<<"Please enter student mark: ";
cin>>mark;
} while ( mark < 0 && 100 > mark );
if (mark>=90)
cout<<"Student "<<id<<" got a grade A\n";
else if (mark>=80&&mark<=89)
cout<<"Student "<<id<< " got a grade B\n";
else if (mark>=70&&mark<=79)
cout<<"Student "<<id<< " got a grade C\n";
else if (mark>=60&&mark<=69)
cout<<"Student "<<id<< " got a grade D\n";
else if (mark<=59)
cout<<"Student "<<id<< " got a grade F\n";
cout<<"Again?: ";
cin>>yesno;
} while (toupper(yesno)!='N');
cout<<"Thank you. Bye\n";
return 0;
}
>You are right, it can't.
A switch can validate ranges, but you don't want to do it. An if..else if series is far far better than this:
Code:
switch ( mark ) {
case 100:
case 99:
case 98:
case 97:
.
.
.
case 90:
cout<<"Student "<<id<<" got a grade A\n";
break;
.
.
.
}
-Prelude