Search Here

C program to find smallest number using Logical Operators and nested if...else



/* C program to find the Smallest Number using logical AND operator */
int main()
{
    int a,b,c;
    printf("Enter three numbers to find the smallest one: ");
    scanf("%d%d%d",&a,&b,&c);
    if(a<b && a<c)
        printf("\nMin=%d",a);
    else if(b<a && b<c)
        printf("\nMin=%d",b);
    else
        printf("\nMin=%d",c);
    return 0;
}





/* Find the smallest number using logical AND operator */
int main()
{
    int a,b,c;
    printf("Enter three numbers to find the smallest one: ");
    scanf("%d%d%d",&a,&b,&c);
    if(a<b && a<c)
        printf("\nMin=%d",a);
    else if(b<a && b<c)
        printf("\nMin=%d",b);
    else
        printf("\nMin=%d",c);
    return 0;
}


Output


No comments:

Post a Comment