-->

hseb20:program to get maximum and minimum value

//program to get maximum and minimum value
#include<stdio.h>
#include<conio.h>
void main()
{
int a[200],size,i,max,min;
printf("enter value of size to be stored in array\n");
scanf("%d",&size);
for(i=0;i<size;i++)
{
   printf("enter value for location=%d",i);
   scanf("%d",&a[i]);
}
max=a[2];
min=a[1];
for(i=0;i<size;i++)
{
   if(max<a[i])
     {
       max=a[i];
     }
 else if (min>a[i])
   {
     min=a[i];
    }
}
printf("the maximum value=%d\n",max);
printf("the minimum value=%d\n",min);
getch();
}


No comments:

Post a Comment