0
Can someone explain its ans to me ?
#include<stdio.h> main() { int i=1024; while(i) { printf("SoloLearn\n"); i>>=1; } }
1 Resposta
+ 1
>> is right shift operator..
i>>=1
Means i=i>>1 shifting right bits by 1 position
1024 equalent bit expression is
0111 1111 1111
Shifting right one time is
0011 1111 1111 is equal to 512 next
0001 1111 1111 is equal to 256..
0000 1111 1111
....
....
.... repeated upto
0000 0000 0000
It repeats upto i equal to 0
Then stops loop...
Add printing i value in loop, you can see how I value changing
By printf("%d ", i);
Read this for more information..
https://www.sololearn.com/learn/4086/?ref=app