Question #210899

Design a C program to find the Frequency of Characters. The string entered by the user is stored in variable str. Then, the user is asked to enter the character whose frequency is to be found and display.


Expert's answer

#include <stdio.h>
#include <string.h>




int main(){
	char str[1000];
	char character;
	int frequency=0;
	int i;
	printf("Ente string: ");
	gets(str);
	printf("Enter the character whose frequency is to be found: ");
	scanf("%c",&character);
	for(i=0;i<strlen(str);i++){
		if(character==str[i]){
			frequency++;
		}
	}
	printf("Frequency: %d\n\n",frequency);


	getchar();
	getchar();
	return 0;
}





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS