ProgrammingHardIBM · Deloitte pattern
What is printed?
What is printed?
int a, b, c;
a = b = c = 5;
printf("%d %d %d", a, b, c);- A. 5 0 0
- B. Compilation error
- C. 0 0 5
- D. 5 5 5
Correct answer: D. 5 5 5
Assignment is right-associative: a = (b = (c = 5)). c is set to 5, that value is assigned to b, and that value is assigned to a, so all three become 5.
More C Programming questions
- file1.c: c static int secret = 7; int getSecret(void) { return secret; } file2.c: c int getSecret(void); int main(void) { printf("%d"…
- What is printed? c int a[3][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12}}; int p = (int )a; printf("%d %d %d", (p + 5), ((a + 1) + 2), (a[2] +…
- Which identifier, even though declared at file scope, never has linkage at all in C?
- What can printf legally print here? c int i = 0; printf("%d %d %d", i++, i++, i++);
- What happens when this is compiled? c int compute(int x); static int compute(int x) { return x 2; } int main(void) { printf("%d"…
- What is printed? c int a[] = {10, 20, 30, 40, 50}; printf("%d", a[1, 3]);