C Storing value in an array

Storing value in an array

This example demonstrate of Storing Value in Array as well as Retrieving the stored value.

Example:

//Write a Program Which Stores Value in Given Number of Array and Print it.
#include<stdio.h>
#include<conio.h>
#define N 5

void main()
{
    int num[N],i,j;
    clrscr();
    printf("Enter Any %d Number\n\n",N);
    for(i=0;i<N;i++)
    {
        printf("Enter Value Of Num[%d] = ",i);
        scanf("%d",&num[i]);
    }
    printf("\n");
    for(j=0;j<N;j++)
    {
        printf("Value Of Num[%d] is %d\n",j,num[j]);
    }
    getch();
}

Output:

Command Prompt
Enter Any 5 Number

Enter Value of Num[0] = 5
Enter Value of Num[1] = 7
Enter Value of Num[2] = 10
Enter Value of Num[3] = 14
Enter Value of Num[4] = 19

Value of Num[0] is 5
Value of Num[1] is 7
Value of Num[2] is 10
Value of Num[3] is 14
Value of Num[4] is 19


Share This Page to Download:

Share to Download

Share This Page on:


Ask Question