Jan 25, 2022

Maximum of 3 Numbers in C Language

Finding Maximum...

 #include <stdio.h>
int main()
{
    int a, b, c;
    printf("Enter 1st Number : ");
    scanf("%d", &a);
    printf("Enter 2nd Number : ");
    scanf("%d", &b);
    printf("Enter 3rd Number : ");
    scanf("%d", &c);

    // checking the greatest number out of 3 numbers
    //if first number is greater
    if ((a > b) && (a > c))
    {
        printf("%d is the greatest number.", a);
        return 0;
    }

    //if second number is greater
    if ((a < b) && (c < b))
    {
        printf("%d is the greatest number.", b);
        return 0;
    }

    //if third number is greater
    printf("%d is the greatest number.", c);

    return 0;
}

No comments:

Post a Comment

Comparing two files in C language.

Operations on More than one File.    # include < stdio.h > # include < stdlib.h > # include < string.h > int main ( int ...