I am confuse on size of array declaration
result
size of array : 8
Enter element of array : 1
Enter element of array : 2
Enter element of array : 3
Enter element of array : 4
Enter element of array : 5
Enter element of array : 6
Enter element of array : 7
I don't understand what will happen if I change array size like array[6] or array[8].
array[6] store 6 elements
array[8] store 8 elements
array[2] store 2 element s
Code:
#include<stdio.h>
int main (void)
{
int i, array[4], size;
/* print size of array on screen */
printf ("size of array : ");
/*get size of array from user */
scanf ("%d", &size);
for (i = 0; i < size; i++)
{
/* print the element of array */
printf("Enter element of array : " );
/* get array element from user and them stored into array */
scanf("%d", &array[i]);
}
return 0;
}
size of array : 8
Enter element of array : 1
Enter element of array : 2
Enter element of array : 3
Enter element of array : 4
Enter element of array : 5
Enter element of array : 6
Enter element of array : 7
I don't understand what will happen if I change array size like array[6] or array[8].
array[6] store 6 elements
array[8] store 8 elements
array[2] store 2 element s