Variable of Type char
-
The char data type can hold a single symbol such as a (upper or lower case) letter,
digit, and punctuation mark.
-
All the symbols that can be typed on the keyboard can be represented by char
-
In a program, a char literal must be enclosed in a pair of single quotes
Single quotes are absent however in I/O
-
They can be declared and initiated as follows:
char first_initial = 'W', // for Bill Clinton
your_initial; // your initial
cout << "Bill Clinton's first initial is: << first_initial << endl;
cout << "Enter your first initial: :<br>
cin >> your_initial;
cout << "Your first initial is: << your_initial << endl;
-
-