Answer to Question #203059 in C++ for Skye Jordan

Question #203059

Write a program that accept the string, removes all empty space in the string, and replace all character ‘a’ to ‘A’ by display a new string. The program needs to write using array.

*Refer the output below:

Type your Story:

aminah works as a medical assistant at HRPB. She performed her duties as a dedicated frontliner throughout the covid19 outbreak. #stayathome. #staysafe.

Display a new string:

AminahworksAsAmedicalAssistantAtHRPB.SheperformedherdutiesAsAdedicAted frontlinerthroughoutthecovid19outbreAk.#stAyAthome.#stAysAfe.


1
Expert's answer
2021-06-05T02:12:47-0400
#include <iostream>
#include <cctype>
using namespace std;

int main()
{
    const int N=4096;
    char str[N];
    char ch;
    int i=0;

    cout << "Type your Story:" << endl;
    while (i<N-1 && cin) {
        cin >> ch;
        if (iswspace(ch)) {
            continue;
        }
        if (ch == 'a') {
            ch = 'A';
        }
        str[i++] = ch;
    }
    str[--i] = '\0';


    cout << "A new string:" << endl;
    cout << str << endl;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog