ProgrammingModerateWipro · Capgemini pattern
What is printed?
What is printed?
printf("%d", printf("hello"));- A. 5
- B. hello5
- C. hello
- D. 5hello
Correct answer: B. hello5
The inner printf must run first to produce the argument: it prints hello and returns the number of characters written, 5. The outer printf then prints 5, giving hello5.
More C Programming questions
- On a 64-bit system (8-byte pointers, 4-byte int), what does f print? c void f(int a[10]) { printf("%zu", sizeof(a)); }
- How many times is fib called in total (including the first call) when evaluating fib(5)? c int fib(int n) { if (n <= 1) return n; return…
- What is printed? c int x = 181, c = 0; while (x) { x &= x - 1; c++; } printf("%d", c);
- What is printed? c printf("%d", 1 << 3 + 1);
- On a typical compiler where int is 4 bytes and 4-byte aligned, what is printed? c struct S { char c; int i; char d; }; struct T { int i…
- With 4-byte int, consider int (p)[5]; Which is correct?