C
Programming and Technical
Programming
Program
find the output
main( )
{
static int a[ ] = {0,1,2,3,4};
int *p[ ] = {a,a+1,a+2,a+3,a+4};
int **ptr = p;
ptr++;
printf(“n %d %d %d”, ptr-p, *ptr-a, **ptr);
*ptr++;
printf(“n %d %d %d”, ptr-p, *ptr-a, **ptr);
*++ptr;
printf(“n %d %d %d”, ptr-p, *ptr-a, **ptr);
++*ptr;
printf(“n %d %d %d”, ptr-p, *ptr-a, **ptr);
}
Read Solution (Total 4)
-
- Ans.
1,1,1
2,2,2
3,3,3
3,4,4.
from left to right we have to analyze.
ptr=p
ptr++ means ptr=p+1.
s=*ptr++ means s=*ptr and ptr=p+2.
s=*++ptr means first ptr=p+3, s=*ptr.
s=++*ptr means first *ptr=a+3, and *ptr=*ptr+1=a+4.
- 10 years agoHelpfull: Yes(1) No(1)
- code error
- 10 years agoHelpfull: Yes(0) No(3)
- Go through with pointer chapter in "Exploring C" by yashwant kanetkar.
- 10 years agoHelpfull: Yes(0) No(2)
- hi muneeswaran, how error will come? pls explain
- 10 years agoHelpfull: Yes(0) No(0)
C Other Question