-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhw6.c
More file actions
46 lines (37 loc) · 691 Bytes
/
hw6.c
File metadata and controls
46 lines (37 loc) · 691 Bytes
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
42
43
44
45
46
#include <stdio.h>
int main(void) {
int arr1[6] = {1, 2, 3, 4, 5, 6};
int arr2[6] = {7, 8, 9, 10, 11, 12};
int* ptr1 = &arr1[0];
int* ptr2 = &arr2[0];
int temp;
printf("arr1 =");
for(int i = 0; i < 6; i++){
printf(" %d", arr1[i]);
}
printf("\n");
printf("arr2 =");
for(int i = 0; i < 6; i++){
printf(" %d", arr2[i]);
}
printf("\n");
for(int i = 0; i < 6; i++){
temp = *ptr1;
*ptr1 = *ptr2;
*ptr2 = temp;
ptr1++;
ptr2++;
}
printf("after swap \n");
printf("arr1 =");
for(int i = 0; i < 6; i++){
printf(" %d", arr1[i]);
}
printf("\n");
printf("arr2 =");
for(int i = 0; i < 6; i++){
printf(" %d", arr2[i]);
}
printf("\n");
return 0;
}