min & max of an array. ... I have written a C++ program that will let the user enter 10 values into an array. The program will display the largest and the smallest values stored in the array.
MAXIMUM AND MINIMUM
#include<iostream>
using namespace std;
int main()
{
int i,n,max=0,min=0;
int a[10];
cout<<"Enter the limit:";
cin>>n;
cout<<"Enter the value one by one:\n";
for(i=0;i<n;i++)
{
cin>>a[i];
}
max=min=a[0];
for(i=0;i<n;i++)
{
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
cout<<"Maximum="<<max;
cout<<"Minimum="<<min;
return 0;
}
OUTPUT:
BY
REGU RAM SV.
Good
ReplyDeletePost a Comment