C program to find frequency of each character in a text
file?
Answer Posted / vadivel
#include <stdio.h>
int count[26];
int main()
{
FILE *f;
int i;
char ch;
f = fopen("capti.c","r");
while(!feof(f))
{
ch = fgetc(f);
count[ch - 'a']++;
}
for(i = 0;i < 26;i++)
printf("count[%c] = %d\n",65+i,count[i]);
fclose(f);
return 0;
}
//asuming only lower characters are required
| Is This Answer Correct ? | 38 Yes | 23 No |
Post New Answer View All Answers
What is the maximum no. of arguments that can be given in a command line in C.?
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }
What is %g in c?
How are Structure passing and returning implemented by the complier?
Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?
Why we use break in c?
What is the advantage of c?
How are portions of a program disabled in demo versions?
Describe dynamic data structure in c programming language?
Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant
How to delete a node from linked list w/o using collectons?
Explain what is a pragma?
Explain the term printf() and scanf() used in c language?
What is c programing language?