in Programming in C edited by
618 views
1 vote
1 vote

What is the output of the following program?

$main()$

{

$char *s[]=\left \{ “ice”, “green”, “cone”, “please”\right \};$

$char **ptr[]=\left \{ s+3, s+2, s+1, s\right \};$

$char ***P=ptr;$

$printf(“\%s”,**++P);$

}

  1. Ice
  2. Green
  3. Cone
  4. Please

I think the answer should be $B$ but $C$ is provided as answer.

in Programming in C edited by
618 views

4 Comments

Yes $C$is the correct answer.

$**++P=*(*(++P))$
1
1
Not getting, how?
0
0
**++P is done it  is incremented and points to second element which is s+2

printf("%s",**++p)

(p)-->600

(++P)-->602

(**)-->504

(%s)-->300=cone
0
0

2 Answers

0 votes
0 votes
Initially P is pointing to first element of  ptr array. When **++P is done it  is incremented and points to second element which is s+2 , which points to Cone. Hence C should be answer.
by
0 votes
0 votes

Option c is right.

Related questions