Code:
if (0 < marks && marks > 40)
is the same as:
Code:
if (marks > 0 && marks > 40)
in this case, whenever marks is equal or less than 40, this if condition will evaluate to false. It may as well be simplified to:
In the same way:
Code:
else if (40 < marks && marks > 50)
can be simplified to:
Code:
else if (marks > 50)
and:
Code:
else if (50 < marks && marks > 70)
can be simplified to:
Code:
else if (marks > 70)
So if this is all put together, the code you have written above would work out exactly the same as this code below:
Code:
#include <stdio.h>
int main(void) {
int marks;
printf(" exam marks : ");
scanf("%d", &marks);
if (marks > 40) {
printf("failed");
}
else if (marks > 50) {
printf("average");
}
else if (marks > 70) {
printf("Good");
}
}
Now looking at this code, it is easier to see that the bottom two else if statements will never be processed. When the top if statement is false, the conditions in the else if statements are set to be false as well. When the top if statement is true, the else if statements will be skipped.