• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic