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

Write a complete program that copies each character that is input from the keybo

ID: 3849851 • Letter: W

Question

Write a complete program that copies each character that is input from the keyboard and prints it to the screen, with the following two exceptions. when the user hits the "Enter" key of the keyboard (newline) the two characters V and '' are printed to the screen with no space between them. when the user hits the "Tab" key of the keyboard (tab) the two characters '' and 't' are printed to the screen with no space between them when the user enters cntrl-Z the program terminates. Each line of the printout to the screen must be exactly 40 characters long (here: '' and 'n' constitute two characters of output.

Explanation / Answer

#include <stdio.h>

int main()
{

   char ch;
   char line[1000];
   int count =0;
   int i;
   while (1)
   {
       while((ch=getchar())!='^z')
       {
       if (ch==' ')
       {
           line[count]='\';
           line[count+1]='n';
           count+=2;
       }
           else
           {
           if (ch==' ')
           {
               line[count]='\';
               line[count+1]='t';              
               count+=2;
           }
       else
       {
           line[count]=ch;
           count++;  
       }
           }

           if(count==40)
           {
               count =0;

               for (i =0;i<40;i++)
                   printf("%c",line[i]);
               printf(" ");
           }
       }
   }

}

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