C++ if statement Tests the user's first initial and prints a message.

Description

C++ if statement Tests the user's first initial and prints a message.

#include <iostream>
using namespace std;
int main()/*from w  ww.jav  a 2  s .  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