How to write a C Program if - else if - else Example in C Programming language ?
Solution For C Program ://C Program if - else if - else Example.
#include <stdio.h>
int main(){
int score;
scanf("%d", &score);
/*
(X) 90 <= score <= 100
score = 95: 90 <= 95 <= 100
=> 1 <= 100
=> 1
score = 89: 90 <= 89 <= 100
=> 0 <= 100
=> 1
*/
if( (score >= 90) && (score <= 100) ){
printf("A+");
}
else if( (score >= 85) && (score <= 89) ){
printf("A");
}
else if( score >= 80 && score <= 84 ){
printf("A-");
}
/*
=: Value assigned。 ex. a = 2; => 2
==: After the judgment equal results。 ex. 2 == 2; => 1
3 == 2; => 0
*/
else if( score == 0 ){
printf("X");
}
return 0;
}