Rainrix2001

Counting the Letters

Aug 19th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.     int main () {
  5.         string ed;
  6.         char letter;
  7.         int izon, count = 0;
  8.         system("cls");
  9.         cout << "Problem 4 - Counting Letter" << endl;
  10.         cout << "--------------------------------\n";
  11.         cout << "Enter Text: ";
  12.         getline (cin, ed);
  13.         cout << "Letter to count: ";
  14.         cin >> letter;
  15.         izon = ed.length();
  16.  
  17.             while (izon>0){
  18.                 izon--;
  19.                 if (ed[izon]==letter){
  20.                     count++;
  21.             }
  22.  
  23.             }
  24.             cout << count << " Letter " << letter << "!" << endl;
  25.  
  26.     return 0;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment