C Program To Find Maximum And Minimum Value Using Array | C Programming

C Program To Find Maximum And Minimum Value Using Array 

#include<stdio.h> 
int main() 
{ 
 int i,n,max=0,min=0, a[10]; 
 printf("Enter a number:-"); 
 scanf("%d",&n); 
 printf("Enter numbers in array\n"); 
 for(i=0;i<n;i++)
 { 
 scanf("%d",&a[i]); 
 }
 min=a[0]; 
 max=a[0]; 
 for(i=0;i<n;i++)
 { 
 if (a[i]>max) 
 { 
 max=a[i]; 
 } 
 if(a[i]<min)
 { 
 min=a[i]; 
 }
 } 
 printf("The largest number is %d\n",max); 
 printf("The smallest number is %d\n",min); 
 return 0; 
}



OUTPUT

C program to find Maximum and Minimum value using array.

Post a Comment

0 Comments