Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the following C++ programming questions: 1. Print the numbers 33 to 126

ID: 3834983 • Letter: C

Question

Complete the following C++ programming questions:

1.

Print the numbers 33 to 126 and their corresponding ASCII character values.

required output:

2. Prompt the user for a string. Output the length of the string.

Required output:

Test Case 2

Test Case 3

3.Prompt the user for a string. Output the string in reverse.

required output:

4.Prompt the user for a line of text. Output that line in all capitals. Leave non-alphabetic characters untouched.

required output:

Test Case 2

Test Case 3

Test Case 4

5.Prompt the user for two strings, s1 and s2. Determine if s1 and s2 are equal. If they're not equal, output them in alphabetical order.

Required output:

Test Case 2

Test Case 3

Test Case 4

Test Case 5

Test Case 6

Test Case 7

Test Case 8

Test Case 9

6.Prompt the user for his/her name. Verify that the name only contains alphabetic characters.

Required output:

Test Case 1

Test Case 2

Test Case 3

Test Case 4

Test Case 5

Test Case 6

Test Case 7

Test Case 8

7.Prompt the user for a social security number. Determine if the SSN is in the correct format.

required output:

8.Determine if a word entered by the user is spelled correctly. A word is considered correct if it's found in dict.txt (see required output to get file).

Required output:

dict.txt


  a  

Explanation / Answer

#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main()
{
// 1
for(int i = 33; i <= 126; i++)
{
char c = i;
cout << i << " " << c << endl;
}
  
string str;
  
//2
cout << "Enter a word: " << endl;
cin >> str;
cout << "Charcter count: " << str.length() << "." << endl;
  
// 3
cout << "Enter some word: " << endl;
cin >> str;
for(int i = str.length()-1; i >= 0; i--)
{
cout << str[i];
}
cout << endl;
  
// 4
cout << "Enter a line of text" <<endl;
cin.ignore();
getline(cin, str);
for(int i = 0; i < str.length(); i++)
{
if(isalpha(str[i]))
{
str[i] = toupper(str[i]);
}
cout << str[i];
}
cout << endl;
return 0;
}