Programming Examples
Cpp program to input 10 integer numbers and find the minimum and maximum
Write a cpp program to input 10 integer numbers and find the minimum and maximum
Solution
#include<iostream>
using namespace std;
int main(){
int ar[10],a,max,min;
cout<<"Enter 10 integer numbers"<<endl;
for(a=0;a<10;a++)
{
cin>>ar[a];
}
max=min=ar[0];
for(a=0;a<10;a++)
{
if(ar[a]>max)
{
max=ar[a];
}
if(ar[a]<min)
{
min=ar[a];
}
}
cout<<"Largest number is :"<<max<<endl;
cout<<"Smallest number is:"<<min;
return 0;
}
Output
Enter 10 integer numbers
1Â
4
67
34
78
34
98
27
45
11
Largest number is :98
Smallest number is:1