753 views
1 1 vote
main(){
static int n[3][3] = {2,4,3,6,8,5,3,5,1};
Int i,j;
for(i=2;i>=0;i--){
for (j=2;j>=0;j--){
printf(“%d ”,*(*(n+i)+j));
}
}

What will be the output of the program?

1 Answer

1 1 vote
2 4 3 6 8 5 3 5 1
1000 1002 1004 1006 1008 1010 1012 1014 1016
  • *(*(n+i)+j) = here *(n+i) means skipping 'i' rows which contains 3 elements of each size "c" bytes {here, i assumed c=2Bytes} and selecting row which is done by "*".
  • after that, 'j' elements are skipping of size "c" bytes.

first iteration:

i=2, j=2

*(*(1000+2)+2) = *(*(1000+2*3*2)+2*2)  = *(*(1012)+4) =*(1016) = 1

similarly for i=2,j=1 

*(*(1000+2)+1) = *(*(1000+2*3*2)+1*2)  = *(*(1012)+2) =*(1014) = 5

final o/p: 1 5 3 5 8 6 3 4 2

Position:
Show:

Related questions

1 1 vote
0 0 answers
389
389 views
Umesh Shelke asked Aug 24, 2025
389 views
A. z K SB. 122 75 83C. * - +D. P x +
0 0 votes
1 answers 1 answer
1.7k
1.7k views
kallu singh asked Sep 8, 2018
1,722 views
Question:-Consider the following program fragmenta = 0 for (x = 1; x < 31; ++x) for (y = 1; y < 31; ++y) for (z = 1; z < 31; ++z) if (((x + y + z)%3) = =0) a = a + 1; pri...