Write a C program to Find the Largest Number Among Three Numbers.

Function Main
    Declare Real num1
    Declare Real num2
    Declare Real num3
    Output "Enter three numbers: "
    Input num1
    Input num2
    Input num3
    If num1>=num2
        If num1>=num3
            Output "The larggest numner is: " &num1
        Else
            Output "The larggest numner is: " &num3
        End
    Else
        If num2>=num3
            Output "The larggest numner is: " &num2
        Else
            Output "The larggest numner is: " &num3
        End
    End
End

#include <stdio.h>
#include <stdlib.h>

int main()
{
    double num1;
    double num2;
    double num3;

    printf("Enter three numbers:\n");
    scanf("%lf %lf %lf", &num1, &num2, &num3);

    if (num1 >= num2) {
        if (num1 >= num3) {
            printf("The largest number is: %.2lf\n", num1);
        } else {
            printf("The largest number is: %.2lf\n", num3);
        }
    } else {
        if (num2 >= num3) {
            printf("The largest number is: %.2lf\n", num2);
        } else {
            printf("The largest number is: %.2lf\n", num3);
        }
    }

    return 0;
}
Enter three numbers:
10.0
20.0
30.0
The largest number is: 30.00

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.