int x=1,m=0; for(;m<10;++m) x=x+x; System.out.print(x); | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

int x=1,m=0; for(;m<10;++m) x=x+x; System.out.print(x);

Explain

29th Jun 2020, 2:03 PM
Subhash Vangari
Subhash Vangari - avatar
2 Answers
+ 1
You can see what's going on in the loop by adding some print works to see how <x> changes with each loop iteration. int x = 1, m = 0; for (; m < 10; ++m) { System.out.printf("In loop x = %d\n", x); x = x + x; } System.out.printf("Finally ... x is %d", x); For next time, put snippet in thread Description, and ask for explanation in thread question title. Here's some tips on posting a question 👇 https://www.sololearn.com/Discuss/333866/?ref=app
29th Jun 2020, 2:16 PM
Ipang
+ 1
it's a loop, explained enough on course too, you can learn here https://www.sololearn.com/learn/Java/2147/
29th Jun 2020, 2:16 PM
Sudarshan Rai
Sudarshan Rai - avatar