UGC NET CS 2010 June-Paper-2
October 24, 2023UGC NET CS 2010 June-Paper-2
October 24, 2023UGC NET CS 2010 June-Paper-2
Question 11
|
The statement
printf(“%d”,10 ? 0 ? 5 : 1 : 12);
will print
printf(“%d”,10 ? 0 ? 5 : 1 : 12);
will print
10
|
|
0
|
|
12
|
|
1
|
Question 11 Explanation:
We can write above statement into (10 ? (0 ? 5 : 1) : 12)
Step-1: (0 ? 5 : 1) → It will give result 1 because the condition is FALSE because given value is 0. If nonzero given in condition, it will print TRUE value.
Step-2: (10 ? 1 : 12) → Here, given condition is nonzero. So, it will print TRUE value. The TRUE value is 1.
Note: Ternary operators(?:) evaluation starts from innermost conditions first.
Step-1: (0 ? 5 : 1) → It will give result 1 because the condition is FALSE because given value is 0. If nonzero given in condition, it will print TRUE value.
Step-2: (10 ? 1 : 12) → Here, given condition is nonzero. So, it will print TRUE value. The TRUE value is 1.
Note: Ternary operators(?:) evaluation starts from innermost conditions first.
Correct Answer: D
Question 11 Explanation:
We can write above statement into (10 ? (0 ? 5 : 1) : 12)
Step-1: (0 ? 5 : 1) → It will give result 1 because the condition is FALSE because given value is 0. If nonzero given in condition, it will print TRUE value.
Step-2: (10 ? 1 : 12) → Here, given condition is nonzero. So, it will print TRUE value. The TRUE value is 1.
Note: Ternary operators(?:) evaluation starts from innermost conditions first.
Step-1: (0 ? 5 : 1) → It will give result 1 because the condition is FALSE because given value is 0. If nonzero given in condition, it will print TRUE value.
Step-2: (10 ? 1 : 12) → Here, given condition is nonzero. So, it will print TRUE value. The TRUE value is 1.
Note: Ternary operators(?:) evaluation starts from innermost conditions first.
Subscribe
Login
0 Comments