If-else in C++ Language
In C++ programming language, if statement is used to test the condition. There are various types of if statements in C++.
- if statement
- if-else statement
- nested if statement
- if-else-if ladder
C++ IF Statement
The C++ if statement tests the condition. If condition is true then program is executed.
C++ If Example -
Output -
C++ IF-else Statement
The C++ if-else statement also tests the condition. If block executes when condition is true otherwise else block is executed.
C++ If-else Example -
Output -
C++ If-else Example: with input from user -
Output -
Output -
C++ If-else-if ladder Statement
The C++ if-else-if ladder statement executes one condition from multiple block of statements.
C++ If-else-if Example -