• anonymous
i need help with this problem writing it in C++: Characters for the ASCII codes, Write a program that uses a loop to display the characters for the ASCII codes 0 through 127. Display 16 characters each line.
Computer Science
  • Stacey Warren - Expert
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
  • katieb
I got my questions answered at in under 10 minutes. Go to now for free help!
  • anonymous
You need either an int or char variable that goes from 0 to 127 and print it as a %c. Use a for, something like: for(i=0; i <= 127; i++){ if(i % 16 == 0){ //print the character and a \n i%16 will make it so everytime you reach 16, 32, 48, etc. you will ujmp a line. } else { //just print the character } } the variable i will go through all the values from 0 to 127 in this for.
  • anonymous
I think it's a little cleaner to always print the character, then if i%16==0 print just a newline.
  • rsmith6559
One thing, the ASCII values below 32 are mostly control "characters" printing them can give some REAL interesting results.

Looking for something else?

Not the answer you are looking for? Search for more explanations.