You can write a program in a programming language like Python to find the greatest of three numbers using nested if statements. Here's a simple Python program to do that:
python
Copy code
# Input three numbers from the user
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))
# Nested if statements to find the greatest number
if num1 >= num2:
if num1 >= num3:
greatest = num1
else:
greatest = num3
else:
if num2 >= num3:
greatest = num2
else:
greatest = num3
# Display the result
print("The greatest number is:", greatest)
In this program:
We take input from the user for three numbers and convert them to floating-point values using float(input(...)).
We use nested if statements to compare the numbers:
The outer if-else statement compares num1 and num2 to determine which one is greater.
Then, based on the result of the outer if-else, we use another nested if-else statement to compare the greater of the first two numbers with num3 to find the greatest number.
Finally, we display the result, which is the greatest of the three numbers.
You can run this program in a Python environment to find the greatest of three numbers.