203 views
1 votes
1 votes

Which of the following represents the number of additions performed by above code?

A 8000

B 4000

C 4020

D 28420

Solution:- Well i got the Answer but not exact answer :- 

Ttoal  number of times loop executes = 20 * 20 * 20 = 8000

The inner condition will execute always and two additions will be there so = 8000*2 = 16000 (atleast this much additions will be there. Here we can mark our option as D)

Now we Know :-    Even + Even = Even  ,   Even + Odd = Odd    ,    Odd + Odd = Even.

So when i = 1, total Odd numbers in j = 10 and for every 10 numbers loop k will also have 10 numbers  hence total 100 numbers

So total = 100*10 = 1000   (I guess here i left some Cases)

So total = 17000  

But sill its far away from actual answer which is D

Please log in or register to answer this question.

No related questions found