Using a loop to display the characters for ACSII codes? HELP!

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2009
Posts: 16
Reputation: jko2326 is an unknown quantity at this point 
Solved Threads: 0
jko2326 jko2326 is offline Offline
Newbie Poster

Using a loop to display the characters for ACSII codes? HELP!

 
0
  #1
Jul 27th, 2009
Hello everyone!
I'm a beginner in programming so please bare with me =/
I have a problem that I just don't understand.

Here's the problem:

Write a program that uses a loop to display the characters for the ACSII codes 0 - 127. Display 16 characters on each line (c++).

What is it asking for me to display in the program?
Any examples to help me get started would be great.
Thanks. =)
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 66
Reputation: djextreme5 is on a distinguished road 
Solved Threads: 4
djextreme5's Avatar
djextreme5 djextreme5 is offline Offline
Junior Poster in Training

Re: Using a loop to display the characters for ACSII codes? HELP!

 
0
  #2
Jul 27th, 2009
Every thing that you can type or have displayed in the DOS shell has a certain number known as the ASCII value. What the problem is asking is "to display all the characters that can be represented in the given range."

edit:

cout << static_cast<char>(100) << endl;

with iostream libray and std namespace, this will display the character that is represented by the ASCII value 10.

To find the ASCII value of a character,

cout << (int)'i' << endl;

same thing again, with iostream libray and std namespace.
Last edited by djextreme5; Jul 27th, 2009 at 4:20 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,500
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1479
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Using a loop to display the characters for ACSII codes? HELP!

 
0
  #3
Jul 27th, 2009
Here are a few tables that will show the ascii codes for all possible values. Note that decimal values 0 thru 32 are not printable so you won't see anything on your screen for them. Only values 33 thru 126 can be shown on the screen.
Last edited by Ancient Dragon; Jul 27th, 2009 at 9:15 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 16
Reputation: jko2326 is an unknown quantity at this point 
Solved Threads: 0
jko2326 jko2326 is offline Offline
Newbie Poster

Re: Using a loop to display the characters for ACSII codes? HELP!

 
0
  #4
Jul 27th, 2009
Thanks for the info.
Last edited by jko2326; Jul 27th, 2009 at 3:39 pm.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,831
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Using a loop to display the characters for ACSII codes? HELP!

 
0
  #5
Jul 27th, 2009
Code tags. makes it easier to read:


[code=cplusplus]
// paste code here
[/code]

or

[code]
// paste code here
[/code]


Why do you have two separate while conditions here and where is each supposed to start and end? Stick some brackets in there to make it more obvious. I feel pretty confident that at the very least, you have a brackets problem. I'd suggest a way to fix it, but I don't understand what you're trying to do. Please repost with brackets and code tags. Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 16
Reputation: jko2326 is an unknown quantity at this point 
Solved Threads: 0
jko2326 jko2326 is offline Offline
Newbie Poster

Re: Using a loop to display the characters for ACSII codes? HELP!

 
0
  #6
Jul 27th, 2009
I have solved this problem. Thank you for all the help
You were right about the brackets I forgot to add them in!
But thanks again everyone.
Last edited by jko2326; Jul 27th, 2009 at 3:38 pm. Reason: Solved it.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,831
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Using a loop to display the characters for ACSII codes? HELP!

 
0
  #7
Jul 27th, 2009
My point is that the first while loop starts on line 5 and ends on line 46. the second while loop (with no brackets) starts on line 25 and ends on line 26 and resides 100% inside the first while loop. I assume this not what you intended? The indentation suggests so. Look at the brackets and make sure they are where you want them to be.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,831
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Using a loop to display the characters for ACSII codes? HELP!

 
0
  #8
Jul 27th, 2009
Originally Posted by VernonDozier View Post
My point is that the first while loop starts on line 5 and ends on line 46. the second while loop (with no brackets) starts on line 25 and ends on line 26 and resides 100% inside the first while loop. I assume this not what you intended? The indentation suggests so. Look at the brackets and make sure they are where you want them to be.
Obviously my last two posts refer to code that's no longer there. Glad you solved it.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC