Poll Results
No votes. Be the first one to vote.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
D. 1
The statement `printf (“%d”, 10 ? 0 ? 5 : 1 : 12);` uses the ternary conditional operator, which works as `condition ? result_if_true : result_if_false`. This operator can be nested, as seen in the statement.
Here is how the expression is evaluated:
1. The condition `10 ? 0 ? 5 : 1 : 12` starts with the first condition `10`, which is true (in C and similar languages, any non-zero value is considered true).
2. Since 10 is true, it evaluates the next part of the expression after the first `?`, which is `0 ? 5 : 1`.
3. This can be seen as a nested ternary operation. Here, the condition is `0`, which is false. Therefore, it chooses the result after the `:`, which is `1`.
So, the expression simplifies to `printf(“%d”, 1);`.
Therefore, the statement will print `1`.