paulrai238 paulrai238
  • 09-12-2021
  • Computers and Technology
contestada

Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in the string in c++

Respuesta :

Talanat
Talanat Talanat
  • 09-12-2021
#include
#include

using namespace std;

int CountCharacters(char userChar, string userString){
int result = 0;
for(int i = 0;i if(userString[i] == userChar){
result++;
}
}
return result;
}

int main(){
string userString;
char userChar;
cin>>userChar>>userString;
cout< return 0;
}
Answer Link

Otras preguntas

What is 10 times as much as 0.09
Write a decimal equation that has a product of 3.15 do not use one as a factor
what shortcut can you use to multiply tens by tens, such as 40x60"
The length of a rectangle is 5 feet more than twice the width. The perimeter is 130 feet. Find the dimensions.
How can I revive my old Spanish skills I once had two years ago. I want them because I really admire a language other than my own. Please answer if you read.
Honeybees produce 7 pounds of honey for every 1 pound of beeswax they produce. Use equivalent ratios to find how many pounds of honey are produced when 25 pound
The Buck Creek Fire Department served 250 dinners.A child's plate cost $5.50 and an adult's plate cost $9.00. A total of 1935 was collected.How many of each of
what will happen to the food web if all primary consumers became extinct?
Why did the Spanish and Portuguese launch voyages of exploration? A. They hoped to establish sea routes to the Indies to make profits from trade. B. They were l
How can you use an array to show the commutative property