0

Please explain the codes snippet how the code working and returning 1 10?

#include <stdio.h> int main() { int x=1,i,y=2; for(i=0;i<10;i++){ x<<1; y=x+i; } printf("%d,%d",x,y); return 0; }

25th Feb 2020, 5:37 PM
Arshia
Arshia - avatar
1 ответ
+ 3
Your not storing result of x<<1. So that does not effect x value. For last iteration i=9, y=9+1=10 So x remains 1, y=10. So may be, you are missing like this.. x=x<<1, will affect the result..
25th Feb 2020, 5:47 PM
Jayakrishna 🇮🇳