0

what is output of code and how?

int c=0 if(c) printf("%d",c=0); else printf("%d",c=1); printf("%d\n",c);

12th Dec 2021, 6:50 AM
learn coder avi
learn coder avi - avatar
2 Respuestas
+ 2
Well it will produce error correct code is \/ #include <stdio.h> int main() { int c=0; if(c){ printf("%d",c=0); } else{ printf("%d",c=1); printf("%d\n",c); } return 0; } you are suggested to go through the course https://www.sololearn.com/Course/C/?ref=app
12th Dec 2021, 6:56 AM
Ayush Kumar
Ayush Kumar - avatar
+ 1
After correcting the missing #include and missing ; the output would be: 11 Here is why. See comments. #include <stdio.h> int main() { int c=0; // initial value is 0 if(c)      // 0 is false. Skip to else. printf("%d",c=0); else printf("%d",c=1); // assign 1 to c, print it printf("%d\n",c); // print c again, 1 return 0; }
12th Dec 2021, 8:06 AM
Brian
Brian - avatar