Explain what's wrong in this if else loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Explain what's wrong in this if else loop

#include <iostream> using namespace std; int main() { int x=9; if(x=10) { cout <<"WTF??"; } else cout <<"OKAY"; return 0; } //output WTF??

17th Feb 2017, 9:59 PM
Ibrahim Iqra
3 Answers
+ 9
It should be if(x==10) Not if(x=10)
17th Feb 2017, 10:05 PM
Boris Sundic
Boris Sundic - avatar
+ 2
@Boris Sundic is right, but accessory, the 'if/else' statement isn't at all a loop: loops are 'for' and 'while' statements, as 'if/else' structure doesn't provide any repetition when it run ^^
18th Feb 2017, 8:09 AM
visph
visph - avatar
0
sorry my mistake 😶
22nd Feb 2017, 10:28 AM
Ibrahim Iqra