+ 1
Can anyone explain this code
#include <stdio.h> extern int x; int main() { do{ do{ printf("%o", x); } while(!-2); } while(0); return 0; } int x =8;
9 Respuestas
+ 1
%o is for octal number.
1000 -> this is 8 in binary
For octal you group three elements from LSB but 1 will be left out alone. So to get 3 bit combination you add two 0's before 1.
001000 -> now if you group 3 bits from right you get 0 and three bits on left will give you 1.
So your output is 10.
Also if you did not understand the while loop then both are false since -2 will give true but the ! operator results in false.
+ 1
AnonymousGuy yeah for confusing people thanks for help 👍
+ 1
External is a storage class like auto ,static I think it is global
0
Thanks @all
0
AnonymousGuy I'm preparing for Gate and these all questions are in question bank of gate which in referring
0
Preity Okay..Then I guess these loops are just for confusing people😅