Demonstrates character variables - C++ Data Type

C++ examples for Data Type:char

Description

Demonstrates character variables

Demo Code

#include <iostream>
using namespace std;
int main()/*from  w  w w .  j  av  a 2s . c  o m*/
{
   char charvar1 = 'A';    //define char variable as character
   char charvar2 = '\t';   //define char variable as tab
   cout << charvar1;       //display character
   cout << charvar2;       //display character
   charvar1 = 'B';         //set char variable to char constant
   cout << charvar1;       //display character
   cout << '\n';           //display newline character
   return 0;
}

Result


Related Tutorials