Frequency of Characters Integers File Handling coderinme

Frequency of Characters Integers File Handling coderinme

Frequency of Characters Integers File Handling coderinme
Write an interactive C program to read a text file and display the following:
(i) Frequency table of all the alphabetic characters.
(ii)Number of numeric characters present in the file.
Here we first create an input text file named “Frequency.txt”. Add some text in this input file . Then run the below program in order to get the required output

#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
FILE *inpt;
int j,count,x=0, i=0;
int count2=0;
char s[1000],c;
inpt=fopen("Frequency.txt","a+");
do
{
c = fgetc(inpt);
s[i]=c;
i++;
}
while (c != EOF);
s[i] = '\0';
for(i=0;i<strlen(s);i++)
{
if(isdigit(s[i]))
{
count2++;
}
}
printf("\nCHAR FREQUENCY\n");
for(i=0;i<strlen(s);i++)
{
if(isalpha(s[i]))
{
if(s[i]=='9')
continue;
count=0;
for(j=0;j<strlen(s);j++)
{
if((s[j])==(s[i]) && i!=j)
{
count++;
s[j]='9';
}
}
printf(" %c %d\n",s[i],count+1);
}
}
printf("\nNumber of Integers%d\n",count2);
getch();
return 0;
}

For more programs in C, visit our C Coder Archives

Frequency of Characters Integers File Handling coderinme

Frequency of Characters Integers File Handling coderinme

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.