Friday, 3 October 2014

WAP that will take as input a set of integer and find and display the largest and the smallest value with in the input data value



#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a[20],k,x=0,i,p=0;
printf(" How many no. to be entered ? ");
scanf("%d",&k);
printf("\n\tEnter no. ");
for(i=0;i<k;i++)
{
scanf(" %d",&a[i]);
}
for(i=0;i<k;i++)
{
if(a[0]>a[i])
{
a[0]=a[i];
p=a[0];
}
}
for(i=0;i<k;i++)
{
if(a[0]<a[i])
{
a[0]=a[i];
x=a[0];
}
}
printf(" Smallest no. is %d  and Largest no. is  %d",p,x);
getch();
}

No comments:

Post a Comment

Please write your doubts