Illustrates this declaration and the use of cout to display the value stored in a character variable. - C++ Data Type

C++ examples for Data Type:char

Description

Illustrates this declaration and the use of cout to display the value stored in a character variable.

Demo Code

#include <iostream>
using namespace std;
int main()//from  ww w.ja v  a  2s.  co m
{
   char ch;     // this declares a character variable
   ch = 'a';    // store the letter a in ch
   cout << "The character stored in ch is " << ch << endl;
   ch = 'm';    // now store the letter m in ch
   cout << "The character now stored in ch is "<< ch << endl;
   return 0;
}

Result


Related Tutorials