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

Programming Project: Turn in your program for this problem to Blackboard by the

ID: 3850133 • Letter: P

Question

Programming Project: Turn in your program for this problem to Blackboard by the due date. 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 '' and 'n' 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 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

SOURCE CODE:

#include <stdio.h>
#include <stdlib.h>

int main()
{
int i;
char c[40];
while(1!=0)
{
printf("Enter line");
scanf("%s",c);//This will work properly in linux.
for(i=0;i<40;i++)//Prints 40 characters to the screen
{

if(c[i]==' ') {printf(" "); i++;}// is used to escape the .
else if(c[i]==' ') {printf("\t"); i++;}
else printf("%c",c[i]);//The program will terminate if user presses ctrl+z in linux
}
}

}