Write a program to Read and Display elements of One Dimensional Array
#include<stdio.h>
void main()
{
int
n, i, a[100];
printf("\nEnter the number
of elements:");
scanf("%d", &n);
printf("\nEnter the
elements:");
for(i=0; i<n; i++)
{
scanf("%d",
&a[i]);
}
printf("\nArray elements
are: ");
for(i=0; i<n; i++)
{
printf("%d
", a[i]);
}
}
Output:
Enter the number of elements: 5
Enter the elements: 1 2 3 4 5
Array elements are: 1 2 3 4 5
Also Check:
Also Check:
- Program to Insert an Element to an Array at Valid Position
- Program to Delete an Element from an Array at Valid Position
No comments:
Post a Comment