Decision-Making Statements in C
In any programming language decision making is a core concept, A programmer must know about decision making. Read the below lines carefully!
- If there is a football match on TV I will stay at home.
- If I get $1000 I will buy a computer this month.
- If I will pass the exam I would like to have a party.
In the above sentence, the decision will be made on some conditions, if the condition is true then the task will happen otherwise not.
In the same way, In C programming decisions are also made based on some conditions. For example...
Condition For Voting
age >= 18;
If Condition is True
If the above condition is true then, the boy is eligible for voting.
If the Condition is False
If the above condition is false then, the boy is not eligible for voting.
The above example is very small but as a programmer, we have worked on large data that may need many decisions based on various conditions.
Types of Decision-Making Statements in C
In C programming there are 4 ways to decide the conditions. It depends on the programmer which decision-making technique he wants to use to make the decision.
- if statement
- if-else statement
- Nested if-else statement
- switch case statement.