Array and pointer in c/c++

main()
{
int d[]={2.8,3.4,4.6.7,5};
int j,*p=c,*q=d;
for(j=0;j<5;j++)
{
printf(“%d”,*d);
++q;
}
for(j=0;j<5;j++)
{
printf(“%d”,*p);
++p;
}

}

Tutorial answer:2222223465

Debugging explanation:
Initially pointer c is assigned to both p and q.In the first loop,
In these time q is increment but not c.so it will print 2in 5 times.In the second loop p itself is incremented .so the values 2,3,4,6,5

Related post