/****************************************************** ** Name: ** Filename: ASCII.cpp ** Project #: Deitel & Deitel 11.17 ** Project Description: Write a program that uses a for structure to print a table of ASCII values for the characters in the ASCII character set from 33 to 126. The program should print the decimal value, octal value, hexadecimal value and character value for each character. Use the stream manipulators dec, oct and hex to print the integer values. Also send output to a datafile as well as to the screen. ** Output: List of ASCII character set from 33 to 126 -List sent to screen output -List sent to data file "outputfile.txt" ** Input: None ** Algorithm: Instruct the user on the purpose of program Make file outputfile.txt to send information to Do a for loop for values 33 to 126 print out the decimal /send to file print out the octal /send to file print out the hexadecimal /send to file print out the character /send to file Once all values from 33 to 126 have been printed Exit program ******************************************************/ // Include files #include // used for cin, cout #include #include #include using namespace std; // Global Type Declarations // Function Prototypes void instruct (void); void pause (); //Global Variables - should not be used without good reason. int main () { // Declaration section int runs, row; ofstream odf; // Executable section instruct (); odf.open ( "outputfile.txt", ios::out ); if ( odf.fail()){ cerr << "File could not be opened\n"; exit (1); } odf << "Output file opened" < (runs) << endl; odf << setw( 10 ) << dec << runs << setw( 13 ) << oct << runs << setw( 13 ) << hex << runs << setw( 13 ) << static_cast (runs) << endl; ++row; if (row % 10 == 0 ){ pause (); odf << "Pause" << endl; } } odf << "\nPrinted list complete" << "\nExit" << endl; pause (); return 0; } void instruct (void) { // Declaration section cout << "This program will print a table of ASCII values for ASCII " << "character set\n33 to 126 on the screen. At the same time it " << "will send information from\nthe program and print the same " << "table in the datafile .\n" << "_______________________________________________________________" << "_____________" << "\n" << endl; pause(); // Executable section } void pause () { // Declaration section // Executable section cout << "\nPress any key to continue..."; getch(); cout << "\r"; cout << " "; cout << "\r"; } /* Program Output This program will print a table of ASCII values for ASCII character set 33 to 126 on the screen. At the same time it will send information from the program and print the same table in the datafile . ____________________________________________________________________________ List of the ASCII character set from 33 to 126 33 41 21 ! 34 42 22 " 35 43 23 # 36 44 24 $ 37 45 25 % 38 46 26 & 39 47 27 ' 40 50 28 ( 41 51 29 ) 42 52 2a * ... ... ... ... 113 161 71 q 114 162 72 r 115 163 73 s 116 164 74 t 117 165 75 u 118 166 76 v 119 167 77 w 120 170 78 x 121 171 79 y 122 172 7a z 123 173 7b { 124 174 7c | 125 175 7d } 126 176 7e ~ Press any key to continue... */