What is the difference between if and else statement in C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference between if and else statement in C++

26th Mar 2018, 5:55 AM
Ravi
Ravi - avatar
3 Answers
+ 1
if and else is a conditional statement, which executes when certain condition is met. eg: int x = 6; if (x>5) { cout << "hello"; } else { cout<< "hi"; } //outputs hello
26th Mar 2018, 6:13 AM
Nilesh
Nilesh - avatar
+ 1
Else needs an If statement before it, but an if statement works alone. If your condition in the if statement if false the else block will be executed: if (condition) { code; } else { //if the condition of the if before is false the else block will be executed code; }
26th Mar 2018, 6:16 AM
Aaron Eberhardt
Aaron Eberhardt - avatar
0
i am new in solo learn i am just in 8 th standard is it difficult for me or not to learn python anyone tell
26th Mar 2018, 7:25 AM
Pushkar Patade
Pushkar Patade - avatar