C++ char array Tests the user's first initial and prints a message.

Description

C++ char array Tests the user's first initial and prints a message.

#include <iostream>
using namespace std;
int main()//w  ww .  j  a va  2s . c o  m
{
   char last[20];   // Holds the last name.
   cout << "What is your last name? ";
   cin >> last;
   // Test the initial
   if (last[0] <= 'P')
   {
      cout << "Your name is early in the alphabet.\n";
   }
   else
   {
      cout << "You have to wait a while for " << "YOUR name to be called!\n";}
      return 0;
}



PreviousNext

Related