Think about a situation where you got a project and it requires branching procedures. You are given an option of choosing between if-else and conditional operator, which one you will choose and tell why?
Answers
Explanation:
Conditional Statements in C programming are used to make decisions based on the conditions. Conditional statements execute sequentially when there is no condition around the statements. If you put some condition for a block of statements, the execution flow may change based on the result evaluated by the condition. This process is called decision making in 'C.'
In 'C' programming conditional statements are possible with the help of the following two constructs:
1. If statement
2. If-else statement
It is also called as branching as a program decides which statement to execute based on the result of the evaluated condition.
The if statement doesn't yield a value, so the statements in the "then" and "else" parts don't need to be type compatible in any way. The conditional operator yields a value, and therefore both parts must be type compatible in some way in order for the compiler to determine the type of the expression.
.