271 views
1 votes
1 votes
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 votes
1 votes
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

Related questions

3 votes
3 votes
0 answers
4
mohitbawankar asked Jan 17, 2018
532 views
Consider the following program along with push and pop operations on stack which can contain atmost The decimal value equivalent to the binary number printed by above cod...