The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: For loops - MIND BENDER!!!

SercoSteveB
Active Participant

Steve - Just for fun!!!

 

What is the value in Numeric Value Out after the following has executed?

 

 Daily CLAD #7.png

 

a)    0

b)    1

c)    2

d)    3

Comments
RustyStrings
Member

the inner loop will output 1 + the second from the bottom terminal this will be put at the top of the outer loop and sent in to the next iteration

1st iteration (outer loop)

0
1+1=2 (put at the top of next)
2

2nd iteration (outer loop)

2
0+1=1 (put at the top of next)

1

3rd iteration (outer loop)

1
2+1=3 (send out)
0

so the answer is D 3

swetha_sadula
Member

ANswer:D

ashwinilele
Member

0th iteration of outer loop

            Inner loop

           0.        1

0.        3.         2

1.        0.         3

2.        1.          1

1 St iteration of outer loop

          0.         1

2.       2.         4

3.       2.         2

1.       3.         2

2 nd iteration of outer loop

           0.         1

4.        3          3

2.        4.        3

2.        2.        4

So output is 3. Ans Is D .  Procedure is correct or not?

Abodorra
Member

D

Andreas.Bernau
Member

D
image0926k.jpg

Andreas.Bernau
Member

@RustyStings

I like your approach.
But in a real exam when I am  getting nervous I would not be able to think like this.
I need simple solutions, without thinking if possible;-)

@ashwinilele

Take a look at the values you take over from one iteration to the next iteration of outer loop. It should be just one value not tree values. I think your procedure is not correct:

First iteration of outer loop we have an input of 0, 1, 2 and an output of 2.

Resulting in the input values of the second iteration of outer loop: 2, 0, 1 (not 2, 3, 1) and an output of 1

Resulting in the input values of the third iteration of outer loop: 1,2,0 (not 4,2,2) and an output of 3.

I recognized you have the same solution 3.
So I am not sure maybe I completely misunderstood your approach....

image0927k.jpg

sac0071
Member

D

Lily2016
Member

3

ersmt444
Member

Image broken

skian
Member

d