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 difference between break and continue?
#include
Here is a good puzzle: how do you write a program which produces its own source code as output?
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers
What is integer constants?
What will the preprocessor do for a program?
Why is c so powerful?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
What is the difference between call by value and call by reference in c?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
What are pointers? Why are they used?
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
What is the collection of communication lines and routers called?
Can a pointer be null?
Write a program to reverse a string.