ProgrammingVery hardProduct company OA
What is printed?
What is printed?
int a[] = {10, 20, 30, 40, 50};
printf("%d", a[1, 3]);- A. 20
- B. Compilation error
- C. Garbage value
- D. 40
Correct answer: D. 40
Inside [] the comma is the comma operator (not an argument separator), which evaluates 1, discards it, and yields 3. So a[1, 3] is a[3] = 40.
More C Programming questions
- What can be said about this program? c int main(void) { int arr[5]; arr[5] = 10; printf("%d", arr[5]); }
- What is the only output consistent with the C standard? c int a[3] = {10, 20, 30}; int p = a; printf("%d %d", p++, p);
- What is printed? c int x = 5; x = x++ + 1; printf("%d", x);
- What is printed? c int i, j; for (i = 0, j = 10; i < 3; i++, j--) ; printf("%d %d", i, j);
- What is printed? Assume 32-bit int, two's complement. c unsigned int a = 5, b = 9; a = a ^ b; b = a ^ b; a = a ^ b; printf("%u %u", a, b);
- What is printed? c int flag = 0, mask = 2; flag |= mask == 2; printf("%d", flag);