#include<iostream>
using namespace std;
int main()
{
int array[10],max,min,i,j,k;
cout<<"Enter 10 numbers in array : \n";
for(i=0;i<10;i++)
{
cout<<"Enter number "<<i+1<<": ";
cin>>array[i];
}
max=array[0];
min=array[0];
//loop to find maximum No in array
for(j=1;j<10;j++)
{
if(max<array[j])
{
max=array[j];
}
}
//loop to find minimum No in array
for(k=1;k<10;k++)
{
if(min>array[k])
{
min=array[k];
}
}
cout<<"The maximum number in array is "<<max<<endl;
cout<<"The minimum number in array is "<<min<<endl;
return 0;
}
No comments:
Post a Comment