May 24, 2020

C program to find maximum between three numbers

EX: write a C program to check maximum number between three numbers. C program to print Maximum  between three numbers. How to write a C program to print Maximum  between three numbers.

In privious program we learn how to find maximum between two numbers. In this program we will find maximum between three numbers.

Input from user:

Enter the number 1: 100

Enter the number 2: 500

Enter the number 3: 300

Expected output:

Maximum between three numbers is: 500

So let's get explore it's logic.

Step by step logic of the given program:

1. Accept three numbers from user say no1, no2 and no3.

2. Use if-else-if ladder and relational operators to find this .

3. Check if no1>no2 and no1>no3 if true means no1 is maximum.

4. If this condition is not true then we check no2>no1 and no2>no3 if this condition true then no2 is maximum.

5. Otherwise we will print no3 is maximum.



int main()
int no1,no2,no3;

printf("Enter number 1:\n");

printf("Enter number 2:\n");

printf("Enter number 3:\n");

printf("Maximum number is %d",no1);
else if(no2>no1&&no2>no3)
printf("Maximum number is %d",no2);
printf("Maximum is %d",no3);

return 0;


Above program shows the following output:

Share This:    Facebook Twitter


Post a Comment

If you have any doubts, please discuss here...