Write a C++ program that prompts the user to input four integer values and find the lowest value of the four values.
#include <bits/stdc++.h>
using namespace std;
void determine_greatest(int x, int y, int z, int d)
{
if (x > y) {
if (x > z) {
if (x > d) {
cout << "x is greatest";
}
else {
cout << "d is greatest";
}
}
}
else if (y > z) {
if (y > d) {
cout << "y is greatest";
}
else {
cout << "d is greatest";
}
}
else if (z > d) {
cout << "z is greatest";
}
else {
cout << "d is greatest";
}
}
int main()
{
int x , y , z , d;
cout<<"\nEnter the first integer: ";
cin>>x;
cout<<"\nEnter the second integer: ";
cin>>y;
cout<<"\nEnter the third integer: ";
cin>>z;
cout<<"\nEnter the fourth integer: ";
cin>>d;
cout << "x=" << x << " y=" << y << " z=" << z << " d=" << d;
cout << "\n";
determine_greatest(x, y, z, d);
x = 35, y = 50, z = 99, d = 2;
cout << "\n";
cout << "x=" << x << " y=" << y << " z=" << z << " d=" << d;
cout << "\n";
determine_greatest(x, y, z, d);
return 0;
}
Comments
Leave a comment