Explanation: This Program will help you to find the largest three numbers. The stdio.h library is first included so that we may utilize input/output routines.
To save the numbers that the user enters, we declare three integer variables, a, b, and c, inside of main().
We use scanf() to read the three integers that the user is prompted to enter.
At first, we presume that an is the greatest number.
Next, we determine whether b exceeds largest. Should it be, we adjust largest to equal b.
This check is done again for c.
We print the greatest number last.

#include <stdio.h>

int main() {
    int a, b, c;
    printf("Enter three numbers: ");
    scanf("%d %d %d", &a, &b, &c);

    int largest = a; // Start by assuming 'a' is the largest.

    if (b > largest) {
        largest = b; // If 'b' is greater than 'largest', update it.
    }
    if (c > largest) {
        largest = c; // If 'c' is greater than 'largest', update it.
    }

    printf("Largest number is: %d\n", largest); // Output the largest number.
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Verified by MonsterInsights