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

4

67

34

78

34

98

27

45

11

Largest number is :98

Smallest number is:1

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials 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 Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz