Char Data Type In C++ With Example

Card image cap

Char Data Type ?

Character data type is used for storing characters. Keyword used for character data type is char.


Char data type :

Characters typically requires 1 byte of memory space and ranges from -128 to 127 or 0 to 255. char ch = 'A';

C++ offers a predefined data type that is one byte in size, which can hold exatly one character such as ‘a’ or ‘A’. To declare a variable of type char.

     char myword[] = { 'e','C','O','D','I',N','G', 'S','c','H','O','O','L','\0' };
    char myword[] = "eCODING SCHOOL"; 

Example :



Output :

    
    What is your name? Prayag
    Where do you live? eCoding School
    Hello, Prayag from ecoding School!
Card image cap