-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharrays_1.c
35 lines (24 loc) · 884 Bytes
/
arrays_1.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
#include <stdio.h>
/* program to show the use of arrays */
void main(void) {
/* an array that contains 4 integer */
int a[4];
int b = 0;
printf("len of array: %d\n",sizeof(a));
/* print all the integers of the array */
printf("\na[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\n", a[0],a[1],a[2],a[3]);
/* set the first integer in the array */
a[0] = 4;
/* set the second integer in the array */
a[1] = 3;
/* set the third integer in the array */
a[2] = 2;
/* set the fourth integer in the array */
a[3] = 1;
/* print all the integers of the array */
printf("\na[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\n", a[0],a[1],a[2],a[3]);
printf("\nb = %d\n",b);
/* assign the content of the second element of the array to b */
b = a[2];
printf("\nb = %d\n",b);
}