Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is C++:D Could you please be kind enough and show me the your work by using

ID: 3712297 • Letter: T

Question

This is C++:D

Could you please be kind enough and show me the your work by using Visual Studio and type the code?

Thank you and have a good one!

Write a full program (starting from #include) that asks the user to

enter a phrase and then a single letter. The program should then report how many times

that letter occurred in the phrase, displaying the letter with double quotes around it. An

example is shown below where the user searched for lower-case "g".

Enter phrase: I love programming languages!

Enter letter: g

The letter "g" occurred 4 times.

Your program does not have to check upper versus lower case.

Solution: (Paste your code below)

Explanation / Answer

#include <iostream>

using namespace std;

int main()
{
string s;
char ch;
cout << "Enter phrase:" << endl;
getline(cin, s);
cout<<"Enter letter: "<<endl;
cin >> ch;
int count = 0;
for(int i=0;i<s.length();i++) {
if(s[i] == ch) {
count++;
}
}
cout<<"The letter "<<ch<<" occurred "<<count<<" times."<<endl;
return 0;
}

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote