Return to Topic Menu | Computer Science Main Page | MathBits.com | Terms of Use

Character Literals and Variables

Characters are always only ONE letter or ONE character.
Character literals always appear inside
single quotation marks.
Define char variables for character data. 

// Example of character literals
#include <iostream.h>
int main(void)
{
     char first, middle, last;
     first = 'D;
     middle = 'O';
     last = 'G';
     // Rest of program would follow 



NOTE:  Character variable can be initialized when the variable is declared: 
char HonorGrade = 'A';    //Declare and initialize

Return to Topic Menu | Computer Science Main Page | MathBits.com  | Terms of Use