Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

Character Set in C

In the C programming language, the character set refers to a set of all the valid characters that we can use in the source program for forming words, expressions, and numbers.

The source character set contains all the characters that we want to use for the source program text. On the other hand, the execution character set consists of the set of those characters that we might use during the execution of any program. Thus, it is not a prerequisite that the execution character set and the source character set will be the same, or they will match altogether.

Ultimate Guide to Kickstart your GATE Exam Preparation
Download the e-book now

In this article, we will take a closer look at the Character Set in C according to the GATE Syllabus for CSE (Computer Science Engineering). Read ahead to know more.

Table of Contents

Use of Character Set in C

Just like we use a set of various words, numbers, statements, etc., in any language for communication, the C programming language also consists of a set of various different types of characters. These are known as the characters in C. They include digits, alphabets, special symbols, etc. The C language provides support for about 256 characters.

Every program that we draft for the C program consists of various statements. We use words for constructing these statements. Meanwhile, we use characters for constructing these statements. These characters must be from the C language character set. Let us look at the set of characters offered by the C language.

Types of Characters in C

The C programming language provides support for the following types of characters. In other words, these are the valid characters that we can use in the C language:

  • Digits
  • Alphabets
  • Main Characters

All of these serve a different set of purposes, and we use them in different contexts in the C language.

Alphabets

The C programming language provides support for all the alphabets that we use in the English language. Thus, in simpler words, a C program would easily support a total of 52 different characters- 26 uppercase and 26 lowercase.

Type of Character Description Characters
Lowercase Alphabets a to z a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z
Uppercase Alphabets A to Z A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z

Digits

The C programming language provides the support for all the digits that help in constructing/ supporting the numeric values or expressions in a program. These range from 0 to 9, and also help in defining an identifier. Thus, the C language supports a total of 10 digits for constructing the numeric values or expressions in any program.

Type of Character Description Characters
Digits 0 to 9 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Special Characters

We use some special characters in the C language for some special purposes, such as logical operations, mathematical operations, checking of conditions, backspaces, white spaces, etc.

We can also use these characters for defining the identifiers in a much better way. For instance, we use underscores for constructing a longer name for a variable, etc.

The C programming language provides support for the following types of special characters:

Type of Character Examples
Special Characters ` ~ @ ! $ # ^ * % & ( ) [ ] { } < > + = _ – | / \ ; : ‘ “ , . ?

White Spaces

The white spaces in the C programming language contain the following:

  • Blank Spaces
  • Carriage Return
  • Tab
  • New Line

Summary of Special Characters in C

Here is a table that represents all the types of character sets that we can use in the C language:

Type of Character Description Characters
Lowercase Alphabets a to z a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z
Uppercase Alphabets A to Z A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z
Digits 0 to 9 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Special Characters ` ~ @ ! $ # ^ * % & ( ) [ ] { } < > + = _ – | / \ ; : ‘ “ , . ?
White Spaces Blank Spaces, Carriage Return, Tab, New Line

Purpose of Character Set in C

The character sets help in defining the valid characters that we can use in the source program or can interpret during the running of the program. For the source text, we have the source character set, while we have the execution character set that we use during the execution of any program.

But we have various types of character sets. For instance, one of the character sets follows the basis of the ASCII character definitions, while the other set consists of various kanji characters (Japanese).

The type of character set we use will have no impact on the compiler- but we must know that every character has different, unique values. The C language treats every character with different integer values. Let us know a bit more about the ASCII characters.

ASCII Values

All the character sets used in the C language have their equivalent ASCII value. The ASCII value stands for American Standard Code for Information Interchange value. It consists of less than 256 characters, and we can represent these in 8 bits or even less. But we use a special type for accommodating and representing the larger sets of characters. These are called the wide-character type or wchat_t.

However, a majority of the ANSI-compatible compilers in C accept these ASCII characters for both the character sets- the source and the execution. Every ASCII character will correspond to a specific numeric value.

