1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
What number which has been printed?
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.
At the beginning a = 3 0 and ( b − c ) = ( 2 0 − 1 0 ) = ( 1 0 ) > − 8 0
Loop 1: If the values satisfies the condition of the first loop, the program enters into the loop and adds 1 to the value of a , but b and c remains unchanged.
Loop 2: When a = 8 0 , the program enters into the second loop. Then the value of a becomes 0 . It adds 4 to the value of b and 7 to the value of c .
Now again it goes to first loop. When a = 8 0 it comes to second loop and change the value of b and c again.
Suppose after going to the second loop n times, b − c < − 8 0 which doesn't satisfy the condition of the first loop and will not go through any loop again.
( b + n × 4 ) − ( c + n × 7 ) < − 8 0
( 2 0 + n × 4 ) − ( 1 0 + n × 7 ) < − 8 0
− 3 × n < − 9 0
n > 3 0 [Dividing both sides by − 3 ]
That means after going to the second loop 3 1 times, b − c < − 8 0 .
Then, b = 2 0 + 3 1 × 4 = 1 4 4
c = 1 0 + 3 1 × 7 = 2 2 7
After last loop, a = 0
Hence, a + b + c = 0 + 1 4 4 + 2 2 7 = 3 7 1