samedi 9 janvier 2021

Evaluation of the if condition in c as true or false

int n,i;

scanf("%d",&n);

if(n==0)
printf("a");

else if (!(n>=1))
printf("b");

When I give the input as m, the condition (n==0) is evaluating to be true. When the condition is a valid expression and non-zero, then it's true. When I am replacing n by i and providing the same input, the condition n==0 is getting evaluated as false. Why is this happening?. Why is it evaluating to be true even when there's 0 in n==0 ?

Aucun commentaire:

Enregistrer un commentaire