I have this source code:
void main() {
int a[10]={9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; int i;
for (i=0; i<10; i=1<<i) a[9-i]=a[i];
for (i=1; i<10; i++) a[0]+=a[i];
printf("%d", a[0]);
}
Since I'm new to C programming, I don't really understand what it does. What does i=1<<i
mean in the for loop?
<<
is the bitwise left shift operator. (Andvoid main()
is wrong; it should beint main(void)
.)i
will take on the values 0, 1, 2, 4, 16. 16 > 10, so that will end the loop.main
is not one of those defined in the standard."