Q.) Write a program for searching maximum and minimum numbers.
Sol.)
#include<stdio.h>
#include<conio.h>
int main( )
{
int arr[10] ;
int i, num, min, max;
for(i=0; i<10; i++)
{
printf("Enter %d number : ",i+1) ;
scanf("%d",&arr[i]);
}
min=max=arr[0] ;
for(i=0; i<10; i++)
{
if(arr[i]<min)
min=arr[i];
else if(arr[i]>max)
max=arr[i];
}
printf("\n Maximum number is %d",max) ;
printf("\n Minimum number is %d", min) ;
return 0 ;
}
No comments:
Post a Comment