C program to read three numbers and find maximum of the three numbers
Posted by Samath
Last Updated: January 02, 2017

Write a C program to read three numbers and find maximum of the three numbers using if else statement.

Code:

#include<stdio.h>
 
int main() 
{
   int num1, num2, num3;
 
   printf("\nEnter the first number: ");
   scanf("%d", &num1);
   
   printf("\nEnter the second number : ");
   scanf("%d", &num2);
   
   printf("\nEnter the third number : ");
   scanf("%d", &num3);
 
   if ((num1 > num2) && (num1 > num3))
      printf("\nFirst number is the greatest");
 
   if ((num2 > num3) && (num2 > num1))
      printf("\nSecond number is the greatest");
 
   if ((num3 > num1) && (num3 > num2))
      printf("\nThird number is the greatest");
 
   return(0);
}