-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab1_q4
31 lines (30 loc) · 1.06 KB
/
lab1_q4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <stdlib.h>
/*write a program that reads integers input by the user and outputsthose integers of 5digits.
The program should end when 0 is the input. The following is an example of the execution of your program("↓"is Enter or the Return key ) */
int main()
{ /* program will print a number based on a students average, the numbers go from 0 to 4 as the
students averages get proceedingly higher and if an invalid input is given, it will print invalid input. */
float average; //used a float as we want to allow numbers with decimal to be valid input
printf("Enter students average\n");
scanf("%f",&average);
if(average>= 90 && average <=100){
printf("4");
}
else if(average>= 80 && average <= 89){
printf("3");
}
else if(average>= 70 && average <= 79){
printf("2");
}
else if(average>= 60 && average <= 69){
printf("1");
}
else if(average <= 59 && average >= 0){
printf("0");
}
else {
printf("You have entered an invalid input");
}
return 0;
}