C++ Char Data Types Last Updated : 29 Nov, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report A Char datatype is a datatype that is used to store a single character. It is always enclosed within a single quote (' '). Syntax: Char variable; Example: C++ // C++ Program demonstrate // Use of char #include <iostream> using namespace std; int main() { char c = 'g'; cout << c; return 0; } OutputgASCII Value ASCII Value stands for American Standard Code for Information Interchange. It is used to represent the numeric value of all the characters. ASCII Range of 'a' to 'z' = 97-122 ASCII Range of 'A' to 'Z' = 65-90 ASCII Range of '0' to '9' = 48-57 To know more about it, refer to the article - ASCII table. Convert Character Value to Corresponding ASCII Value To convert a character to ASCII value we have to typecast it using int(character) to get the corresponding numeric value. Example: C++ // C++ Program to convert // Char to ASCII value #include <iostream> using namespace std; int main() { char c = 'g'; cout << "The Corresponding ASCII value of 'g' : "; cout << int(c) << endl; c = 'A'; cout << "The Corresponding ASCII value of 'A' : "; cout << int(c) << endl; return 0; } OutputThe Corresponding ASCII value of 'g' : 103 The Corresponding ASCII value of 'A' : 65Convert ASCII Value to Corresponding Character Value To convert an ASCII value to a corresponding Character value we have to typecast it using char(int) to get the corresponding character value. Example: C++ // C++ Program to convert // ASCII value to character #include <iostream> using namespace std; int main() { int x = 53; cout << "The Corresponding character value of x is : "; cout << char(x) << endl; x = 65; cout << "The Corresponding character value of x is : "; cout << char(x) << endl; x = 97; cout << "The Corresponding character value of x is : "; cout << char(x) << endl; return 0; } OutputThe Corresponding character value of x is : 5 The Corresponding character value of x is : A The Corresponding character value of x is : aEscape Sequence in C++ Escape sequences are characters that determine how the line should be printed on the output window. The escape sequence always begins with a backslash '\' (also known as an escape character). Some Examples of Escape Sequences are mentioned below: S. No.Escape SequencesCharacter1.\nNewline2.\\Backslash3.\tHorizontal Tab4.\vVertical Tab5.\0Null Character Example: C++ // C++ Program to demonstrate // Use of Escape Sequence #include <iostream> using namespace std; int main() { char a = 'G'; // horizontal tab char b = '\t'; char c = 'F'; char d = '\t'; char e = 'G'; // new line char f = '\n'; string s = "is the best"; cout << a << b << c << d << e << f << s; return 0; } OutputG F G is the best Comment More infoAdvertise with us Next Article char8_t Data Type in C++ 20 R raj2002 Follow Improve Article Tags : Technical Scripter C++ Technical Scripter 2022 cpp-data-types Practice Tags : CPP Similar Reads C++ Data Types Data types specify the type of data that a variable can store. Whenever a variable is defined in C++, the compiler allocates some memory for that variable based on the data type with which it is declared as every data type requires a different amount of memory.C++ supports a wide variety of data typ 7 min read char8_t Data Type in C++ 20 The most recent version of the C++ programming language, C++20, was introduced in the year 2020. The char8_t data type is one of the new features added to C++20. This data type was created especially to display UTF-8 encoded characters. Let's understand what char8_t is and how is it different from o 3 min read COBOL - Data Types A Datatype is a classification by the programmer to tell the compiler/interpreter how data will be used inside a program. For example, the roll number of the student defined as the number will take input as a number only if other values are supplied instead of the number it will raise an abend insid 4 min read SAP ABAP | Data Types Before Understanding the Data type first understand the Data object. Data objects are variables that we declare in the program. It occupies some memory where you can store the data from external sources. Data can be of different types, so data types are responsible for defining the type of data of t 6 min read C++ Compound Data Types Quiz Built-in data types cannot store all the information in an easily accessible and organized way. That is why C++ provides compound data types such as arrays, pointers, strings, etc. that are derived from the built-in data types and provide different way to use them. Good understanding of compound dat 2 min read C++ Numeric Data Type There are mainly 3 types of Numeric Data Types in C++ int unsigned intshort intunsigned short int long intunsigned long intlong long intunsigned long long intfloat double long double1. Integer (int) An integer is a type of datatype that can store integer values. Integer acquires 4 bytes in memory an 4 min read Like