C program to find greatest number from three numbers

Problem statement

Write a program to take three numbers as input from users and find a greatest numbers from three.
For example: Let three numbers are 34965, 34750, 34068
Then the greatest number is 34965.

Program to find greatest number

Output

Explanation

In above program first we take three numbers as input from users.
We are checking greatest number in three if statement.
To know the working of if-else statement check our post on if- else.

In first if we check number1 is greater than number2 and number3. If number1 is greater, then first if statement will execute and print ‘number1 is greater number’.
Otherwise corresponding else statement will execute.

In second else-if statement, we are checking number2 is greater than number1 and number3.
If condition is true then it print number2 is greater. Else the third else-if statement will execute.
In this way we will get greatest number from three numbers.

Note: If you dont know what is && and how it work then refer Operators.

Help others by sharing the content!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.