ProgrammingVery hardProduct company OA

What is printed?

What is printed?
char *s[] = {"alpha", "beta", "gamma", "delta"};
char **p = s;
p += 2;
printf("%c ", **p);
printf("%c ", *(*(p - 1) + 2));
printf("%s ", *--p + 1);
printf("%c", (*++p)[3]);
  1. A. g t eta m
  2. B. g t beta m
  3. C. g e eta m
  4. D. g t eta a

Correct answer: A. g t eta m

p → "gamma", so **p is 'g'. *(p − 1) is "beta" and +2 gives 't'. *--p moves p back to "beta" and +1 skips one char: "eta". *++p moves p forward to "gamma" again and [3] is 'm'. 'beta' forgets the +1, which applies after the dereference.

More C Programming questions

Exams that ask this topic