C Programming · Question 30 · Hard

What will be the output of the following C program?

#include <stdio.h>

int main(void) {
    const char *s[] = {"pune", "goa", "agra"};
    printf("%c%c%s", *s[1], s[2][1], s[0] + 2);
    return 0;
}
  1. pgne
  2. ggune
  3. gane
  4. ggne
Answer and explanation

Answer: D. ggne

Explanation: *s[1] is the first character of "goa", which is g. s[2][1] is the second character of "agra", which is g. s[0] + 2 points into "pune" at "ne". The output is ggne.

Previous: What will be the output of the following C program?

Practise c programming

Try a fresh set of c programming questions with an explanation after every answer, free and without signing up: C Programming practice. Or sit a full placement mock test.

More c programming questions

More technical & programming practice

Java · Python · Data Structures · Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge