Saturday 23 July 2016

Program to Read and Display elements of One dimensional array

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

No comments:

Post a Comment