C++ char type Requests a name, prints the name five times, and rings a bell.

Description

C++ char type Requests a name, prints the name five times, and rings a bell.

#include <iostream>
using namespace std;
int main()/*from ww w  .  j  av  a  2s.  co  m*/
{
   const char BELL = '\a';      // Constant that rings the bell
   int ctr = 0;       
   char fname[20];    
   cout << "What is your first name? ";    // Prompt the user
   cin >> fname;      
   while (ctr < 5)
   {
      cout << fname << "\n";
      ctr++;
   }
   cout << BELL;                  // Ring the terminal's bell
   return 0;
}



PreviousNext

Related