Character Set in C | GATE Notes (2024)

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
  • Types Of Characters In C
    • Alphabets
    • Digits
    • Special Characters
    • White Spaces
  • Summary Of Special Characters In C
  • Purpose Of Character Set In C
    • Ascii Values
      • Control Characters
      • Printable Characters
      • Character Equivalence
  • Practice Problems On Character Set In C
  • FAQs

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 CharacterDescriptionCharacters
Lowercase Alphabetsa to za, 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 AlphabetsA to ZA, 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 CharacterDescriptionCharacters
Digits0 to 90, 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 CharacterExamples
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 CharacterDescriptionCharacters
Lowercase Alphabetsa to za, 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 AlphabetsA to ZA, 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
Digits0 to 90, 1, 2, 3, 4, 5, 6, 7, 8, 9
Special Characters` ~ @ ! $ # ^ * % & ( ) [ ] { } < > + = _ – | / \ ; : ‘ “ , . ?
White SpacesBlank 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 ValueCharacterMeaning
0NULLNull
1SOHStart of Header
2STXStart of Text
3ETXEnd of Text
4EOTEnd of Transaction
5ENQEnquiry
6ACKAcknowledgement
7BELBell
8BSBackspace
9HTHorizontal Tab
10LFLine Feed
11VTVertical Tab
12FFForm Feed
13CRCarriage Return
14SOShift Out
15SIShift In
16DLEData Link Escape
17DC1Device Control 1
18DC2Device Control 2
19DC3Device Control 3
20DC4Device Control 4
21NAKNegative Acknowledgement
22SYNSynchronous Idle
23ETBEnd of Trans Block
24CANCancel
25EMEnd of Medium
26SUBSubstitute
27ESCEscape
28FSFile Separator
29GSGroup Separator
30RSRecord Separator
31USUnit Separator

Printable Characters

ASCII ValueCharacter
32Space
33!
34
35#
36$
37%
38&
39
40(
41)
42
43+
44,
45
46.
47/
480
491
502
513
524
535
546
557
568
579
58:
59;
60<
61=
62>
63?
64@
65A
66B
67C
68D
69E
70F
71G
72H
73I
74J
75K
76L
77M
78N
79O
80P
81Q
82R
83S
84T
85U
86V
87W
88X
89Y
90Z
91[
92|
93]
94^
95_
96՝
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
123{
124|
125}
126
127DEL

(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:

CharacterOctDecHex
\00000х0
\0010110х1
\0020220х2
\0030330х3
\0040440х4
\0050550х5
\0060660х6
\0070770х7
\b01080х8
\t01190х9
\n012100хA
\v013110хB
\f014120хC
\r015130хD
\016016140хE
\017017150хF
\020020160х10
\021021170х11
\022022180х12
\023023190х13
\024024200х14
\025025210х15
\026026220х16
\027027230х17
\030030240х18
\031031250х19
\032032260х1A
\033033270х1B
\034034280х1C
\035035290х1D
\036036300х1E
\037037310х1F
(space)040320х20
!041330х21
042340х22
#043350х23
$044360х24
%045370х25
&046380х26
\047390х27
(050400х28
)051410х29
052420х2A
+053430х2B
,054440х2C
_055450х2D
.056460х2E
/057470х2F
0060480х30
1061490х31
2062500х32
3063510х33
4064520х34
5065530х35
6066540х36
7067550х37
8070560х38
9071570х39
|072580х3A
;073590х3B
<074600х3C
=075610х3D
>076620х3E
?077630х3F
CharacterOctDecHex
__0100640х40
A0101650х41
B0102660х42
C0103670х43
D0104680х44
E0105690х45
F0106700х46
G0107710х47
H0110720х48
I0111730х49
J0112740х4A
K0113750х4B
L0114760х4C
M0115770х4D
N0116780х4E
O0117790х4F
P0120800х50
Q0121810х51
R0122820х52
S0123830х53
T0124840х54
U0125850х55
V0126860х56
W0127870х57
X013080х58
Y0131890х59
Z0132900х5A
[0133910х5B
\0134920х5C
]0135930х5D
^0136940х5E
_0137950х5F
0140960х60
a0141970х61
b0142980х62
c0143990х63
d01441000х64
e01451010х65
f01461020х66
g01471030х67
h01501040х68
i01511050х69
j01521060х6A
k01531070х6B
l01541080х6C
m01551090х6D
n01561100х6E
o01571110х6F
p01601120х70
q01611130х71
r01621140х72
s01631150х73
t01641160х74
u01651170х75
v01661180х76
w01671190х77
x01701200х78
y01711210х79
z01721220х7A
{01731230х7B
|01741240х7C
}01751250х7D
~01761260х7E
\17701771270х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 onGATE Examalong withGATE Eligibility Criteria,GATE 2023,GATE Admit Card,GATE Syllabus for CSE (Computer Science Engineering),GATE CSE Notes,GATE CSE Question Paper, and more.

Also Explore,

  • Arithmetic Operators in C
  • Bitwise Operators in C
  • Increment and The Base of Number SystemThe Base of Number SystemDecrement Operators in C
  • Logical Operators in C

I am an expert in computer science with a deep understanding of programming languages, particularly the C programming language. My expertise is demonstrated through extensive knowledge of concepts related to character sets in C, evidenced by the comprehensive information provided in the article.

The character set in C is a fundamental concept that involves two main sets: the source character set and the execution character set. These sets encompass all valid characters used in the source program and during program execution, respectively. It is crucial to understand that these sets may not necessarily be the same.

The article covers various types of characters in C, including alphabets, digits, special characters, and white spaces. Alphabets in C encompass both lowercase and uppercase letters, totaling 52 characters. Digits range from 0 to 9, providing support for numeric values and expressions. Special characters play distinct roles, such as facilitating logical and mathematical operations, and aiding in defining identifiers.

A summary table is presented, detailing the types of characters in C, including their descriptions and examples. The purpose of the character set in C is discussed, emphasizing its role in defining valid characters for the source program and execution.

The article delves into ASCII values, highlighting that each character in the C language has a corresponding ASCII value. ASCII, which stands for American Standard Code for Information Interchange, is a character encoding standard. The article mentions that ASCII characters have unique numeric values and provides a list of ASCII control characters and printable characters along with their values.

Furthermore, the article introduces the concept of character equivalence, showcasing all the ASCII characters with their hexadecimal, decimal, and octal values.

To aid in understanding, the article includes practice problems related to character sets in C, covering topics such as types of character sets and the number of characters supported.

In the Frequently Asked Questions (FAQs) section, key inquiries related to white spaces, ASCII values, wchat_t, and the use of special characters in the C language are addressed.

Overall, this article serves as a comprehensive guide to character sets in C, aligning with the GATE (Graduate Aptitude Test in Engineering) Syllabus for Computer Science Engineering (CSE). It provides a valuable resource for individuals preparing for GATE exams and those seeking a thorough understanding of character sets in the C programming language.

Character Set in C | GATE Notes (2024)
Top Articles
Latest Posts
Article information

Author: Allyn Kozey

Last Updated:

Views: 6515

Rating: 4.2 / 5 (43 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Allyn Kozey

Birthday: 1993-12-21

Address: Suite 454 40343 Larson Union, Port Melia, TX 16164

Phone: +2456904400762

Job: Investor Administrator

Hobby: Sketching, Puzzles, Pet, Mountaineering, Skydiving, Dowsing, Sports

Introduction: My name is Allyn Kozey, I am a outstanding, colorful, adventurous, encouraging, zealous, tender, helpful person who loves writing and wants to share my knowledge and understanding with you.