programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Jeanne Boyarsky
• Ron McLeod
• Paul Clapham
• Liutauras Vilda
Sheriffs:
• paul wheaton
• Rob Spoor
• Devaka Cooray
Saloon Keepers:
• Stephan van Hulst
• Tim Holloway
• Carey Brown
• Frits Walraven
• Tim Moores
Bartenders:
• Mikalai Zaikin

# Flow Control -JQ+

Ranch Hand
Posts: 143
• Number of slices to send:
Optional 'thank-you' note:

I don't seem to understand how the output is 10. Please advise.
-Arun

Ranch Hand
Posts: 411
• Number of slices to send:
Optional 'thank-you' note:
Arun, I'll explain step by step:
i j k c (k>j)
0 0 0 1 false
0 0 1 2 true
0 1 0 3 false
0 1 1 4 false
0 1 2 5 true
1 0 0 6 false
1 0 1 7 true
1 1 0 8 false
1 1 1 9 false
1 1 2 10 true

Regards,
Jamal Hasanov
www.j-think.com

Arun Pai
Ranch Hand
Posts: 143
• Number of slices to send:
Optional 'thank-you' note:
Hi Jamal,
Really fast and the solution is quite simple.Thanks a lot.
-Arun

Ranch Hand
Posts: 2120
• Number of slices to send:
Optional 'thank-you' note:
These are the values when i is 0:
c=0
i=0
j=0
k=0
c=1
k=1
c=2
j=1
k=0
c=3
k=1
c=4
k=2
c=5
i=1
now i is 1 and the same it's repeated again,
but c is increamented up to 10

Arun Pai
Ranch Hand
Posts: 143
• Number of slices to send:
Optional 'thank-you' note:
Jose,
Thanks and what is this???

Well, I have been good looking for a long time before Map noticing it.

Jamal Hasanov
Ranch Hand
Posts: 411
• Number of slices to send:
Optional 'thank-you' note:
By the way, Arun
try this method in exam: draw a table of variables(for example: variables are columns) and debug code step by step in paper.
This method helped me very much in exam.
Regards,
Jamal Hasanov
www.j-think.com

Jose Botella
Ranch Hand
Posts: 2120
• Number of slices to send:
Optional 'thank-you' note:
Arun it's a joke about how good looking some bartenders are.
It was no addressed to anybody.
I think it is time to remove it

 Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad: a bit of art, as a gift, that will fit in a stocking https://gardener-gift.com