Easy Java

Computer Science Level pending

In Java, you are given the code: int random = 1; for(int i=0; i<10; i++){ random = random +random; } print(random);

What is the number printed in this program?


The answer is 1024.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Prince Loomba
Sep 27, 2016

For 10 times we are multiplying random by 2 so answer 2^10 or 1024

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...