I have seen many problems like, here I'm giving one example. Always I wonder why is even this 'if' is given with only one variable without any relation to the other variable to check with.
int c = 0;
if (c)
printf("%d",c=0);
else
printf("%d",c=1);
print("%d\n",c);
Once I have seen a while condition as while(~c) for the loop to run. I have run this code and got 11 as the answer.
output: 11
but I don't know how will the if checks the condition with only one operand i.e., without any operators. I expected the output as 00 but the actual output was 11.
Here I'm expecting it would be as boolean but the c here is int.
Sorry for my terrible editing, this was my first time posting a code snippet.
Aucun commentaire:
Enregistrer un commentaire