C program to find frequency of characters in given text

Given a text file, write a C program to find

  • frequency of characters
     
  • Number of words having each character
     
  • Total number of words in the file and
     
  • Special characters present in the file.


 

C

 

Input (input.txt):

BURNS- are the damage to tissue caused by their exposure
to thermal, chemical, electrical, radiation energy.

Output (output.txt):

character    frequency     word frequency
A                 1                 1
B                 5                 3
C                 3                 3
D                14                11
F                 2                 2
G                 4                 4
H                 6                 5
K                 4                 3
L                 3                 3
M                 2                 2
N                 4                 4
O                 1                 1
Q                 7                 7
R                 4                 3
S                 8                 8
T                 3                 3
W                 1                 1
X                 2                 2
i                 1                 1
1                 1                 1
2                 1                 1
4                 1                 1

Special characters –

!                 1
–                 1
@                 9
^                 1

Total no. of Special characters are 12

Total no. of words are 16

 
Thanks for reading.




Please use ideone or C++ Shell or any other online compiler link to post code in comments.
Like us? Please spread the word and help us grow. Happy coding 🙂