Answer to Question #278508 in C++ for Neneng

Question #278508

Write a C++ program that prompts the user to input four integer values and find the lowest value of the four values.


1
Expert's answer
2021-12-11T05:52:17-0500
#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;  
}  

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