ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
int n = printf("%d", printf("%s", "abc"));
printf(" %d", n);- A. abc3 4
- B. abc3 1
- C. abc 3 1
- D. 3abc 1
Correct answer: B. abc3 1
The inner call runs first (its result is an argument), printing abc and returning 3. The outer call prints 3 and returns 1, the number of characters it wrote. So the screen shows abc3, then a space and 1.
More C Programming questions
- What is printed? c int f(int n, int b) { return n < b ? 1 : 1 + f(n / b, b); } int main(void) { printf("%d %d %d", f(1000, 2), f(1000…
- What is printed? c const char s = "education"; int v = 0, o = 0; for (; s; s++) switch (s) { case 'a': case 'e': case 'i': case 'o': case…
- Which of these functions return a pointer that is still valid to read after the function returns? c char f1(void) { char s[] = "hi"…
- Assume 32-bit unsigned int. What is printed? c unsigned int x = 65536; printf("%u %u", x x, x (x - 1) / 2);
- What is printed? c int i = 0; while (i++ < 5); printf("%d", i);
- What is printed? c #define LEVEL 2 #if LEVEL > 1 #define MSG "high" #elif LEVEL > 0 #define MSG "low" #endif #undef LEVEL #ifndef LEVEL…