Page 1 of 1

About Question enthuware.ocajp.i.v7.2.1227 :

Posted: Mon Aug 20, 2012 12:33 pm
by ETS User
Hi,

option 3 (It will print 4, 3 when line 1 is replaced by continue.) is a correct option but I figure it would print '4, 4' - could you explain why please?

Also, I think there's a typo in the explanation about the break statement, at step 2.3 'm' suddenly jumps to 2, then increments to 3, but still prints out 2. Should it not be m=1 at step 2.3, then m=2 at step 3.3?

Thanks in advance for your help:)

Re: About Question enthuware.ocajp.i.v7.2.1227 :

Posted: Mon Aug 20, 2012 8:32 pm
by admin
Yes, you are right. m should be 1 in iteration 1. This has now been fixed. Rest is fine.

Regarding continue:

1. k=0, m=0

2. iteration 1: i=0
2.1 k = 1
2.2 i == 2 is false
2.3 m = 1

3. iteration 2: i = 1
3.1 k=2
3.2 i==2 is false
3.3 m = 2

4. iteration 3: i = 2
4.1 k=3
4.2 i==2 is true
4.3 continue - This means rest of the statements in the loop for this iteration will be skipped and thus m will not be incremented and will remain 2.

5. iteration 4: i = 3
5.1 k=4
5.2 i==2 is false
5.3 m = 3

6. print 4, 3

HTH,
Paul.

Re: About Question enthuware.ocajp.i.v7.2.1227 :

Posted: Wed Mar 06, 2013 5:17 pm
by Guest
not that this question is hard by any means but it's very time consuming to try out, my question is are we allowed pen and paper in the exam room? or something they give us to use?

Re: About Question enthuware.ocajp.i.v7.2.1227 :

Posted: Wed Mar 06, 2013 6:50 pm
by admin
Yes, you are allowed pen and paper.
You may get questions that involve simple loops where you have to work through each iteration.

Re: About Question enthuware.ocajp.i.v7.2.1227 :

Posted: Wed Mar 06, 2013 8:10 pm
by Guest
admin wrote:Yes, you are allowed pen and paper.
You may get questions that involve simple loops where you have to work through each iteration.
that's fine, as long as i have a pen and paper because my heap seems not to function correctly sometimes :ugeek: !!

Thanks.

Re: About Question enthuware.ocajp.i.v7.2.1227 :

Posted: Fri May 30, 2014 12:44 am
by Chandni
The break statement, if inserted in line 1 will break the 'if' loop or the 'for' loop?

Thanks in adv.

Re: About Question enthuware.ocajp.i.v7.2.1227 :

Posted: Fri May 30, 2014 12:56 am
by admin
break will apply to the for loop. if is not a loop.
Please try it out.

HTH,
Paul.

Re: About Question enthuware.ocajp.i.v7.2.1227 :

Posted: Fri May 30, 2014 1:02 am
by Chandni
admin wrote:break will apply to the for loop. if is not a loop.
Please try it out.

HTH,
Paul.
Thanks alot.