mardi 14 juillet 2020

Given a 3 digit number by user, find and print it's minimum digit

I have tried a C program which takes a 3-digit integer from user, then find and print it's minimum digit.

#include <stdio.h>
int main()
{
    int a,b,c;
    printf("Enter a 3-digit integer : ");
    scanf("%d%d%d",&a,&b,&c);
    if(a<b){
        if(a<c){
            printf("%d is the minimum digit\n",a);
        }
        else printf("%d is the minimum digit\n",c);
    }
    else {
        if (b<c){
            printf("%d is the minimum digit\n",b);
        }
    }

    return 0;
}

But this is not the right way, as everytime i am being needed to press enter while giving the 3 digit input.

Aucun commentaire:

Enregistrer un commentaire