C Program - One Dimensional Array Program

Following C program ask to the user to enter the array size, then ask to enter the element of the array to store the elements in the array, then finally display the array element on the screen:

#include<stdio.h>
#include<conio.h>
void main()
{
    clrscr();
    int array[50], num;
    printf("How many element you want to store in the array ? ");
    scanf("%d",&num);
    printf("Enter %d element to store in the array : ",num);
    for(int i=0; i<num; i++)
    {
        scanf("%d",&array[i]);
    }
    printf("The Elements in the Array is : \n");
    for(i=0; i<num; i++)
    {
        printf("%d\t",array[i]);
    }
    getch();


Run: 
 

No comments:

Post a Comment

100 C Programs with Code and Output

Program 1: C Program To Read Two Numbers And Print The Sum Of Given Two Numbers. Program 2: C Program To Read Three Numbers And Prin...