Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Include the header file for
- //visual studio.
- #include "stdafx.h"
- //Include the header file.
- #include <iostream>
- using namespace std;
- //Define the main() function.
- int main()
- {
- //Declare the variables.
- int i;
- int lower_value, upper_value;
- bool loop_value = true;
- //Begin the for loop.
- while (loop_value)
- {
- //Prompt the user to enter the
- //lower_value and upper_value.
- cout << "Enter lower and upper values: " << endl;
- cin >> lower_value >> upper_value;
- //Check the input value to be valid.
- if ((lower_value<32 || lower_value>126))
- {
- //Display the statement.
- cout << "Values must be in range 32"
- << " to 126 inclusive \n";
- }//End of if condition.
- //Else if part.
- else if ((lower_value > upper_value))
- {
- //Display the statement.
- cout << "Lower value can't be greater"
- << "than Upper \n";
- }//End of else if condition.
- //Else part.
- else
- {
- //Update the loop_value to false.
- loop_value = false;
- }//End of else part.
- }//End of while loop.
- //Display the values with the statement.
- cout << "Characters for ASCII values between "
- << lower_value << " and " << upper_value;
- //Display the line.
- cout << "\n----+----+----+-\n";
- //Begin the for loop.
- for (i = lower_value; i <= upper_value; i++)
- {
- //Display the ASCII values.
- cout << (char)i;
- //Go to the new line after every 16
- //values.
- if ((i - lower_value + 1) % 16 == 0)
- {
- //Print the next line.
- cout << "\n";
- }//End of if condition.
- }//End of for loop.
- //Display the line.
- cout << "\n----+----+----+-\n";
- //Include the command to pause
- //the screen in visual studio.
- system("pause");
- //Return the value to the main() function.
- return 0;
- }//End of the main() function.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement