C++ Character Data Types

Character Types

The char data type is used to store a single character. The character must be surrounded by single quotes, like 'A' or 'c':

Example

char myGrade = 'B';
cout << myGrade;

Try it yourself!

Alternatively, you can use ASCII values to display certain characters:

Example

char a = 65, b = 66, c = 67;
cout << a;
cout << b;
cout << c;

Try it yourself!

Tip: A list of all ASCII values can be found in our ASCII Table Reference.

Comments

Popular posts from this blog

Two ways to add code block in blogger template for composing posts

ភាសាកម្មវិធី C++៖ សង្ខេប

សំណួរ និងលំហាត់៖ ភាពខុស​គ្នា​រវាងភាសា C និងភាសា C++