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

2019 wasn’t just a year—it was a whole era.From lectures to late nights, chaos to clarity… every frame built a story I’m still living ✨

Video Link The video contains snaps from 2019 throwback ones when i was doing my masters studies from university of surrey, guildford, londo...