Can anyone explain how does this work the output is A3 but how come it print 3
#include <stdio.h>
int main() {
int i;
if(printf("A"))
i=3;
else
i=5;
printf("%d",i);
}
printf() returns the number of characters upon success and negative values on failure.
Therefore, if printf("A") succeeds, it will return 1.
In C, values other than 0 is treated as true, so i=3; is executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With