Skip to main content

Problem Statement

Write a C program to find the largest among three numbers using nested if-else statements.

Solution

#include <stdio.h>

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a >= b && a >= c)
        printf("Largest = %d\n", a);
    else if (b >= a && b >= c)
        printf("Largest = %d\n", b);
    else
        printf("Largest = %d\n", c);
    return 0;
}

Input

10 25 18

Output

Largest = 25