C++ Control Statement
C++ control statement or decision-making statement is used to control the flow of program statement according to condition applied.
C++ if Control Statement
An
if control statement in C++ is used to control the flow of program statement on behalf of condition applied.
When
if condition returns
true boolean value, then statement within if block will be executed. And when if condition returns
false boolean value, then statement after if the condition will be executed.
Syntax
if(check_condation){
statement 1;
statement 2;
...;
}
Example
#include <iostream>
using namespace std;
int main () {
int a = 10;
int b=20;
if( a < b ) {
cout << "a is less than b:" << endl;
}
cout << "value of a is : " << a <<endl << "value of b is : "<< b;
return 0;
}
Output
a is less than b:
value of a is : 10
value of b is : 20