Can someone explain its ans to me ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone explain its ans to me ?

#include<stdio.h> main() { int i=1024; while(i) { printf("SoloLearn\n"); i>>=1; } }

4th Apr 2020, 5:11 PM
Riya Patel
Riya Patel - avatar
1 Answer
+ 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
4th Apr 2020, 5:44 PM
Jayakrishna 🇮🇳