0
What mistake i am doing in this code.
#include <iostream> using namespace std; int main() { int mark = 90; if (mark < 50) { cout << "You failed." << endl; } else { cout << "You passed." << endl; } if(mark=100){ cout <<"you are perfect"; } return 0; }
7 ответов
+ 4
if(mark == 100)
mark = 100 --> mark gets the value 100
mark == 100 --> using boolean operator to compare 100 with the value of mark.
Is equal return true else return false
+ 4
The sequence is
If (){
}
else if(){
}
else if(){
}
else if(){
}
else if(){
}
.
.
.
.
else{
}
+ 2
Please look at the code. Hope it helps you.
https://code.sololearn.com/cY71GtJLlKKk/?ref=app
+ 1
There's a mistake on your last if statement.
You wrote "if (mark=100)". The problem is that you're not doing a comparison. To compare two values, you need to use "=="
Here, you're setting mark's value to 100 and evaluating it as a Boolean (condition)
By convention, any numeric value that is not zero will return true when evaluated as a condition
+ 1
Okey
+ 1
Thx
+ 1
Now I have got