Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

What are the two contingency leadership theory leadership styles?

Answered: 1 week ago