Write a C Program to input values into an array and display them

By | 18.03.2017

C Program to input values into an array and display them


Write a C Program to input values into an array and display them. Here’s a Simple Program input values into an array and display them in C Programming Language.

Following C Program ask to the user to enter values that are going to be stored in array. Here we make an intialize an array of 5 elements to be stored in it i.e arr[5].

In this program , we use two for loop : One is to input values in the program to store to an array. And second loop is used to display  elements of an array one by one on the screen.

Below is the source code for C Program to input values into an array and display them which is successfully compiled and run on Windows System to produce desired output as shown below :


SOURCE CODE : :


/* Program to input values into an array and display them*/
#include<stdio.h>

int main()
{
        int arr[5],i;
        for(i=0; i<5; i++)
        {
                printf("Enter the value for arr[%d] : ",i);
                scanf("%d", &arr[i]);
        }
        printf("The array elements are : \n");
        for(i=0; i<5; i++)
                printf("%d\t", arr[i]);
        printf("\n");
}

OUTPUT : :


Enter the value for arr[0] : 5
Enter the value for arr[1] : 3
Enter the value for arr[2] : 8
Enter the value for arr[3] : 6
Enter the value for arr[4] : 1
The array elements are :
5       3       8       6       1

Above is the source code for C Program to input values into an array and display them which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach upto you in the short interval. Thanks for reading the post.

Feel Free to ASK !

3.8 5 votes
Article Rating
Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
jui

thank you

Void

thank you very much!