Printable ascii codes – CSKC
Sign In

Search

Solved Problem #CPP#2045    siteicon   siteicon  

Problem Statement - Printable ascii codes

Write a c++ program to print ascii codes and given printable characters from decimal ascii code 32 to 126 (The printable ascii code range). Print each code and character set in a new line.

Solution

TC++ #2045

 

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

This code is fairly simple, just start the range from 32 which is a space character, which does not show anything but is still considered a printable character and the test condition goes up to ascii 126.

for(int i=32;i<=126;i++)
{
cout<<i<<“\t”<<(char)i<<endl;
}
The index i will print the ascii code as it is defined as an integer variable. The (char) typecasted version of i will print its corresponding character.

Notes

  • The ascii code range has been designed in a way that the matter also remains in a sorted ascending order of digits and alphabets.
  • The 7-bit ascii set starts with 0 and ends at 127. If you try the same question with 0 to 127 range some special characters will also be printed. These character shapes will be dependent on the code-page being used for the output, but the range 32-126 will always display the same character any any code page.


Suggested Filename(s): printable-ascii.cpp



Share

Created: 30-Dec-2017 23:34 | Updated: 13-Dec-2018 23:52|