Decision making statements in C will let you to execute specific blocks of statements under specified conditions. The decision making statements will check for the given condition and if it meets specified condition then it will allow execution of statements.
C languages has provided numerous method for making decisions in programs:
Following are the available statements for decision making in C language:
- if statement
If statement consists of only true block. You can execute number of statements if the condition is true.
For more about if statement visit my article on If statement in C - if … else statement
If else statement consists of two blocks true and false block. When the given condition is true the true block is executed and if the condition is false then the false block is executed.
For more about if … else statement visit my article on If … else statement in C. - if … else if … else statement
If … else if … else statement is an extended form of if … else statement. It provides number of optional blocks for the different conditions.
For more about if … else if … else statement visit my article on If … else if … else statement in C. - nested if statement
Nested if statement is same as if statement in addition in this statement we can write number of if statements within if statement.
For more about nested if statement visit my article on Nested if statement in C. - switch case statement
Switch case statement consists of number of cases which upon condition match execute the statements.
For more about switch case statement visit my article on Switch case statement in C. - conditional statement
A conditional statement is a ternary operator. It has three blocks the condition block, the true block and the false block.
For more about conditional statement visit my article on Conditional statement in C.