#include<stdio.h>
void main()
{
int a[50],i,n,large,small;
printf("Enter the size of array");
scanf("%d",&n);
printf("Enter the elements into array to find largest and smallest number");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
large=small=a[0];
for(i=1;i<n;i++)
{
if(a[i]<small)
small=a[i];
}
printf(" The largest number is %d",large);
printf("The smallest number is %d",small);
}
OUTPUT
Enter the size of array 10
Enter the elements into array to find largest and smallest number 12 3 67 90 9 56 34 6 8 12
The largest number is 90
The smallest number is 3
void main()
{
int a[50],i,n,large,small;
printf("Enter the size of array");
scanf("%d",&n);
printf("Enter the elements into array to find largest and smallest number");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
large=small=a[0];
for(i=1;i<n;i++)
{
if(a[i]<small)
small=a[i];
}
printf(" The largest number is %d",large);
printf("The smallest number is %d",small);
}
OUTPUT
Enter the size of array 10
Enter the elements into array to find largest and smallest number 12 3 67 90 9 56 34 6 8 12
The largest number is 90
The smallest number is 3
No comments:
Post a Comment