Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

**NOTE: The program should be written in (C programming language), please show t

ID: 3837407 • Letter: #

Question

**NOTE: The program should be written in (C programming language), please show the result for good rate, The code that you need to edit will be under the picture.

HERE IS THE CODE THAT NEEDS TO BE EDITED:

#include <stdio.h>

void main(){

   int j=0,i=0;

   FILE *in,*out;

   in=fopen("c://test_c/BMI.c","r");

   out=fopen("c://test_c/BMI_n.c","w");

   char o[100]={''};

   do {

      o[i++]=(fgetc(in));

      if (o[i-1]==' ' )

       {

         o[i]='';

           fprintf(out,"%-.3d: %s",++j,o);

            i=0;

      }

   } while (o[i-1]!=EOF);

   fclose(in);

   fclose(out);

}

In this project, you are asked to write a program which can open a text file, read its content and count the number of each alphabetic character regardless of its case. It means that program needs to count for example how many letter of 'A' or 'a' are in the text file. The counting is for all alphabetic characters; thus, all other characters such as numbers and punctuation characters should be excluded. The output of the program should be formatted in two columns as: Note: for now you can write the program and test it on any text file and my suggestion is that you create your own text file, where you can have some pre-determine number of characters. For Submission, Should run the program using the source code of project #1 that l posted on iLearn.

Explanation / Answer

#include <stdio.h>

void main(){

     FILE *in,*out;

     in=fopen("read.txt","r");
    out=fopen("out.txt","w");

  
   if(in == NULL)
   {
      printf("Error!");
      exit(1);           
   }


    int a[255]={0};
     char c;
     //reading
   while(1)
   {
          
           c=(char)fgetc(in);
           if(c==EOF)break;
           a[c]=a[c]+1;//finding frequency...
           //printf("%c",c);
   }


   fclose(in);
  
  
   int i=65,k=97;
   //writing..
   for(;i<(65+26);i++,k++)
   {
       fprintf(out,"%c    %d ",i,a[i]+a[k]);
   }
   
    fclose(out);
   
   

}

input file:

alsdkf eoajfanslks
asdjalsd fja
asdflasdkf jas
sadfjlkadf

output file:-

A    11
B    0
C    0
D    7
E    1
F    7
G    0
H    0
I    0
J    5
K    4
L    5
M    0
N    1
O    1
P    0
Q    0
R    0
S    9
T    0
U    0
V    0
W    0
X    0
Y    0
Z    0