Computer Science, asked by dragonride1, 1 year ago

Plzzzz help !!!!

consider max. limit of letters as 15 for input string.

^^ The output string should not display any other characters/numbers or any message except the output string

Attachments:

Answers

Answered by siddhartharao77
6

In simple, your question is to find frequency of character.

Here is a sample program to find frequency of character:

#include<stdio.h>

#include<string.h>

int main()

{

char str[50];

int a[256] = {0},i;

printf("Enter any string: ");

scanf("%s", &str);

for(i = 0; str[i] != '\0'; i++)

{

a[str[i]]++;

}

printf("\n The frequency of characters are: \n");

for(i=0; i<256; i++)

{

if(a[i] != 0)

{

printf("\n%d %c", a[i], i);

}

}

return 0;

}



Output:

Enter any string: aaabbccdddd

The frequency of characters are:

3 a

2 b

2 c

4 d.



Hope it helps!   ---------- > Good Luck!


dragonride1: array elment with corresponding value
siddhartharao77: we print till null character.. '\0'
siddhartharao77: For every character we increment ---- > a[str[i]]++;
dragonride1: means a[str[i]]++ right ?
siddhartharao77: yes..it is
dragonride1: ha yes
dragonride1: thank you again
dragonride1: in case of any orher prigram please help me out
siddhartharao77: You should have minimum knowledge on it.. Please try to refer some C programming books and start practicing.. Bye!
dragonride1: ok
Similar questions