C Program to Calculate Maximum of three numbers

maximum-of-three-numbers-program-in-c-language

Program Description: 

Program to calculate the maximum of three numbers in C programming language.

The program will accept the three numbers from the user and then calculate the maximum of them. and display the result on the console.

We are going to use the decision-making statement i.e if else statement with the Relations operators( >, <, etc) to calculate the maximum.

Prerequisites:

It is recommended to have a basic knowledge of if-else statements and Relational operators. please go through the following articles

Maximum of three numbers Program Explanation:

  • We start the program by asking the user for input and once we got the three numbers and we store them in variables a, b, and c.
  • Then we will check if the a is maximum by comparing a with b and c. i.e (a>b) && (a>c)
    • We have AND&& operation, means both a > b and a > c need to be true
    • If the above condition is true then the a is maximum number. Save the a value in max variable.
  • If the above condition is false, then a is not maximum, So we need to check the variable b and c
    • check if the variable b is maximum by comparing the b and c.
    • if b is larger than c ( i.e b > c). Then b is the maximum of three number. save the value of b in max variable
  • If above two conditions are false, Then the variable c is bigger than both variables a and b.
    • Store the value of the c in the max variable
  • Finally, We printed the maximum number on to the console using the printf function.

Maximum of three numbers program in C:

Program Output:

maximum-of-three-numbers-program-output-in-c-language
Output

Related Programs:

Venkatesh

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

2 Responses

  1. codeforhunger says:

    Nice blog, keep sharing all type of program which is useful and very informative for student, if you want to more information about c language then visit my profile….

  1. […] C Program to find the Biggest number from Three Numbers (Maximum) […]

Leave a Reply