Question: Hello, I need help solving this Lab simulation, It uses remove spaces for loops statements and I am very new at coding on so I

Hello, I need help solving this Lab simulation, It uses remove spaces for loops statements and I am very new at coding on so I need help solving it. It is very difficult. It is very confusing since the there are multiple inputs and on can only code it once.

A program that removes all spaces from the given input. If the input is "Hello my name is John." the output is "HellomynameisJohn."

try these inputs as well:

If the input is "This is a sentence." the output is "Thisisasentence."

If the input is "Look! Multiple spaces." the output is "Look!Multiplespaces."

If the input is "Look! Multiple spaces." the output is "Look!Multiplespaces."

If the input is "flying" the output is "flying"

but the problem is that you can only code one input, so you can only remove the spaces on one input but I need to remove all the spaces on each input in this lab simulation.

#include

using namespace std;

int main() {

/* your code here. */

return 0;

}

Here is a clue my friend in the class sent me

The following code will remove spaces from your input

Example:

if you type "This is a test"

your output will be:

Thisisatest

#include

#include

usingnamespacestd;

intmain() {

stringuserInput ="";

stringuserInputNoSpaces ="";

unsignedinti;

std::getline(cin, userInput);

for(i = 0; i < userInput.length(); ++i) {

if(!isspace(userInput.at(i))) {

userInputNoSpaces+=userInput.at(i);

}

}

cout<

return0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!