8,614 views
0 votes
0 votes
main()
{
int c[ ]={2,3,4,6,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q; }
for(j=0;j<5;j++){
printf(" %d ",*p);
++p; }
}

1 Answer

0 votes
0 votes
Initially pointers p,q and c are pointing to first element of the array c[].
First pointer c is pointing to first element of array;i.e;2
So first loop will print 2,five times
22222
every iteration q is pointing to next element.So,after five iterations it points to an adress out of array.

In second loop,
p prints content at first element(2),
and then it points to next (p++),

So,23465 is printed.

Total output :

22222

23465

Related questions

2 votes
2 votes
2 answers
2
atulcse asked Jan 15, 2022
662 views
Consider the following programint find (int n) { int a = 1; for (i = 1; i < = n; i ++) for (j = 1; j < = i; j++) for (k = 1; k <= j, k++) a = a + 1; ...
1 votes
1 votes
1 answer
3
Na462 asked Jan 8, 2019
1,402 views
#include <stdio.h>main (){unsigned x = -10;int X = 20;if (X x) printf ("Hello");else{ printf ("%d",x); printf ("Jello"); }}
0 votes
0 votes
0 answers
4
aimhigh asked Jan 8, 2019
1,235 views
#include<stdio.h>void main(){int p=-8;int i= (p++,++p);printf("%d\n",i);}