Quick actions

cmd+k|ctrl+k

Navigation

Languages

counting letters in string

Snippet info

Language

Cpp

Visibility

public

Author

ganesh26

Created

2020-06-23T10:59:05Z

Updated

2020-06-23T10:59:41Z

#include <iostream>
using namespace std;

int main() {
    cout << "Hello World!" << endl ;
    string str ;
    std :: string :: iterator it ;
    getline(cin , str);
    
    int i = str.length() ;
    int count = 0 ;
    cout <<"enterd string is : "  << str << endl <<  "length of string is : " << i << endl ;
    
    for(it = str.begin() ; it != str.end() ; ++it)
    {
        if( *it == 'p')
          {
              count = count + 1;
          }
    }
    cout << " number of times " << " letter occurs is " << count << endl ;
    return 0;
}
INFO