Write a program in c to store elements in an array and print it or write a c program to read and print elements of array
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],n,i;
clrscr();
printf("How many elements? ");
scanf("%d",&n);
printf("Enter the elements\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("The entered elements are\n");
for(i=0;i<n;i++)
printf("a[%d]=%d\n",i,a[i]);
getch();
}
Output:
How many elements? 5
Enter the elements
1
2
3
4
5
The entered elements are
a[0]=1
a[1]=2
a[2]=3
a[3]=4
No comments: