Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Flow Control.......

 
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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 ]
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic