C Programming Code Examples C > Arrays and Matrices Code Examples program to input and print elements in array program to input and print elements in array Write a C program to input elements in array and print array. How to input and display elements in an array using for loop in C programming. How to input and display array elements Array uses an index for accessing an element. Array index starts from 0 to N-1 (where N is the number of elements in array). To access any an array element we use. array[0] = 10 array[1] = 20 array[2] = 30 array[9] = 100 Since array index is an integer value. Hence, rather hard-coding constant array index, you can use integer variable to represent index. For example, int j = 0; array[j] = 10; // Assigns 10 to first array element #include <stdio.h> #define maxsize 1000 // Maximum array size int main() { int arr[maxsize]; // Declare an array of maxsize int j, N; /* Input array size */ printf("Enter size of array: "); scanf("%d", &N); /* Input elements in array */ printf("Enter %d elements in the array : ", N); for(j=0; j<N; j++) { scanf("%d", &arr[j]); } /* Print all elements of array */ printf("\nElements in array are: "); for(j=0; j<N; j++) { printf("%d, ", arr[j]); } return 0; }