ProgrammingModerateTCS NQT · Infosys pattern

What is printed?

What is printed?
printf("%zu", strlen("a\tb\\n"));
  1. A. 6
  2. B. 5
  3. C. 7
  4. 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

Exams that ask this topic