ASCII Code In C With Example and Table

What is the ASCII code?

ASCII stands for American Standard Code for Information Interchange. It’s a 7-bit character code where every single bit represents a unique character.

Number 65-90 its range is capital A-Z, and 97-122 its range is small a-z and in this range, all character is only 26.

ASCII value represents the English characters as numbers, each letter is assigned a number from 0 to 127. For example, the ASCII value for the uppercase B is 66.

Program to display the ASCII value of a character entered by the user.

#include <stdio.h>
#include <stdlib.h>
int main()
{
    char ch;
    printf("Enter any character:");
    /* Reads the entered character and stores it
     * into the char variable ch
     */
    scanf("%c", &ch);
    /* Using the format specifiers we can get the ASCII code
     * of a character. When we use %d format specifier for a
     * char variable then it displays the ASCII value of a char
     */
    printf("ASCII value of character %c is: %d", ch, ch);
    return 0;
}

Output:

Enter any character:P
ASCII value of character P is: 80

Table for common ASCII Codes:

NumbersCharacter
65A
66B
67C
68D
69E
70F
71G
72H
73I
74J
75K
76L
77M
78N
79O
80P
81Q
82R
83S
84T
85U
85V
87W
88X
89Y
90Z
97a
98b
99c
100d
101e
102f
103g
104h
105i
106j
107k
108l
109m
110n
111o
112p
113q
114r
115s
116t
117u
118v
119w
120x
121y
122z

Previous Lecture:

Introduction to C
Escape Characters
Data Types

If you have any problem in solving your questions, then join our Telegram group or search @Learnsimply, we will help you.

Please write comments if you find anything incorrect in the ASCII Code lecture.

Leave a Comment

en English
X