C++ - Conditional statement: if, if else
By conditions we can control our program. thanks conditional statement we can control program running in two directions. if the condition is satisfied to continue running the program in a first direction, if not as the second direction. under the directions of the programme I think either statement or block of statements.if, if else
Description
if (condition) statement1
if (condition) statement1 else statement2
Input
- condition - Logical value The condition can be any expression
- statement1 - statements
- statement2 - statements
Examples
C++
Conditional statement the possible of use:if (i > 10)
{
i =10; i = i - 1; i++;
}
if (i < 10) i = 10; else i=1;
C++
Other pieces of example codes:if (x>1) { x=1; y=y-1; }
if ( x >= 12 ) while ( y >= 0 ) --y;
if (y < 100) x++;
if ( y > 32 ) c=true;
if (x>10) y = (float)x / 0xa; // y = 1
if (y<5) y = y/ 3.14; // y = 1.234
Conditional statement in another programming language:
Differences to: