Answer to Question #289982 in C++ for ali

Question #289982

Write a program that reads three integers and prints the minimum and maximum.


1
Expert's answer
2022-01-26T09:55:17-0500
#include<iostream>

using namespace std;

int main()
{
	int arr[3];
	cout<<"Please, enter three integers: ";
	for(int i=0;i<3;i++)
		cin>>arr[i];
	int mn=arr[0];
	for(int i=0;i<3;i++)
	{
		if(mn>arr[i])
			mn=arr[i];
	}
	int mx=arr[0];
	for(int i=0;i<3;i++)
	{
		if(mx<arr[i])
			mx=arr[i];
	}
	
	cout<<"Minimum is "<<mn;
	cout<<"\nMaximum is "<<mx;
}

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