• Post Reply Bookmark Topic Watch Topic
  • New Topic

Another While loop  RSS feed

 
Cade Foster
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This one has been driving my n00b brain nuts for weeks now, any help greatly appreciated:

I want a 5 column/12 Row output of UNICODE characters starting from 65 going up to 124 - my code:



What I've got so far from the output is the first 5 letters A B C D E, then I need it to repeat through the first while loop again.
 
Brian Cole
Author
Ranch Hand
Posts: 959
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by John Dupre:
while (uni <=65 && uni <123)


What's the point if checking if uni < 123 if you already know that uni <= 65 ?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually, your second loop never even executes. you start by setting uni to 'A', which is 65. col is less than 5, so you increment both, specifically making uni 66.

you then hit "while uni <= 65..." this is false, so this check stops, and you never enter this loop. if you take out that loop in its entirety, you code still runs exactly the same.

what i think you want to do is wrap this:

in a while loop, as long as uni is less than 124. You'll also need to reset col each time you exit the inner loop.

something like

 
Cade Foster
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My bad on the operand(should be >=65), thankfully I got it sorted myself I got advice from another forum that was total crap, you guys where spot on though

 
Brian Cole
Author
Ranch Hand
Posts: 959
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Cade Foster:


btw, this code would work just as well if you completely removed the row variable. You aren't really using it for anything.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!