Largest of Three Numbers

less than 1 minute read

The code has been modified slightly and now uploaded to the site.

Question

<— Return Home

65.cpp

#include <iostream>
using namespace std;

void displayLargest(int num1, int num2, int num3){
    int value = 0;
        if (num1 > value){
            value = num1;
        }
        if (num2 > value){
            value = num2;
        }
        if (num3 > value){
            value = num3;
        }
        // for (int j = i + 1; j < 3; j++){
        //     if (num1 > num2){

        //     }
        // }
    std::cout << "\n";
    std::cout << value << "\n";
}

int main(){
    double num1;
    double num2;
    double num3;

    std::cout << "Enter three numbers to display the largest of them: \n";
    std::cin >> num1;
    std::cin >> num2;
    std::cin >> num3;

    displayLargest(num1, num2, num3);
}

<— Return Home