Program to find the Maximum and Minimum value in an array
#include <iostream>
#include <conio.h>
int main ()
{
int min,max;
int a[5];
cout<<"Enter any 5
numbers:";
for(int i=0;i<=4;i++)
{
cout<<endl<<"Enter
value: ";
cin<<a[i];
}
min=a[0];
max=a[0];
for(int i=1;i<<=4;i++)
{
if(min>a[i])
{
min=a[i];
}
else if(max<a[i])
{
max = a[i];
}
}
cout<<"Maximum
number is: "<<max<<endl;
cout<<"Minimum
number is: "<<min<<endl;
getch();
return 0;
}
No comments :
Post a Comment