Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string text;
- char symbol;
- int counter = 0;
- cout << "Enter text: "<<endl;
- getline(cin, text);
- cout << "The number of times a symbol has appeared will be counted. Enter the symbol you want to check: "<<endl;
- cin >> symbol;
- for (int i = 0; i < text.length(); i++) {
- if (text[i] == symbol) {
- counter++;
- }
- }
- cout << "The symbol has appeared "<<counter<<" times!";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement