← Back to Analisis Kode
Prev

Question 3 — Nested If

Analisis Kode · 20 points · Answer key: 50

Next

Question

#include <iostream>
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a >= b) {
        if (a >= c) {
            cout << a << endl;
        } else {
            if (c >= d) {
                cout << c << endl;
            } else {
                cout << d << endl;
            }
        }
    } else {
        if (b >= c) {
            cout << b << endl;
        } else {
            if (c >= d) {
                cout << c << endl;
            } else {
                cout << d << endl;
            }
        }
    }
    return 0;
}

Input: 30 20 40 50

Jawab: …………………………………………………… {tuliskan output program}

Answers (7 members)

MemberAnswer
Yazid50
Habibie50
Kian50
Algazel50
Athar50
Athmar50
Priscillad