You are given n number of different numbers. Write the pseudo code to identify the number
whose value is in between the other numbers.
Example:
Lets suppose input numbers are:2,13,5
Output:5
#include<iostream>
using namespace std;
int main(){
int arr[3] ={2,13,5} ;
int max = arr[0];
for(int i=0; i<3; i++){
if(arr[i]>max){
max =arr[i];
}
}
int min = arr[0];
for(int i=0; i<3; i++){
if(arr[i]<min){
min =arr[i];
}
}
cout<<"Output:"<<endl;
for(int i=0; i<3; i++){
if(arr[i] != max && arr[i] != min){
cout<<arr[i]<<endl;
}
}
}
Comments
Leave a comment