(Displaying Characters for Given ASCII Codes) Write a program that inputs an ASCII code and prints the corresponding character. Modify this program so that it generates all possible three- digit codes in the range 000–255 and attempts to print the corresponding characters. What happens when this program is run?

What will be an ideal response?


```
// Printing ASCII characters based on codes entered by the user.
#include
using namespace std;

int main()
{
int c;

cout << "Enter an ASCII character code (-1 to end): ";
cin >> c;

// loop until user enters -1
while ( c != -1 )
{
if ( c >= 0 && c <= 255 )
cout << "The corresponding character is '"
<< static_cast< char > ( c ) << "\'\n";
else
cout << "Invalid character code\n";

// ask for another character
cout << "\nEnter an ASCII character code (-1 to end): ";
cin >> c;
} // end while

return 0;
} // end main
```
Enter an ASCII character code (-1 to end): 44
The corresponding character is ','
Enter an ASCII character code (-1 to end): 77
The corresponding character is 'M'
Enter an ASCII character code (-1 to end): 26
The corresponding character is '?'
Enter an ASCII character code (-1 to end): 0
The corresponding character is ' '
Enter an ASCII character code (-1 to end): -1

Computer Science & Information Technology

You might also like to view...

Which of the following are the correct preprocessor commands necessary to prevent multiple inclusions of header files? If there is an answer here that works to prevent multiple inclusion, carefully describe how it works in the explanation.

a. #include “header.h” b. #define HEADER_H #ifndef HEADER_H //declarations for header.h go here #endif c. #ifndef HEADER_H #define HEADER_H // declarations for header.h go here #endif d. #ifndef HEADER_H //declarations for header.h go here #endif

Computer Science & Information Technology

A(n) ____ is a small blotch of irregular color left behind when converting a JPEG image from RGB to LAB color.

a. spot b. interpolation c. artifact d. blemish

Computer Science & Information Technology

Page headers and footers can be changed in this view

A) Print preview B) Normal view C) Page Layout view

Computer Science & Information Technology

A color with 0 percent ____ is gray.

a. saturation b. hue c. brightness d. contrast

Computer Science & Information Technology