#include<stdio.h>
int main(){
int array[100];
int size,i;
int max,min;
// taking the array size
printf("Enter Size : \n");
scanf("%d",&size);
// reading elements into array
printf("Enter %d elements : \n",size);
for(i=0;i<size;i++)
scanf("%d",&array[i]);
//assuming 0th element as small and large
max=min=array[0];
// iterating through array to find small/large number
for(i=1;i<size;i++)
{
if(array[i]>max)
max=array[i];
if(array[i]<min)
min=array[i];
}
printf("Largest Number %d \n",max);
printf("Smallest Number %d \n",min);
}
Comments
Post a Comment