Character Set in C++

The character set combines some mathematical symbols, such as the Digits and Special symbols, with the Alphabets and White Spaces of the English language. The term "C++ character set" refers to the characters and symbols that the C++ program can comprehend and accept. These are combined to form and provide the C++ language's commands, expressions, words, c-statements, and other tokens.

It basically consists of combining alphabets or characters, Special symbols, Digits, and White Spaces in a way that is similar to how learning English entails first learning the alphabets, then learning how to combine these alphabets to create words. After that, these words are joined to make sentences, and these sentences are joined to make paragraphs. More specifically, a C++ program can be described as a succession of characters in an ordered fashion. In the C++ compiler, these characters play a variety of roles, which are part of the character set.

C++ utilizes a combination of characters in addition to characters to describe some specific circumstances. For instance, the newline, backspace, and horizontal tab are each represented by the character combinations "nt", "b", and "t".

These are categorized as below:

Sr.noCategoryCharacter
1.AlphabetsA 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
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
2.Digits0 1 2 3 4 5 6 7 8 9
3.Special characters- * / A () [] {} = <> . ' " $ , ; : % ! & ? _ (underscore) # @
4.White spacesSpace bar (Blank space), Horizontal Tab (? ),

1. Alphabets

A-Z or a-z represents alphabets, and it depends on the case. As C++ language is case-sensitive, lowercase and uppercase letters always have different meanings. This character set makes writing C++ statements and character constants very simple. Thus, all 26 letters are available in C++ programming.

2. Digits

The Digits are represented by the numbers 0 through 9, alone or in combination. The numeric constant can be written out easily using Digits. The C-tokens can also be given the numerical data. In C++ programming, you can use any one of the ten Digits, from 0 to 9.

3. Special symbols

The term "Special symbols" refers to all keyboard keys other than the alphabetic, numeric, and white space keys. Therefore, these are some punctuation marks and some unique symbols that can be used for a quotation or for a special purpose.

Approx thirty Special symbols are available for usage in C++ programming. Additionally, Special symbols can be used for C++ statements to create arithmetic statements like +, -, *, relational statements like >, =, >=, ==, assignment expressions like =, and logical statements like &&, II, etc.

4. White Spaces

For specific applications, White Spaces can be used for blank space, newline return, tab space (horizontal), form feed, carriage control, etc. Notably, the Turbo-C Compiler always ignores these white space characters in both high-level and low-level programming.

Example of a C++ Character Set:

You can see an example of the use of character sets in the C++ programming language in the program that follows:

Output:

Enter a character: A
You entered a character: A

Enter a Digit: 5
You entered a Digit: 5
Enter a symbol: #
You entered a symbol: #





Latest Courses