C - 07 Programming Nested if else, if else if, ternary operator

preview_player
Показать описание
C Nested If..else statement
When an if else statement is present inside the body of another “if” or “else” then this is often called nested if else.

C – else..if statement
The else..if statement is beneficial once you got to check multiple conditions within the program, nesting of if-else blocks are often avoided using else..if statement.

Nested Ternary operator
In programming , ?: may be a ternary operator that's a part of the syntax for basic conditional expressions in several programming languages. it's commonly mentioned because the conditional operator, inline if (iif), or ternary if. An expression a ? b : c evaluates to b if the worth of a is true, and otherwise to c. One can read it aloud as "if a then b otherwise c".
It originally comes from CPL, during which equivalent syntax for e1 ? e2 : e3 was e1 → e2, e3.
Although many ternary operators are possible, the conditional operator is so common, and other ternary operators so rare, that the conditional operator is usually mentioned because the ternary operator.
Ternary operator also referred to as conditional operator uses three operands to perform operation.
Nested Ternary operator: Ternary operator are often nested. A nested ternary operator can have many forms like :
a ? b : c
a ? b: c ? d : e ? f : g ? h : i
a ? b ? c : d : e

Why don’t we see this pattern more often then?
One limitation to the present technique compared to the else-if sequence is that there can’t be more that one statement for every conditional. If you would like to try to to two things, or instantiate an intermediary variable, the entire thing must replaced by a classical else-if sequence. Unless you're taking the statements out into a separate function.

Zeedup Course:
Рекомендации по теме