Program to read and display array elements

#include<stdio.h>


void main()

{

    int a[50];

    int n,i;


    do

    {

        printf("\nEnter no. of elements in between 1 and 50: ");

        scanf("%d",&n);

    }while(n<1 || n>50);


    printf("\nEnter the elements: ");

    for(i=0;i<n;i++)

        scanf("%d",&a[i]);


    printf("\nElements are: ");

    for(i=0;i<n;i++)

        printf("%d ",a[i]);

}

Comments

Popular posts from this blog

Single Program Using All Automatic String Functions

C program for subtraction of two matrices (2D Arrays)

C program for Multiplication of Two matrices