About Question enthuware.ocajp.i.v7.2.1227 :
Moderator: admin
About Question enthuware.ocajp.i.v7.2.1227 :
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:)
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:)
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1227 :
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.
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.
If you like our products and services, please help us by posting your review here.
Re: About Question enthuware.ocajp.i.v7.2.1227 :
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?
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1227 :
Yes, you are allowed pen and paper.
You may get questions that involve simple loops where you have to work through each iteration.
You may get questions that involve simple loops where you have to work through each iteration.
If you like our products and services, please help us by posting your review here.
Re: About Question enthuware.ocajp.i.v7.2.1227 :
that's fine, as long as i have a pen and paper because my heap seems not to function correctly sometimes !!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.
Thanks.
-
- Posts: 6
- Joined: Thu May 08, 2014 12:13 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1227 :
The break statement, if inserted in line 1 will break the 'if' loop or the 'for' loop?
Thanks in adv.
Thanks in adv.
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1227 :
break will apply to the for loop. if is not a loop.
Please try it out.
HTH,
Paul.
Please try it out.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 6
- Joined: Thu May 08, 2014 12:13 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1227 :
Thanks alot.admin wrote:break will apply to the for loop. if is not a loop.
Please try it out.
HTH,
Paul.
Who is online
Users browsing this forum: No registered users and 113 guests