Given three numbers A, B and C; The task is to find the largest number among the three.

**Examples**:

Input: A = 2, B = 8, C = 1Output: Largest number = 8Input: A = 231, B = 4751, C = 75821Output: Largest number = 75821

In the below programs, to find the largest of the three number, , , and ‘s are used.

**Algorithm to find the largest of three numbers:**

1.Start2.Read the three numbers to be compared, as A, B and C.3.Check if A is greater than B.3.1If true, then check if A is greater than C.3.1.1If true, print 'A' as the greatest number.3.1.2If false, print 'C' as the greatest number.3.2If false, then check if B is greater than C.3.1.1If true, print 'B' as the greatest number.3.1.2If false, print 'C' as the greatest number.4.End

**FlowChart to find the largest of three numbers:**

Below is the C program to find the largest among the three numbers:

**Example 1:** Using only if statements to find the largest number.

`#include <stdio.h> ` ` ` `int` `main() ` `{ ` ` ` `int` `A, B, C; ` ` ` ` ` `printf` `(` `"Enter the numbers A, B and C: "` `); ` ` ` `scanf` `(` `"%d %d %d"` `, &A, &B, &C); ` ` ` ` ` `if` `(A >= B && A >= C) ` ` ` `printf` `(` `"%d is the largest number."` `, A); ` ` ` ` ` `if` `(B >= A && B >= C) ` ` ` `printf` `(` `"%d is the largest number."` `, B); ` ` ` ` ` `if` `(C >= A && C >= B) ` ` ` `printf` `(` `"%d is the largest number."` `, C); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

**Output:**

Enter the numbers A, B and C: 2 8 1 8 is the largest number.

**Example 2:** Using if-else statement to find the largest number.

`#include <stdio.h> ` `int` `main() ` `{ ` ` ` `int` `A, B, C; ` ` ` ` ` `printf` `(` `"Enter three numbers: "` `); ` ` ` `scanf` `(` `"%d %d %d"` `, &A, &B, &C); ` ` ` ` ` `if` `(A >= B) { ` ` ` `if` `(A >= C) ` ` ` `printf` `(` `"%d is the largest number."` `, A); ` ` ` `else` ` ` `printf` `(` `"%d is the largest number."` `, C); ` ` ` `} ` ` ` `else` `{ ` ` ` `if` `(B >= C) ` ` ` `printf` `(` `"%d is the largest number."` `, B); ` ` ` `else` ` ` `printf` `(` `"%d is the largest number."` `, C); ` ` ` `} ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

**Output:**

Enter the numbers A, B and C: 2 8 1 8 is the largest number.

**Example 3:** Using nested if-else statements to find the largest number.

`#include <stdio.h> ` `int` `main() ` `{ ` ` ` `int` `A, B, C; ` ` ` ` ` `printf` `(` `"Enter three numbers: "` `); ` ` ` `scanf` `(` `"%d %d %d"` `, &A, &B, &C); ` ` ` ` ` `if` `(A >= B && A >= C) ` ` ` `printf` `(` `"%d is the largest number."` `, A); ` ` ` ` ` `else` `if` `(B >= A && B >= C) ` ` ` `printf` `(` `"%d is the largest number."` `, B); ` ` ` ` ` `else` ` ` `printf` `(` `"%d is the largest number."` `, C); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

**Output:**

Enter the numbers A, B and C: 2 8 1 8 is the largest number.

**Example 4:** Using Ternary operator to find the largest number.

`#include <stdio.h> ` `int` `main() ` `{ ` ` ` `int` `A, B, C, largest; ` ` ` ` ` `printf` `(` `"Enter three numbers: "` `); ` ` ` `scanf` `(` `"%d %d %d"` `, &A, &B, &C); ` ` ` ` ` `largest = A > B ? (A > C ? A : C) : (B > C ? B : C); ` ` ` ` ` `printf` `(` `"%d is the largest number."` `, largest); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

**Output:**

Enter the numbers A, B and C: 2 8 1 8 is the largest number.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Program to find the smallest element among three elements
- Program to find the common ratio of three numbers
- Find the largest and second largest value in a Linked List
- Missing vertex among N axis-parallel rectangles
- Swap three numbers in cycle
- Count of ways to write N as a sum of three numbers
- Product of Complex Numbers using three Multiplication Operation
- C Program for Find largest prime factor of a number
- Program to Find the Largest Number using Ternary Operator
- Python program maximum of three
- Check if a number can be written as sum of three consecutive integers
- Program to find largest element in an array
- C Program to find largest element in an array
- Program to find largest element in an array using Dynamic Memory Allocation
- Largest Even and Odd N-digit numbers in Hexadecimal Number System
- Largest of two distinct numbers without using any conditional statements or operators
- Largest and Smallest N-digit Hexadecimal Numbers
- C / C++ Program for Largest Sum Contiguous Subarray
- Find largest sum of digits in all divisors of n
- Find the largest N digit multiple of N

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.