C++ examples for Language Basics:Console
Tests the user's first initial and prints a message.
#include <iostream> using namespace std; int main()//from w w w .j av 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; }