Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

The ASCII Table: A Deep Dive

Lesson 6 of 53 in the free Foundation of C & C++ notes on Siksha Sarovar, written by Rohit Jangra.

Characters are Just Small Integers

In C, the char type is essentially a 1-byte integer. The mapping between the binary number in memory and the character you see on the screen is defined by the ASCII (American Standard Code for Information Interchange) table.

Understanding the Mapping

Every key on your keyboard has a corresponding ASCII value:

  • 48 to 57: The digits 0 through 9.
  • 65 to 90: Uppercase letters A through Z.
  • 97 to 122: Lowercase letters a through z.
  • 32: The Space character.
  • 10: Newline (\n).
  • 0: The Null Character (\0).

Why is this important?

Because characters are numbers, you can perform logic on them:

  1. Checking for letters: if (ch >= 'A' && ch <= 'Z') checks if a character is an uppercase letter.
  2. Case Conversion: The difference between 'A' (65) and 'a' (97) is always exactly 32.
  • To lowercase: upper + 32
  • To uppercase: lower - 32
  1. Digit to Integer: To turn the character '5' into the actual number 5 for math, subtract the character '0'.
  • '5' - '0' == 5 (because 53 - 48 == 5).

Control Characters (0-31)

These are non-printable characters used to control hardware:

  • ASCII 7 (Bell): Makes your computer beep! (\a)
  • ASCII 8 (Backspace): Moves the cursor back one spot. (\b)
  • ASCII 9 (Tab): Inserts a horizontal tab. (\t)

Example ASCII Values

CharacterDecimalHexadecimalDescription
\0000Null Terminator
\n100ALine Feed (New line)
3220Space
04830Digit Zero
A6541Uppercase Alpha
a9761Lowercase alpha

Extended ASCII and Unicode

Standard ASCII uses 7 bits (values 0-127). The 8th bit allowed for "Extended ASCII" (128-255) to include currency symbols and accented letters. Modern software uses Unicode (UTF-8), which can represent over 100,000 characters from every language on Earth. C handles Unicode through wider data types like wchar_t.

You can print the ASCII value of any character using printf("%d", 'Z');. You can print the character associated with any number using printf("%c", 90);. Try it out!