Program Grade prints appropriate message based on a grade read from the keyboard.
We need to add the logical expression in the if statement for checking whether the grade entered is greater than or equal to 80. If it is greater than or equal to 80, 'Congratulations!' must be printed.
So the logical expression is:
if (grade>=80)
Now the program looks as follows:
//Program Grade prints appropriate message based on a
//grade read from keyboard.
#include <iostream>
using namespace std;
int main()
{
int grade;
cout<<"Enter an integer grade between 50 and 100."
<<" Press return. "<<endl;
cin>>grade;
if(grade>=80)
cout<<"congratulations!"<<endl;
return 0;
}
Now let us run the program for the grades 60,80 and 95.
For grade =60, the if statement returns false. Therefore, nothing gets printed.
For grade=80, the if statement returns True. Therefore Congratulations gets printed.
For grade=95, the if statement returns True. Therefore Congratulations get printed.
Step by step
Solved in 3 steps with 9 images