mardi 16 juillet 2019

C - Non Sensible result of if-else statements

I changed the conditions in several ways, But always the second condition is true by compiler

int signf(int a);

int main(void)

{

printf("Enter A Number :\n");

int i = scanf("%i", &i);    

signf(i);

return 0;

}

int signf(int a)

{

if(a<0)
{
printf("Your Number is Negative\n");
}
else if((a>=0)&&(a<10))
{
printf("Your Number has One Digit\n");
}
else if((a>=10)&&(a<100))
{
printf("Your Number has Two Digits\n");
}
else if((a>=100)&&(a<1000))
{
printf("Your Number has Three Digits\n");
}
else
{
printf("Your Number is Huge!\n");
}
printf("This is End!\n");
return 0;
}

It always shows up : Your Number has One Digit , The condition is always true whether I enter 8 or 56 or 849 What's wrong with this code ? I expected work fine , But doesn't .

Aucun commentaire:

Enregistrer un commentaire