Need to write code in C++, will give question and example below. I do use visual studio 2022 if you are wondering. Thank you.
Problem:
Given the following input:
A character value (a letter from the English alphabet)
A string value (string consisting of only English letters and spaces)
Write a C++ program using functions to print the numbers of times the character appears in the string. The character to check in the string is case-sensitive (i.e. checking for an uppercase ‘A’ in the string is not the same as checking for a lowercase ‘a’).
Your solution must follow the requirements presented below:
Do not use cout to print a message before reading the input from STDIN.
Read the input in the main function. Note that the string may contain spaces.
Write a function that returns the number of times the character appears in the string.
You can assume that the input from STDIN will always be valid.
Example:
Input
Output
C Computer Science
1
a apple banana
4
F functions are fun
0
D qwertyuiopasdfghjklzxcvbnm
0
#include
#include
using namespace std;
// Write a function that returns the number of times the character appears in the string.
int main()
{
char myChar;
string myString;
int result;
// Read in the character and assign it to myChar
// Read in the string. Note that the string may contain spaces.
// Call the function.
result =
cout << endl <<“Number of times the character appears in the string = “ << result << endl; return 0; }
Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount