Assignment in If-Else | Sololearn: Learn to code for FREE!

+2

Assignment in If-Else

Please explain how this works #include <stdio.h> int main() { char ch; if(ch= printf("c: ")) printf("It Matters"); else printf("It Doesn't Matter"); return 0; }

10/9/2019 3:23:15 AM

Tom

1 Answer

New Answer

+4

printf returns number of chars printed on the screen. Here it will return 2 (for "c:")which is assigned to ch. "If" checks if the value is true or false. 2 is non zero value so it evaluates to true, so printf condition is true and it prints "it Matters"