C++ Programming Code Examples C++ > Strings Code Examples C++ Programming Code to Find Frequency of Character in String C++ Programming Code to Find Frequency of Character in String To find the frequency of character or count occurrence of character in string in C++ programming, you have to ask to the user to enter the string, again ask to enter the character to find the frequency of that character (or to count the occurrence of character) in given string. After finding the frequency of the character, display the result on the output screen as shown here in the following program. Following C++ program ask to the user to enter a string and a character to find the frequency of the entered character in the string : #include<iostream.h> #include<conio.h> #include<stdlib.h> void main() { clrscr(); int i, count=0; char str[1000], ch; cout<<"Enter the String : "; gets(str); cout<<"Enter a character to find frequency : "; cin>>ch; for(i=0; str[i]!='\0'; i++) { if(ch==str[i]) { count++; } } cout<<"Frequency of the character "<<ch<<" = "<<count; getch(); }