C
curiousEngine
Write a program that allows you to input 3 integer values A, B and C
and output the largest of the 3 values.
//TO DO RIGOUROUS TESTING
#include<iostream>
using namespace std;
void main(){
int A(0), B(0), C(0);
int max(0), min(0);
cout<<"Enter 3 integers:";
cin >> A >> B >> C;
if (A > B){
if (A > C)
max = A;
} else {
if (B > C)
max = B;
else if (C > A)
max = C;
}
if (A < B){
if (A < C)
min = A;
} else {
if (B < C)
min = C;
else if (C < A)
min = C;
}
cout <<"Max integer: "<<max<<endl;
cout <<"Min integer: "<<min<<endl;
}
and output the largest of the 3 values.
//TO DO RIGOUROUS TESTING
#include<iostream>
using namespace std;
void main(){
int A(0), B(0), C(0);
int max(0), min(0);
cout<<"Enter 3 integers:";
cin >> A >> B >> C;
if (A > B){
if (A > C)
max = A;
} else {
if (B > C)
max = B;
else if (C > A)
max = C;
}
if (A < B){
if (A < C)
min = A;
} else {
if (B < C)
min = C;
else if (C < A)
min = C;
}
cout <<"Max integer: "<<max<<endl;
cout <<"Min integer: "<<min<<endl;
}