Here is a list of all the ASCII characters, along with their assigned numeric values.

Control Characters

ASCII Value Character Meaning
0 NULL Null
1 SOH Start of Header
2 STX Start of Text
3 ETX End of Text
4 EOT End of Transaction
5 ENQ Enquiry
6 ACK Acknowledgement
7 BEL Bell
8 BS Backspace
9 HT Horizontal Tab
10 LF Line Feed
11 VT Vertical Tab
12 FF Form Feed
13 CR Carriage Return
14 SO Shift Out
15 SI Shift In
16 DLE Data Link Escape
17 DC1 Device Control 1
18 DC2 Device Control 2
19 DC3 Device Control 3
20 DC4 Device Control 4
21 NAK Negative Acknowledgement
22 SYN Synchronous Idle
23 ETB End of Trans Block
24 CAN Cancel
25 EM End of Medium
26 SUB Substitute
27 ESC Escape
28 FS File Separator
29 GS Group Separator
30 RS Record Separator
31 US Unit Separator

Printable Characters

ASCII Value Character
32 Space
33 !
34
35 #
36 $
37 %
38 &
39
40 (
41 )
42
43 +
44 ,
45
46 .
47 /
48 0
49 1
50 2
51 3
52 4
53 5
54 6
55 7
56 8
57 9
58 :
59 ;
60 <
61 =
62 >
63 ?
64 @
65 A
66 B
67 C
68 D
69 E
70 F
71 G
72 H
73 I
74 J
75 K
76 L
77 M
78 N
79 O
80 P
81 Q
82 R
83 S
84 T
85 U
86 V
87 W
88 X
89 Y
90 Z
91 [
92 |
93 ]
94 ^
95 _
96 ՝
97 a
98 b
99 c
100 d
101 e
102 f
103 g
104 h
105 i
106 j
107 k
108 l
109 m
110 n
111 o
112 p
113 q
114 r
115 s
116 t
117 u
118 v
119 w
120 x
121 y
122 z
123 {
124 |
125 }
126
127 DEL

(DEL is also a control character.)

Character Equivalence

Here are all the character sets in ASCII. The table below displays all the character’s hexadecimal, decimal, and octal values:

