-
Notifications
You must be signed in to change notification settings - Fork 0
/
assign3.c
41 lines (41 loc) · 854 Bytes
/
assign3.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<stdio.h>
int main(void){
int a[3] = {11, 22, 33};
int *pa = a;
//print these
printf("%d\n",*a);
printf("%d\n",*(a+2));
printf("%d\n",*pa);
printf("%d\n",pa[1]);
//NEXT QUESTION
int m[4][4] = {{1,3,5,7}, {11,33,55,77}, {2,4,6,8},{22,44,66,88}};
int (*parr)[4] = m;
/* **m =
*(*m+2) =
*(*(m+1)+1) =
*(m[1]+2) =
(*(m+2))[3] =
(*(parr+3))[2] =
*/
printf("%d\n",**m);
printf("%d\n",*(*m+2));
printf("%d\n",*(*(m+1)+1));
printf("%d\n",*(m[1]+2));
printf("%d\n",(*(m+2))[3]);
printf("%d\n",(*(parr+3))[2]);//this is a problem point
//write a for loop to show all the values of parr
int i,j;
printf("double loop\n");
for(i =0;i<4;i++){
for(j=0;j<4;j++){
printf("%d\n",(*(parr+i))[j]);
}
}
printf("double loop parr\n");
for(i =0;i<4;i++){
for(j =0;j<4;j++){
printf("%d\n",(parr[i][j]));
}
}
return 0;
}