C Program to Display Array Elements

In this program, you'll learn to display array elements. An array is a collection of homogeneous (same type) data items stored in contiguous memory locations. For example if an array is of type “int”, it can only store integer elements and cannot allow the elements of other types such as double, float, char etc. An element is accessed by indexing the array name. This is done by placing the index of the element within square brackets after the name of the array. For example − int max = arr[2];

Source Code

int main()
    int a[5];
    int i=0;

    printf("Enter 5 numbers: ");

    for(i=0; i<5; i++)
        scanf("%d", &a[i]);

    printf("\nArray elements are..\n");
    for(i=0; i<5; i++)
        printf("a[%d] = %d\n", i, a[i]);
    return 0;
Enter 5 numbers:

Array elements are..
a[0] = 47
a[1] = 51
a[2] = 68
a[3] = 91
a[4] = 105

"Coding Hub - Learn to code" app now available on Google Play Store