-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray.c
More file actions
24 lines (24 loc) · 717 Bytes
/
Array.c
File metadata and controls
24 lines (24 loc) · 717 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
#include <stdio.h>
#include <string.h>
int main ()
{
int arr[4] = {23,45,22,56};
int*ptr=arr;
printf("printing the array using normal method\n");
for (int i = 0; i < 4; i++)
{
/* code */
printf("The value at arr[%d] is %d\n",i,arr[i]);
}
printf("\n printing the array using pointer arithmetic\n");
// for (int i = 0; i < 4; i++)
// {
// /* code */
// printf("The value at arr[%d] is %d \n",i,*(ptr+i));
// }
printf("The value at arr[%d] is %d \n",0,*(ptr));
printf("The value at arr[%d] is %d \n",1,*(ptr+1));
printf("The value at arr[%d] is %d \n",2,*(ptr+2));
printf("The value at arr[%d] is %d \n",3,*(ptr+3));
return 0;
}