1 write a programthat reads a file data txt shown below character bycharacter it the 5347018

1) Write a programthat reads a file data.txt shown below character bycharacter. It then displays the number of digits, smallletters, capital letters, and other characters as shown in theoutput of the program.

Note : Thedigits are represented internally by integer numbers forming aninterval with increasing numbers from ‘0’ to‘9’.   Thus any digit belongs to the interval[‘0’,’9’]. Don’t use the codesin the condition checking; use the characters themselves. Thesame applies for letters i.e. a small letter belongs to theinterval [‘a’,’z’], and a capital letterbelongs to the interval [‘A’,’Z’]. Ifyou don’t take care of checking new line character, you willget 13 for the number of other characters.


# this is my try , i don not know what is wrong with it :

#include

#include

int main(void) {

   int ndigit , ncapital , nsmall , nother ;

   char text ;

   FILE *infile, *outfile;

   infile = fopen(“data.txt”,”r”);

   outfile = fopen(“summary.txt”,”w”);

    while( text != 0 )

    {

   fscanf(infile, “%c”, &text);

   if ( text >='A' && text

   ncapital++ ;

   else if ( text >='a' && text

   nsmall++ ;

    else if ( text >='0' && text

   ndigit++ ;

   else nother++ ;

    }

   fprintf(outfile, “number of digits = %d nnumberof capital character = %d nnumber of small character = %d nnumberof other character = %d”, ndigit , ncapital , nsmall , nother);

   fclose(infile);

   fclose(outfile);

  

   system(“pause”);

   return (0);

}

waiting

"Get 15% discount on your first 3 orders with us"
Use the following coupon
FIRST15

Order Now