Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created October 10, 2021 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/955edd783a7c5e85541ad2ba93b2423e to your computer and use it in GitHub Desktop.
Save amankharwal/955edd783a7c5e85541ad2ba93b2423e to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
using namespace std;
int main(){
int count = 0;
char input;
string word;
cout<<"Enter a Word: ";
cin>>word;
cout<<"Enter a Character That You Want to Count: ";
cin>>input;
for(int i = 0; i < word.size(); i++){
if (word.at(i) == input){
count++;
}
}
cout<<count<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment