Programming Basics – Using Operators in Pseudocodes: Part 3

Veröffentlicht am: 01 Januar 1970
auf dem Kanal: 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.


Auf dieser Seite können Sie das Online-Video Programming Basics – Using Operators in Pseudocodes: Part 3 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Let's Simplify Computers with MrigVats Learning 01 Januar 1970 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 4,683 Mal angesehen und es wurde von 99 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!