1If - Else Statements
2if (condition) {
3// what to do if condition is met
4} else {
5// what to do if condition is not met
6}
7
1if (condition1) {
2 // block of code to be executed if condition1 is true
3} else if (condition2) {
4 // block of code to be executed if the condition1 is false and condition2 is true
5} else {
6 // block of code to be executed if the condition1 is false and condition2 is false
7}
1if (condition1) {
2 // block of code to be executed if condition1 is true
3} else {
4 // block of code to be executed if the condition1 is false
5}
1if ( x > 10 )
2{
3cout << "x is greater than 10";
4}
5else
6{
7cout << "x is less than 10";
8}