Saturday, October 31, 2020

C program to find the smallest, middle and greatest number amongst the three given number

 #include <stdio.h>

int main()

{

    int a,b,c;

    printf("Enter a,b,c:");

    scanf("%d %d %d",&a,&b,&c);

    if(a>b)

    {

        if(a<c)

        {

            printf("%d is greatest\n",c);

            printf("%d is middle\n",a);

            printf("%d is smallest\n",b);

        }

        else if(b>c)

        {

            printf("%d is greatest\n",a);

            printf("%d is middle\n",b);

            printf("%d is smallest\n",c);

        }

        else

        {

            printf("%d is greatest\n",b);

            printf("%d is middle\n",c);

            printf("%d is smallest\n",a);

        }

    }

    else if(b<c)

    {

        printf("%d is greatest\n",c);

        printf("%d is middle\n",b);

        printf("%d is smallest\n",a);

    }

    else if(a>c)

    {

        printf("%d is greatest\n",b);

        printf("%d is middle\n",a);

        printf("%d is smallest\n",c);

    }

    else

    {

        printf("%d is greatest\n",c);

        printf("%d is middle\n",b);

        printf("%d is smallest\n",a);

    }

    return 0;

}


No comments:

Post a Comment

How to Fight Overthinking or Negative Thoughts?

How to Combat Overthinking or Negative Thoughts? 1. Don’t Fight Your Thoughts Trying to suppress or control negative thoughts often backfire...