Character Oct Dec Hex
\0 00 0 0х0
\001 01 1 0х1
\002 02 2 0х2
\003 03 3 0х3
\004 04 4 0х4
\005 05 5 0х5
\006 06 6 0х6
\007 07 7 0х7
\b 010 8 0х8
\t 011 9 0х9
\n 012 10 0хA
\v 013 11 0хB
\f 014 12 0хC
\r 015 13 0хD
\016 016 14 0хE
\017 017 15 0хF
\020 020 16 0х10
\021 021 17 0х11
\022 022 18 0х12
\023 023 19 0х13
\024 024 20 0х14
\025 025 21 0х15
\026 026 22 0х16
\027 027 23 0х17
\030 030 24 0х18
\031 031 25 0х19
\032 032 26 0х1A
\033 033 27 0х1B
\034 034 28 0х1C
\035 035 29 0х1D
\036 036 30 0х1E
\037 037 31 0х1F
(space) 040 32 0х20
! 041 33 0х21
042 34 0х22
# 043 35 0х23
$ 044 36 0х24
% 045 37 0х25
& 046 38 0х26
\ 047 39 0х27
( 050 40 0х28
) 051 41 0х29
052 42 0х2A
+ 053 43 0х2B
, 054 44 0х2C
_ 055 45 0х2D
. 056 46 0х2E
/ 057 47 0х2F
0 060 48 0х30
1 061 49 0х31
2 062 50 0х32
3 063 51 0х33
4 064 52 0х34
5 065 53 0х35
6 066 54 0х36
7 067 55 0х37
8 070 56 0х38
9 071 57 0х39
| 072 58 0х3A
; 073 59 0х3B
< 074 60 0х3C
= 075 61 0х3D
> 076 62 0х3E
? 077 63 0х3F
Character Oct Dec Hex
__ 0100 64 0х40
A 0101 65 0х41
B 0102 66 0х42
C 0103 67 0х43
D 0104 68 0х44
E 0105 69 0х45
F 0106 70 0х46
G 0107 71 0х47
H 0110 72 0х48
I 0111 73 0х49
J 0112 74 0х4A
K 0113 75 0х4B
L 0114 76 0х4C
M 0115 77 0х4D
N 0116 78 0х4E
O 0117 79 0х4F
P 0120 80 0х50
Q 0121 81 0х51
R 0122 82 0х52
S 0123 83 0х53
T 0124 84 0х54
U 0125 85 0х55
V 0126 86 0х56
W 0127 87 0х57
X 0130 8 0х58
Y 0131 89 0х59
Z 0132 90 0х5A
[ 0133 91 0х5B
\ 0134 92 0х5C
] 0135 93 0х5D
^ 0136 94 0х5E
_ 0137 95 0х5F
0140 96 0х60
a 0141 97 0х61
b 0142 98 0х62
c 0143 99 0х63
d 0144 100 0х64
e 0145 101 0х65
f 0146 102 0х66
g 0147 103 0х67
h 0150 104 0х68
i 0151 105 0х69
j 0152 106 0х6A
k 0153 107 0х6B
l 0154 108 0х6C
m 0155 109 0х6D
n 0156 110 0х6E
o 0157 111 0х6F
p 0160 112 0х70
q 0161 113 0х71
r 0162 114 0х72
s 0163 115 0х73
t 0164 116 0х74
u 0165 117 0х75
v 0166 118 0х76
w 0167 119 0х77
x 0170 120 0х78
y 0171 121 0х79
z 0172 122 0х7A
{ 0173 123 0х7B
| 0174 124 0х7C
} 0175 125 0х7D
~ 0176 126 0х7E
\177 0177 127 0х7F

Practice Problems on Character Set in C

1. Which of these is a type of character set used in the C language?

A. Digits

B. Alphabets Characters

D. All of the above

Answer – D. All of the above

2. What types of alphabets does the language support?

A. Lowercase Alphabets and Characters

B. Uppercase Alphabets and Characters

C. All of the above

Answer – C. All of the above

3. How many characters does the C programming language support in total?

A. 52

B. 26

C. 256

D. 86

Answer – C. 256

4. How many digits do the C programming language support as character sets?

A. Nine

B. Eight

C. Five

D. Ten

Answer – D. Ten


FAQs

Q1

What constitutes the white spaces in the C language?

In the C programming language, the white spaces contain the following:

  • Blank Spaces
  • Carriage Return
  • Tab
  • New Line
Q2

What are ASCII values in C?

All the character sets used in the C language have their equivalent ASCII value. The ASCII value stands for American Standard Code for Information Interchange value. It consists of less than 256 characters, and we can represent these in 8 bits or even less.
However, a majority of the ANSI-compatible compilers in C accept these ASCII characters for both the character sets- the source and the execution. Every ASCII character will correspond to a specific numeric value.

Q3

What is wchat_t?

The ASCII consists of less than 256 characters, and we can represent these in 8 bits or even less. But we use a special type for accommodating and representing the larger sets of characters. These are called the wide-character type or wchat_t.

Q4

What is the use of special characters if we have digits in the C language?

We use some special characters in the C language for some special purposes, such as logical operations, mathematical operations, checking of conditions, backspaces, white spaces, etc.
We can also use these characters for defining the identifiers in a much better way. For instance, we use underscores for constructing a longer name for a variable, etc.

Keep learning and stay tuned to get the latest updates on GATE Exam along with GATE Eligibility CriteriaGATE 2023GATE Admit CardGATE Syllabus for CSE (Computer Science Engineering)GATE CSE NotesGATE CSE Question Paper, and more.

Also Explore,

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*