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:
Previous Next
#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:
Previous Next
No comments:
Post a Comment