Consider the following statements:int x = 10, y = 15;
x = ((x == y) ? (y + x) : (y - x));
What will be the value of x after executing these statements?
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: A. 5
Explanation
x == y is false (10 ≠ 15), so the conditional operator evaluates y − x = 15 − 10 = 5.More Programming Languages and Computer Graphics questions
- The major adverse side effects of scan conversion are: A. Staircase appearance B. Unequal brightness of slanted lines C. Picket fence probl…
- Match List I (Functions) with List II (Uses of functions)List I List II A. fseek() I. Gives the current position in the file B. ftell() II.…
- Which of the following statements is NOT true?
- The light given off by the phosphor during exposure to the electron beam is known as
- Which of the following statements about pointers in C are TRUE? (A) Pointers can be used to access array elements (B) Pointers can store th…
- Consider the function in C code:Cal(a, b) { if (b != 1) { if (a != 1) { printf("*"); Cal(a/2, b); } else { b = b - 1; Cal(10, b); } } } How…