ProgrammingModerateTCS NQT · Infosys
What does printf("%d", 6 % 4 * 2) print?
- A. 3
- B. 1
- C. 4
- D. 12
Correct answer: C. 4
% and * have the same precedence and bind left to right, so the expression is (6 % 4) * 2 = 2 * 2 = 4.
More C Programming questions
- Which expression computes ceil(a / b) for positive int a = 7 and b = 3 using integer arithmetic, written as ((a + b - 1) / b)?
- int a[3][4]; for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) a[i][j] = i 4 + j; printf("%d", (&a[0][0] + 7)); What is printed?
- With int a[3][4] (4-byte int, row-major), what is the value of (int )&a[1][0] - (int )&a[0][0]?
- With int a[3][4] (4-byte int) and int (p)[4] = a, what is (char )(p + 2) - (char )p?
- Matrix m = {{1,2,3},{4,5,6},{7,8,9}} is rotated 90 degrees clockwise. What is the first row after rotation?
- Matrix m = {{1,2,3},{4,5,6},{7,8,9}} is transposed in place. What is the first row afterwards?