🔀⚡Beginner
Find Largest Number Among Three
Find maximum among three numbers
This program finds the largest among three numbers using nested if-else statements.
Program Code
largest_three.c
C
1#include <stdio.h>23int main() {4 int a, b, c;5 6 printf("Enter three numbers: ");7 scanf("%d %d %d", &a, &b, &c);8 9 if (a >= b && a >= c) {10 printf("%d is largest\n", a);11 } 12 else if (b >= a && b >= c) {13 printf("%d is largest\n", b);14 } 15 else {16 printf("%d is largest\n", c);17 }18 19 return 0;20}Output
Enter three numbers: 25 67 43
67 is largest
Step-by-Step Execution:
1
Input: 25, 67, 43
a=25, b=67, c=43
2
Check a >= b && a >= c
25 >= 67? No, skip this
3
Check b >= a && b >= c
67 >= 25 AND 67 >= 43? Yes!
4
Output
67 is largest
Related Examples
Want to Learn More?
Explore our comprehensive tutorials for in-depth explanations of C programming concepts.
Browse Tutorials