initialize array c code example
Example 1: array value from user c
#include <stdio.h>
int main(void)
{
int size, i;
printf("Enter the size of the arrays:\n");
scanf("%d", &size);
int arr1[size];
printf("Enter the elements of the array:\n");
for (i = 0; i < size; i++) {
scanf_s("%d", arr1[size]);
}
printf("The current array is:\n %d", arr1[i]);
}
Example 2: c array initialization
int x[] = {1,2,3};
int y[5] = {1,2,3};
int z[3] = {0};
Example 3: how to initialize an array in c
double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0};