C Program to find greatest of three numbers

C Program to find greatest of three numbers


 #include<stdio.h>
 int num1, num2, num3;
    printf("Enter the values of num1, num2 and num3:\n");

    scanf("%d %d %d", &num1, &num2, &num3);



    printf("num1 = %d\tnum2 = %d\tnum3 = %d\n", num1, num2, num3);

    if (num1 > num2)

    {

        if (num1 > num3)

        {

            printf("num1 is the greatest among three: ");

        }

        else

        {

            printf("num3 is the greatest among three: ");

        }

    }



    else if (num2 > num3)

        printf("num2 is the greatest among three \n");

    else

        printf("num3 is the greatest among three \n");

 }
               

Output:



 Enter the values of num1, num2 and num3:
 4
 6
 8
 num1 = 4        num2 = 6        num3 = 8
 num3 is the greatest among three



 --------------------------------