Loading...
「ツール」は右上に移動しました。
利用したサーバー: natural-voltaic-titanium
19いいね 839回再生

C Programming Practice 2 on Ternary Operator || Lesson 27 || C Programming || Learning Monkey ||

C Programming Practice 2 on Ternary Operator

In this class, we will do C Programming Practice 2 on Ternary Operator.

We have covered Arithmetic, Assignment, Increment-Decrement, Bitwise, Shift, Ternary, Relational, and Logical Operators.

Here we will solve some C Programming Practice on Ternary Operators.
C Programming Practice on Ternary Operators

The example below is a program on Ternary Operators.

int a = 2, b = 3, c = 4, l;

l = (ab) ? (ac ? a c) (bc ? b c);

In the above program, we have four variables a, b, c, l.

The values assigned to a, b, and c are 2, 3, and 4.

The ternary operators are [?].

The above program finds a large number among the three variables a, b, and c.

The image below is the operator precedence and associativity table.
C Programming Practice 2 on Ternary Operator
Operator Precedence and Associativity Table for Ternary Operator

The expression uses ternary operator in the program is l = (ab) ? (ac ? a c) (bc ? b c).

The C compiler will execute ab if it is true in the above expression, then (ac ? a-c) will be performed.

ab means among a and b a is large.

Now a has to be compared with c.

(ac? a-c) is a ternary operator.

In the above expression, if ac, the output will be a.

Else the output will be c.

If a is NOT greater than b, then (bc ? bc) will be executed.

If bc, b is larger else, c is larger.

#learningmonkey #cprogrammingforbeginners #placements #gatecse #cprogramming #cprogramminglanguage


Link for playlists:
   / @learningmonkey  


Link for our website: learningmonkey.in/

Follow us on Facebook @ www.facebook.com/learningmonkey

Follow us on Instagram @ www.instagram.com/learningmonkey1/

Follow us on Twitter @ twitter.com/_learningmonkey

Mail us @ learningmonkey01@gmail.com

コメント