int main()
{
char answer;
double correct = 0;
double incorrect = 0;
const int TOTAL = 6;
double grade;
cout << "1. Who was the first president of the U.S. " << endl;
cout << endl;
cout << "(A). Thomas Jefferson" << endl;
cout << "(B)/>. Andrew Jackson" << endl;
cout << "(C). George Washington" << endl;
cout << "(D). George Bush" << endl;
cout << "(E). Bill Clinton" << endl;
cout << "(F). Chester A. Arthur" << endl;
cin >> answer;
answer = toupper(answer);
while (answer != 'A' & answer != 'B' & answer != 'C' & answer != 'D' & answer != 'E' & answer != 'F'){
cout << "Please enter a valid answer. " << endl;
cin >> answer;
answer = toupper(answer);
}
if (answer == 'C'){
correct++;
}
else{
incorrect++;
}
Also, if you see anything else that I could do to make the code more efficient, that would appreciated also. Thanks for the help.

New Topic/Question
Reply




MultiQuote




|