Write the program to print the Maximum and Minimum value of array.
Using Visual Studio 2015
#include<iostream>
using namespace std;
#include<conio.h>
void main()
{
int
arr[10],i;
for
(i = 0; i < 10; i++)
{
cout<<"Enter the number"<<(i+1)<<"=";
cin>>arr[i];
}
int
maxvalue=arr[0],minvalue=arr[0];
for
(i = 0; i < 10; i++)
{
if
(arr[i] >= maxvalue)
{
maxvalue=arr[i];
}
if
(arr[i] <= minvalue)
{
minvalue=arr[i];
}
}
cout<<"\nMaximum value in the array= "<<maxvalue;
cout<<"\nMinimum value in the array= "<<minvalue;
_getche();
}
==========================================================================
Comments
Post a Comment