ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    const char *s[] = {"ab", "cde", "f"};
    printf("%c%c", *s[2], s[1][2]);
}
  1. A. ef
  2. B. fe
  3. C. ab
  4. D. fc

Correct answer: B. fe

*s[2] reads the first character of "f", and s[1][2] is the third character of "cde", which is e. Each string pointer is indexed separately.

More C Programming questions

Exams that ask this topic