1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Galina-37 [17]
3 years ago
9

Print "Censored" if userInput contains the word "darn", else print userInput. End with a newline. Ex: If userInput is "That darn

cat.", then output is: Censored Ex: If userInput is "Dang, that was scary!", then output is: Dang, that was scary! Note: If the submitted code has out-of-range access, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message.
#include
#include
using namespace std;
int main() {
string userInput;
getline(cin, userInput);
/* Your solution goes here */
return 0;
}
Computers and Technology
1 answer:
Gemiola [76]3 years ago
6 0

Answer:

<em>The program goes as follows</em>

<em>Comments are used to explain difficult lines</em>

#include <iostream>

#include <string>

using namespace std;

int main()

{

string userinput;

getline(cin,userinput);

/* My Solution starts here*/

//Initialize sub string position to 0

int stringpos = 0;

// Declare an iterating variable to iterate through userinput

int startpos;  

//Declare and initialize a determinant variable

int k = 0;

while((startpos = userinput.find("darn",stringpos))!=string::npos)

{

 //If userinput contaings "darn", increase k by 1

k++;

// Go to next string position

stringpos = startpos+1;  

}

//If determinant variable k is p then, userinput does not contain "darn"

if(k==0)

{

 cout<<userinput;

}

//Otherwise, it contains "darn"

else

{

 cout<<"Censored";

}

/* My Solution ends here*/

return 0;

}

See attached for .cpp program file

Download cpp
You might be interested in
Repeated execution of a set of programming statements is called repetitive execution.
Korolek [52]

Answer:

False

Explanation:

6 0
2 years ago
it says i have brainly plus subscripton but whenever i log onto brainly using my laptop, it says i don't have brainly plus and w
Sladkaya [172]

Answer:

Explanation:

I think you can try logging out from your account. Try cancelling your subscription. Before you do that, reach out to Brainly support.

4 0
3 years ago
Free coins who is octane and dont say u dont know because i will do the same to u
mart [117]

Answer:

Thank you for the free points.

8 0
3 years ago
Read 2 more answers
HELP I WILL GIVVE BRAINLY AND 15 POINTS
levacccp [35]

Answer:

Because someone was hittting the space bar in the message instead of typing letters and numbers

Explanation:

Because they were bored or it was a glitch

4 0
3 years ago
Which of the following describes a Trojan horse?
HACTEHA [7]

Answer:

the answer is

c. Trojan horses enter a secure space, while an infected file proceeds to be downloaded and run.

7 0
3 years ago
Other questions:
  • The maximum number of colors that should be used on a slide is _____. 2 4 6 8
    12·2 answers
  • What concerns do you need to have with individuals hacking your information, computer, personal devices, and car? How can you pr
    5·1 answer
  • For a loop counter, the appropriate data type would be:
    14·1 answer
  • Ok, so this isn't a tech question it's about a game, moomoo.io so don't hate on this if you don't know it, 40 points to whoever
    12·2 answers
  • When using a wireless mouse, what is the most common port used for the transmitter? 
    7·1 answer
  • The syntax used for referencing cells with their worksheet names is the sheet name, followed by ____, then the usual column lett
    8·1 answer
  • The calls radioed to patrol officers, or assignments given to police patrol units by 911 dispatchers, reveal the types of proble
    9·1 answer
  • What are advantages of using document templates?
    13·2 answers
  • I need help picture above
    14·2 answers
  • 70 point Brainlist to best answer
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!