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

660 ft/min=_________ft/s 1 min = 60 sec
660 ft/min=_________ft/s 1 min = 60 sec
Why did America rely heavily on slaves during the colonial period?
125 pounds decreased by 4% is
A high-speed computer printer prints a page in 1/6 second. Using this printer, how long would it take to print 30 pages?
70 pennies decreased by 20% is
What is 0.4^-2 (0.4 to the power of -2)?
70 pennies decreased by 20% is
Why was white America so fascinated by Harlem in the 1920s
Bill made 5 gallons of fruit punch. If 1/4 of punch was cranberry juice, how much cranberry juice did he use?