Asks for first initial and tests to ensure that response is correct. - C++ Data Type

C++ examples for Data Type:char

Description

Asks for first initial and tests to ensure that response is correct.

Demo Code

#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;
}

Result


Related Tutorials