Easy Tutorial
❮ C Function Isupper C Function Rename ❯

C Language Example - Determine the Largest of Three Numbers

C Language Examples

We input three numbers through the screen and find the largest one.

Example

#include <stdio.h>

int main()
{
    double n1, n2, n3;

    printf("Please enter three numbers, separated by spaces: ");
    scanf("%lf %lf %lf", &n1, &n2, &n3);

    if( n1>=n2 && n1>=n3 )
        printf("%.2f is the largest number.", n1);

    if( n2>=n1 && n2>=n3 )
        printf("%.2f is the largest number.", n2);

    if( n3>=n1 && n3>=n2 )
        printf("%.2f is the largest number.", n3);

    return 0;
}

Running Result:

Please enter three numbers, separated by spaces: 1 2 3
3.00 is the largest number.

C Language Examples

❮ C Function Isupper C Function Rename ❯