Answer to Question #240307 in C++ for adil

Question #240307

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


1
Expert's answer
2021-09-21T13:56:51-0400
#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;
		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS