๐Ÿ”ŸC Program to Find the Largest of Three Numbers (With Program and Explanation)

 

๐Ÿ”ข C Program to Find the Largest of Three Numbers

๐Ÿ“Œ Problem Statement

Write a C program that takes three numbers as input and determines which one is the largest.


๐Ÿง  Logic / Explanation

  1. Read three numbers from the user: a, b, and c.

  2. Compare:

    • If a is greater than both b and c, then a is the largest.

    • Else if b is greater than both a and c, then b is the largest.

    • Otherwise, c is the largest.

  3. Print the largest number.

๐Ÿ‘‰ We use if–else if–else statements to make comparisons.


๐Ÿ’ป C Program Code

#include <stdio.h> int main() { int a, b, c; // Input three numbers printf("Enter three numbers: "); scanf("%d %d %d", &a, &b, &c); // Compare the numbers if (a >= b && a >= c) { printf("Largest number is: %d", a); } else if (b >= a && b >= c) { printf("Largest number is: %d", b); } else { printf("Largest number is: %d", c); } return 0; }

๐Ÿงพ Output Examples

▶ Example 1

Input:

Enter three numbers: 10 25 15

Output:

Largest number is: 25

✅ Key Points

Uses simple if-else conditions
Works for equal numbers also
Beginner-friendly logic
Suitable for exams & interviews


✅Conclusion

In this program, we learned how to Largest of three numbers.


๐Ÿ“˜ C Programming Series – What’s Next?

๐Ÿ‘‰ In the next post of this series, we will learn how  to Count Digits in a Number with complete explanation and output examples. Stay tuned! ๐Ÿš€


Comments

Popular posts from this blog

⓮C Program to calculate Simple Interest (With Program and Explanation)

⑫ C Program to Swap Two Numbers Without Using a Temporary Variable (With Program and Explanation)

9️⃣C Program to Find LCM of Two Numbers (With Program and Explanation)