Write a program that prompts the user to enter a grade, which is aninteger in the range of 0 - 100. Using if statements, have theprogram output an error message of the score is too low or toohigh.

Respuesta :

C program prompts the user to enter a grade

#include<stdio.h>

int main()//driver function

{

int grade;

printf("Please enter grades\n");//taking input from user

scanf("%d",&grade);

if(grade<0)/*checking whether the grade is less than zero(0)*/

printf("Error-Score is too low");

if(grade>100)/*checking whether the grade is higher than 100*/

printf("Error-Score is too high");

if(grade>=0 &&grade<=100)/*checking whether the grade is in 0-100*/

printf("you got %d ",grade);

}

Output

Please enter grades

103

Error-Score is too high

Please enter grades

77

you got 77

Please enter grades

-3

Error-Score is too low

ACCESS MORE