C++ examples for Data Type:char
Asks for first initial and tests to ensure that response is correct.
#include <iostream> using namespace std; #include <ctype.h> void main()/* w ww . j av a 2s. co m*/ { char initial; cout << "What is your first initial? "; cin >> initial; while (!isalpha(initial)) { cout << "\nThat was not a valid initial! \n"; cout << "\nWhat is your first initial? "; cin >> initial; } cout << "\nThanks!"; return; }