UGC NET CS 2010 June-Paper-2
October 24, 2023
UGC NET CS 2010 June-Paper-2
October 24, 2023
UGC NET CS 2010 June-Paper-2
October 24, 2023
UGC NET CS 2010 June-Paper-2
October 24, 2023

UGC NET CS 2010 June-Paper-2

Question 11
The statement
printf(“%d”,10 ? 0 ? 5 : 1 : 12);
will print
A
10
B
0
C
12
D
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.
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.
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!