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

Write a program (a filter) that reads a stream of ASCII from standard input and

ID: 3623970 • Letter: W

Question

Write a program (a filter) that reads a stream of ASCII from standard input and sends
characters to standard output. The program discards all whitespace and punctuation
and sends to standard output only letters A-Z. Any lowercase character is output as an
uppercase character. Separate groups of five output characters with a space character,
and output a newline character after every 10 groups. (The last group on a line is
followed only by newline; the first group on a line does not have a space in front of it.)
The very last group may have fewer than five characters, and the last line may have
fewer than 10 groups. For example, the input stream
It began one day in summer about thirty
years ago, and it happened
to four children.
Jane was the oldest and Mark
was the only boy,
and between them they ran everything. Katharine
was the middle girl, of docile disposition
and a comfort to her mother.
is output as
ITBEG ANONE DAYIN SUMME RABOU TTHIR TYYEA RSAGO ANDIT HAPPE
NEDTO FOURC HILDR ENJAN EWAST HEOLD ESTAN DMARK WASTH EONLY
BOYAN DBETW EENTH EMTHE YRANE VERYT INGKA THARI NEWAS THEMI
DDLEG IRLOF DICIL EDISP OSITI ONAND ACOMF ORTTO HERMO THER
Assume that the input file is a text file of arbitrary length. Use getchar() and
putchar() for this. You will never need to have more than one character of input data
in memory at one time.

Explanation / Answer

please rate - thanks

remember due to the constraints you've been given this must run from DOS with redirection

#include <stdio.h>
int main()
{int chars=0,line=0;
char ch;
while((ch= getchar())!= EOF)
   {
    if(isalpha(ch))
        {putchar(toupper(ch));
         chars++;
         if(chars==5)
             {putchar(' ');
              chars=0;
              line++;
              if(line==10)
                  {printf(" ");
                  line=0;
                  }
              }
          }
      }  
return 0;
       
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote