Answer to Question #210899 in C for genji 4

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.


1
Expert's answer
2021-06-29T00:10:52-0400
#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS