Dark mode logo
Last Updated:
Find the largest among three numbers in c

C Program to find the largest among three numbers

Algorithm

Input: Input three numbers
output: Finds and displays the largest among the three input numbers

  1. Start
  2. Input three numbers say a, b, c
  3. if a>b and b>c
    3.1 Print 'a' is greater
  4. else if
    4.1 b>a and b>c
    4.2 Print 'b' is greater
  5. else
    5.1 Print 'c' is greater
  6. Stop

C Program

 

#include <stdio.h>
int main( )
{
   int a, b, c;
   printf("Enter first number: ");
   scanf("%d", &a);
   printf("Enter second number: ");
   scanf("%d", &b);
   printf("Enter third number: ");
   scanf("%d", &c);
   if (a > b && a > c) {
        printf("%d is the largest among %d, %d and %d", a, a, b, c);
    }
   else if (b > c && b > a) {
        printf("%d is the largest among %d, %d and %d", b, a, b, c);
    }
    else {
       printf("%d is the largest among %d, %d and %d", c, a, b, c);
   }
    return 0;
}
 
Note: This Program was created using visual studio code. The Program file can be downloaded by clicking here

Comments