Question

Text book used: C Primer Plus 6th Edition, Stephen Prata Create count_ch() that will count all...

Text book used: C Primer Plus 6th Edition, Stephen Prata

Create count_ch() that will count all alphanumeric characters, all whitespace characters and all punctuation entered until the user simulates end of file from the keyboard. Also provide a total of ALL characters regardless of type. At the end, you should display 4 totals. (Also, review pages 252-254) If you copy and paste jabberwocky.txt, press enter, and then input the EOF simulation, you should have the following results...

AlphaNumeric: 743, Punctuation: 44, WhiteSpace: 260, All: 1047

THIS WAS THE ATTACHED FILE CONVERTED INTO TEXT BELOW

Jabberwocky
BY LEWIS CARROLL
’Twas brillig, and the slithy toves
      Did gyre and gimble in the wabe:
All mimsy were the borogoves,
      And the mome raths outgrabe.

“Beware the Jabberwock, my son!
      The jaws that bite, the claws that catch!
Beware the Jubjub bird, and shun
      The frumious Bandersnatch!â€

He took his vorpal sword in hand;
      Long time the manxome foe he sought—
So rested he by the Tumtum tree
      And stood awhile in thought.

And, as in uffish thought he stood,
      The Jabberwock, with eyes of flame,
Came whiffling through the tulgey wood,
      And burbled as it came!

One, two! One, two! And through and through
      The vorpal blade went snicker-snack!
He left it dead, and with its head
      He went galumphing back.

“And hast thou slain the Jabberwock?
      Come to my arms, my beamish boy!
O frabjous day! Callooh! Callay!â€
      He chortled in his joy.

’Twas brillig, and the slithy toves
      Did gyre and gimble in the wabe:
All mimsy were the borogoves,
      And the mome raths outgrabe.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio>
# include <conio.h>
#include <Ctype.h>
int main()
{
void count_ch(); Il calling the function count_ch()
}
void count_ch()
{
int num, alphanum =0, pun=0, Space =0, All;
FILE * fptr,
If((fptr = fopen ("c:\\jabbencoocky.txt ","r")) =NULL)
{
printf ("Error in. opening file );

exit ();
}

fgets ( fptr ,sizeof fptr, stdin)/* checks each alphanumeric of string*/

while (fptr [i] != '\0')
{
If ((fptr[i] >= 'a' && fptr[i] <=' z') ||
(fptr[i] >= 'A' && fptr[i] <=' Z') ||
(fptr[i] >= '0' && fptr[i] <=' 9') )
{
Alphonum++;
}

//number of punctuations are calculated
else if (ispunct (fptr[i]))
{
pun++;
}
else if(fptr[i]==' ')
{
Il we calculate whitespace
space ++;
}
\\calculate sum of alphanum , pun , space
All = alphanum + pun + Space;
Printf("Alphanumeric: %d", alphanum);
printf (" Punctuation : %d, pun);
printf (" Whitespace : %d, space);
printf (" All: %d", All) ;
}

Add a comment
Know the answer?
Add Answer to:
Text book used: C Primer Plus 6th Edition, Stephen Prata Create count_ch() that will count all...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Language: C Write an encoder and a decoder for a modified "book cipher." A book cipher...

    Language: C Write an encoder and a decoder for a modified "book cipher." A book cipher uses a document or book as the cipher key, and the cipher itself uses numbers that reference the words within the text. For example, one of the Beale ciphers used an edition of The Declaration of Independence as the cipher key. The cipher you will write will use a pair of numbers corresponding to each letter in the text. The first number denotes the...

  • Language: C Write an encoder and a decoder for a modified "book cipher." A book cipher uses a doc...

    Language: C Write an encoder and a decoder for a modified "book cipher." A book cipher uses a document or book as the cipher key, and the cipher itself uses numbers that reference the words within the text. For example, one of the Beale ciphers used an edition of The Declaration of Independence as the cipher key. The cipher you will write will use a pair of numbers corresponding to each letter in the text. The first number denotes the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT