Input and print the array
C program to input an array and print that array.
Program
#include<stdio.h>
#include<conio.h>
#define MAX 50
void main()
{
int arr[MAX];
int i, n;
printf("Enter the number of elements in the array\t:");
scanf("%d",&n);
printf("Enter the elements\n");
for(i=0;i<n;i++)
{
printf("Element %d\t:",i+1);
scanf("%d",&arr[i]);
}
printf("\nElements of the array you entered are\n");
for(i=0;i<n;i++)
{
printf("Element %d\t:%d\n",i+1,arr[i]);
}
getch();
}
Output
Enter the number of elements in the array :7
Enter the elements
Element 1 :12
Element 2 :23
Element 3 :43
Element 4 :23
Element 5 :45
Element 6 :65
Element 7 :67
Elements of the array you entered are
Element 1 :12
Element 2 :23
Element 3 :43
Element 4 :23
Element 5 :45
Element 6 :65
Element 7 :67