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

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad