• Post Reply Bookmark Topic Watch Topic
  • New Topic
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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Flow Control.......

 
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Options :
1)2
2)3
3)6
4)7
5)9
I tried running the code and got the output as 3.
Can any one make me understand the flow of the code?
Sonir
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sonir :
write it this way
i=0;j=0;k=0 counter will be 0(1)
i=0;j=0;k=1 break's out
i=1;j=0;k=0 counter will be 1(2)
i=1;j=0;k=1 break's out
i=1;j=0;k=0 counter will be 2(3)
i=1;j=0;k=1 break's out
i=2;j=0;k=0 counter will be 3(4)
i=2;j=0;k=1 break's out
So the answer 3 will be printed.
Hope this helps
-A
 
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
first ......i=0 j=0 k=0, counter =1
second ........... k=1, break middle and enter outer
third ...... i=1 j=0 k=0 counter =2
fourth ........... k=1 break middle and enter outer
fifth i=2 j=0 k=0 counter =3
......... k=1 break middle and enter outer
and it stops as i cannot be incremented further.
hope this helps....


Options :
1)2
2)3
3)6
4)7
5)9
I tried running the code and got the output as 3.
Can any one make me understand the flow of the code?
Sonir[/qb]<hr></blockquote>
[ January 23, 2002: Message edited by: mark stone ]
 
Attractive, successful people love this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic