Programming Basics – Using Operators in Pseudocodes: Part 3

Publicado em: 01 Janeiro 1970
no canal de: Let's Simplify Computers with MrigVats Learning
4,683
99

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.


Nesta página do site você pode assistir ao vídeo on-line Programming Basics – Using Operators in Pseudocodes: Part 3 duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Let's Simplify Computers with MrigVats Learning 01 Janeiro 1970, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 4,683 vezes e gostou 99 espectadores. Boa visualização!