The conditional expr1 is evaluated first. If it is non-zero (true), then the expr2 is evaluated, and that is the value of the conditional expression. Otherwise expr3 is evaluated, and that is the value. Only one of expr2 and expr3 is evaluated. In this example given below z will be the maximum of a and b,
Program: Illustration of arithmetic and conditional operators
# include<stdio. h>
Void main ()
{
Int i, j, k, m;
I = 17;
J = 5;
K =i++ - j;
Printf (“I = %d j= %d k= %d\n”, I, j, k);
M= ++i +j;
Printf (“i = %d j = %d m = % d \ n”, i, j, m);
Printf (“i/j = % d / n”, I / j):
Printf (“i %%j = % d / n”, I % j );
Printf (“i+ = j % d \ n”, I + j);
Printf (“%d/n”, (i>j)? 1: 0);
Printf (“%d/n”,(i<j) ? 1: 0);
}
Output
i = 18 j = 5 k = 12
i = 19 j = 5 m = 24
i / j = 3
i % j = 4
i + =j = 24
1
0
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc