954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

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. =)

jko2326
Newbie Poster
19 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

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(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.

djextreme5
Junior Poster
104 posts since Mar 2009
Reputation Points: 76
Solved Threads: 6
 

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.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Thanks for the info.

jko2326
Newbie Poster
19 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

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.

VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 

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.

jko2326
Newbie Poster
19 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

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.

VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 
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.

VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You