Working with Characters in C++

The char data type is used to store single characters, such as letters and symbols.

Example: Character Variables

char grade = 'A';
char initial = 'K'; // 'K' for Karthick AG

Explanation: Variables grade and initial store single character values enclosed in single quotes.

Key Takeaways

  • Use char for single characters.
  • Enclose character literals in single quotes.