#include<stdio.h>
void main()
{
int n,i=1,num,big,small;
clrscr();
printf("Among how many numbers : ");
scanf("%d",&n);
if(n<0)
printf("invalid input");
else
{
printf("Enter number %d :",i);
scanf("%d",&num);
big=small=num;
for(;i<n;++i)
{
printf("Enter number %d :",i+1);
scanf("%d",&num);
if(big<num)
big=num;
if(small>num)
small=num;
}
printf("largest number is : %d",big);
printf("\nSmallest number is : %d",small);
}
getch();
}
void main()
{
int n,i=1,num,big,small;
clrscr();
printf("Among how many numbers : ");
scanf("%d",&n);
if(n<0)
printf("invalid input");
else
{
printf("Enter number %d :",i);
scanf("%d",&num);
big=small=num;
for(;i<n;++i)
{
printf("Enter number %d :",i+1);
scanf("%d",&num);
if(big<num)
big=num;
if(small>num)
small=num;
}
printf("largest number is : %d",big);
printf("\nSmallest number is : %d",small);
}
getch();
}
No comments:
Post a Comment