C++/Language/Break

Материал из C\C++ эксперт
Перейти к: навигация, поиск

Sample program containing a break statement

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
   int ac = 32;          
                         
   while(true)
   { 
     cout << "Character   Decimal   Hexadecimal\n\n";
     int upper;
     for( upper =ac + 20; ac < upper && ac < 256; ++ac)
        cout << "      " << (char)ac     
             << setw(10) << dec << ac
             << setw(10) << hex << ac << endl;
     if( upper >= 256)   
        break;
     cout <<"To Go on, hit <return>, to Stop hit <q>+<return>";
     char answer;
     cin.get(answer);
     if( answer == "q" || answer == "Q" )
       break;
     cin.sync();
   }
   return 0;
}