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
Is boolean a datatype in c?
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
What is p in text message?
#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }
Explain what is the benefit of using #define to declare a constant?
how to find binary of number?
When should a type cast be used?
If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above
What is function in c with example?
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above
Explain the meaning of keyword 'extern' in a function declaration.
What are dangling pointers? How are dangling pointers different from memory leaks?
What is linear search?
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
What is auto keyword in c?