Write a program that prompts the user to enter a string and then prompts the
user to enter a character.The program should display the number of times the
character occurs in the string.
int main() { string str; char ch; int amount = 0; cout<<"Enter the string : "; getline(cin, str); cout<<"Enter the character to find : "; cin>>ch; for (int i = 0; i < str.size(); i++) if(str[i] == ch) amount++; cout<<"This character occurs in this string "<< amount <<" time(s)"<<endl;
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment