Reputation: 1
I am writing a code that will output "Nice work!" if the entered GPA is over 3.5 and "you need to study harder if the entered GPA is under 2.0. But it is not outputting correctly.
if(gpa[i] >= 2.0){
printf("You need to study harder! \n");
}
else if(gpa[i] <= 3.5){
printf("Nice work! \n");
}
I expect the output "nice work!" if the gpa is over 3.5. and "you need to study harder" if the gpa is under 2.0.
Upvotes: 0
Views: 32
Reputation: 1664
You confused with the logical operator within if condition. It should be like
if(gpa[i] <= 2.0){
printf("You need to study harder! \n");
}
else if(gpa[i] >= 3.5){
printf("Nice work! \n");
}
Upvotes: 1