+ 5

How can I fix this code ?

https://code.sololearn.com/cCxFqpw1eFK2/?ref=app in this code. I want to write my percentage and then the program displays my grad (A+,A,B,c...).. can you help me ?

27th Apr 2017, 2:17 PM
Enas Emad
Enas Emad - avatar
3 Respostas
+ 5
thank you for your information Bebida and Shraddha 😀
27th Apr 2017, 2:30 PM
Enas Emad
Enas Emad - avatar
+ 3
The way you have written the if conditions is a bit off. Here is how it should be: #include <iostream> using namespace std; int main() { int x; cout<<"enter the mark: "; cin>>x; if(x>=80){ cout<<"A+"; } if(x>=70 && x<80){ cout<<"A"; } if(x>=60 && x<70){ cout<<"B"; } if(x>=50 && x<60) { cout<<"C"; } if(x>=40 && x<50) { cout<<"D";} if(x<40){ cout<<"F"; } return 0; }
27th Apr 2017, 2:26 PM
Shraddha
Shraddha - avatar
+ 1
The compiler cannot understand a<b<c, you have to put it like so, a<b && b<c. Also you could make the ifs else ifs.
27th Apr 2017, 2:23 PM
Bebida Roja
Bebida Roja - avatar