Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ please! Given an input line of text and two individual characters, count how many times the first character appears in the text and

In C++ please!

Given an input line of text and two individual characters, count how many times the first character appears in the text and replace each instance of the first character with the second character. The output should be the number of occurrences of the first character (first line), and the new text (second line). If the first character is not found then the text should not change.

sample input:

Harding University i 

sample output:

3 HardIng UnIversIty 

sample input:

I don't know what I don't know. ' 

sample output:

2 

sample input:

scud spud stud a 

sample output:

0

image text in transcribedimage text in transcribed

Chap9Lab3.cpp Load default 1 /* Given input text on the first line, and a character on the second line count how many times the characters appears in the line. */ 3 4 #include 5 #include //provides functions for a cstring 6 using namespace std; 7 8 int main() 9 { 10 char line[80]; char searchchar; char* linePtr = nullptr; int searchCounter = 0; 14 cin.getline(line, 80); 16 cin >> searchchar; 17 18 /* Put your algorithm here */ 19 20 //output how many times searchchar appears in line 11 12 13 15 cout

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago