C++ if-else
C++ if else Control Statement
if else control statement in C++ is used to control the program flow in a two-way direction. When condition returns a true value, then the program executes if condition block otherwise program executes else block.Syntax:
Output:
if(check_condation){
statement;
...;
}
else{
statement;
...;
}
C++ if else Example
#include <iostream>
using namespace std;
int main () {
int a=10;
int b=20;
if( a < b ) {
cout << "a is less than b:" << endl;
}
else{
cout<<"a is greater than b";
}
return 0;
}
a is less than b