Find the Largest Number in C++

This program finds the largest of three numbers.

#include <iostream>

int main() {

    int num1, num2, num3;

    std::cout << "Enter three numbers: ";

    std::cin >> num1 >> num2 >> num3;

    int largest = num1;

    if (num2 > largest) {

        largest = num2;

    }

    if (num3 > largest) {

        largest = num3;

    }

    std::cout << "The largest number is " << largest << std::endl;

    return 0;

}


No comments:

Post a Comment

MS Excel Logical Functions

Logical functions in Excel are powerful tools that help you make decisions based on conditions. Whether you're comparing values or testi...

Post Count

Loading...