ProgrammingHardProduct company OA

What is printed?

What is printed?
printf("%d %d", !!"", !*"");
  1. A. 0 0
  2. B. 1 0
  3. C. 0 1
  4. D. 1 1

Correct answer: D. 1 1

A string literal used as a value is a non-null pointer, so even the empty string "" is true and !!"" is 1. *"" is its first character, the '\0', so !*"" is also 1. Testing a string for emptiness must look at its first character.

More C Programming questions

Exams that ask this topic