How to write a C Program To Find The Maximum And Minimum Value In An Array in C Programming Language ?
Solution For C Program :
/*C Program To Find The Maximum And Minimum Value In An Array*/
#include<stdio.h>
#include<conio.h>
void main()
{
int k;
int a[5],i,j,max=0,min=0;
printf("Enter how many numbers in array:=");
scanf("%d",&k);
printf("enter the numbers:\n");
for(i=0;i<k;i++)
{
scanf("%d",&a[i]);
}
max=a[0];
min=a[0];
for(i=1;i<k;i++)
{
if(a[i]>max)
{
max=a[i];
}
if(a[i]<min)
{
min=a[i];
}
}
printf("Maximum value of array:=%d\n",max);
printf("Minimum value of array:=%d",min);
getch();
}