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

Recommended Answers

All 7 Replies

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.

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.

Thanks for the info.

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.

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.

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.