ProgrammingModerateTCS NQT · Infosys pattern
What is printed?
What is printed?
printf("%zu", strlen("a\tb\\n"));- A. 6
- B. 5
- C. 7
- D. 4
Correct answer: B. 5
Escape sequences count as one character each: a, \t (tab), b, \\ (one backslash), n. That is 5 characters. \\n is a backslash followed by the letter n, not a newline.
More C Programming questions
- What is printed? c int a = -1, b = 1; if (a > 0) if (b > 0) printf("X"); else printf("Y"); printf("Z");
- What is printed? c int x = 4; if (x & 1 == 0) printf("even"); else printf("odd");
- What is printed? c int f(int n) { static int s = 0; s += n; if (n > 0) f(n - 1); return s; } ... printf("%d ", f(3)); printf("%d", f(3));
- What is printed? c printf("%d", 2 + 3 << 1 & 7);
- How many of these are correct in C? (i) A global variable without an initialiser starts as 0. (ii) A static local variable is initialised…
- What is f in the declaration int (f)(int); ?