• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Another While loop

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic