+ 1

How many times will “Hello!” be printed in the program ?

#include <stdio.h> int main() {int I = 1024; for (; I; I >>= 1) printf ("Hello!"); return 0;}?

18th Aug 2019, 5:01 AM
Sowmiya V
Sowmiya V - avatar
2 Respostas
+ 4
The string Hello! will be printed 11 times. Based on the code provided, the code will execute while the variable I is a non-zero positive integer. The for loop updates the value of the variable I with a new value that is the right shift value of I by 1 position. Decimal: 1024>512>256>128>64>32>16>8>4>2>1 Binary: 10,000,000,000>1,000,000,000>100,000,000>10,000,000>1,000,000>100,000>10,000>1,000>100>10>1>0(Stopping condition). Thus running the for loop for 11 times. https://code.sololearn.com/c3QOu5sFcEXa/?ref=app
18th Aug 2019, 5:06 AM
Sowmiya V
Sowmiya V - avatar
0
please you can post this on your feed, this is not allowed in the Q&A https://www.sololearn.com/discuss/1316935/?ref=app
18th Aug 2019, 7:19 AM
✳AsterisK✳
✳AsterisK✳ - avatar