Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Annoying Problem.

 
Stephen Foy
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can seem to sort this out, the program should print out a different result for 1, but it keeps printing 2 1's

http://img481.imageshack.us/img481/5180/untitled5ar.jpg
[ October 28, 2005: Message edited by: ste fing ]
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try stepping through the code - either with a debugger or pen and paper

Assume number = 5.
Enter do/while loop
number = number - 2 ==> number = 3
print verse (number = 3)
while condition (number < 100 && number > 1) ==> true
repeat loop
number = number - 2 ==> number = 1
print verse (number = 1)
while condition (number < 100 && number > 1) ==> false
exit loop
print final verse (number = 1)
 
Stephen Foy
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joanne Neal:
Try stepping through the code - either with a debugger or pen and paper

Assume number = 5.
Enter do/while loop
number = number - 2 ==> number = 3
print verse (number = 3)
while condition (number < 100 && number > 1) ==> true
repeat loop
number = number - 2 ==> number = 1
print verse (number = 1)
while condition (number < 100 && number > 1) ==> false
exit loop
print final verse (number = 1)


Yea that does help, I should have done that. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic