WELCOME

Welcome to KoDes4U

Pages

Thursday, March 3, 2011

accepting numbers and storing it on an array

/*Write a C program to accept n numbers from user and store these numbers in
an array. Find the min and max numbers....................................
Coded by KoDes4U.blogspot.com*/






#include<stdio.h>
#include<conio.h>
void main()
{
int num[5],i,min,max;
clrscr();
printf("Accepting of 5 numbers from user:\n");
for(i=0;i<5;i++)
{
printf("Enter the number num[%d]:",i);
scanf("%d",&num[i]);
}
printf("\nDisplay of numbers that was stored in the array num[]\n");
for(i=0;i<5;i++)
{
printf("%d  ",num[i]);
}
max=num[0];
for(i=0;i<5;i++)
{
if(max<num[i])
max=num[i];
}
printf("\nMaximum number is %d",max);
min=num[0];
for(i=0;i<5;i++)
{
if(min>num[i])
min=num[i];
}
printf("\nMinimum number is %d",min);
getch();
}

No comments:

Post a Comment