Search This Blog

Sunday, 17 May 2020

programming C(small value and largest value)

    largest value and smallest value among the three numbers(if and switch content)

#include<stdio.h>
#include<stdlib.h>

int main()
{
    int no1,no2,no3;
    printf("Enter three numbers\n");
    scanf("%d %d %d",&no1,&no2,&no3);

    if(no1<no2 && no1<no3)
    {
            printf("%d is the smallest number\n",no1);
    }
    else if(no2<no3)
    {
        printf("%d is the smallest number\n",no2);
    }
    else
    {
        printf("%d is the smallest number\n",no3);
    }

    if(no1>no2 && no1>no3)
    {
    printf("%d is the largest number",no1);
    }
    else if(no2>no3)
    {
    printf("%d is the largest number",no2);
    }
    else
    {
    printf("%d is the largest number",no3);
    }
    return 0;
}

    

No comments:

Post a Comment

please wait...