edited by
589 views
1 votes
1 votes

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.

edited by

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.

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
4
Mahbub Alam asked Nov 19, 2018
235 views
#include<stdio.h>void main(){ int i ;for(i=0; i<5; i++)f() ;}void f(){static int x ;x=5 ;x++ ;printf("%d", x);}OUTPUT OF THE FUNCTION IS(A)6,6,6,6,6(B)6,7,8,9,10(C)5,5,5,...