#include <iostream>
int main() {
int num1, num2, num3, largest;
std::cout << "Enter three numbers: ";
std::cin >> num1 >> num2 >> num3;
if (num1 >= num2 && num1 >= num3)
largest = num1;
else if (num2 >= num1 && num2 >= num3)
largest = num2;
else
largest = num3;
std::cout << "Largest number among " << num1 << ", " << num2 << ", and " << num3 << " is " << largest;
return 0;
}
Enter three numbers: 14
19
11
Largest number among 14, 19, and 11 is 19
num1
, num2
, num3
, and largest, which are all of type int
. std::cout
and std::cin
objects from the iostream
library. >>
operator is used to input the user's numbers into the variables num1
, num2
, and num3
.largest
variable. std::cout
to output a message that displays the largest number among the three numbers to the console.