+ 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 ?
3 Respostas
+ 5
thank you for your information Bebida and Shraddha 😀
+ 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;
}
+ 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.