In a program, when manipulating and presenting data in a comprehensive format, you might have to take decision based on some condition. Depending on the result of the condition, you decide to select one of the values over the other.
Conditional operator is yet another operator supported in many programming languages. Various languages different variations of this operator. We will cover these variations in the videos related to these languages. Irrespective to the programming language, the conditional operator requires three operands and therefore, is also known as ternary operator. The most commonly used ternary operator uses the ?: symbol. The first operand is a condition while the second and third operands are some values. When used, it takes the form as:
Variable = condition ? value 1 : value 2
In this case, based on the evaluation of the condition, the operator assigns one of the two values separated by the : symbol. If the condition evaluates to true, value 1 is assigned to the variable, else value 2 is assigned to the variable.
After checking a condition, if you need to further check another condition, then you can use another conditional operator on the either sides of the : symbol. As a result, after the first condition is evaluated, the condition in the next conditional operator is evaluated based on the result of the first condition.
Using a conditional operator within a conditional operator is known as nesting. Depending on your requirements you can further use conditional operator at another level. However, you must consider that more you use nesting for the conditional operator, greater are the elements of confusion.
En esta página del sitio puede ver el video en línea Programming Basics – Using Operators in Pseudocodes: Part 3 de Duración hora minuto segunda en buena calidad , que subió el usuario Let's Simplify Computers with MrigVats Learning 01 enero 1970, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 4,683 veces y le gustó 99 a los espectadores. Disfruta viendo!