70.5k views
0 votes
Write a complete program that copies each character that is input from the keyboard and prints it to the screen, with the following three exceptions. (1) 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. The newline is not printed to the screen. What value/values does scanf( ) get from the keyboard when the user hits the Enter key? (2) when the user enters cntrl-Z the program terminates

User Johnkol
by
5.2k points

1 Answer

7 votes

Answer:

program:

#include<stdio.h>

#include<string.h>

int main()

{

char character;

int count =0;

int i;

while (1)

{

while((character=getchar())!='^z')

{

if (character=='\\')

{

printf("\/n");

}

else

printf("%c",character);

}

break;

}

}

Output:

Write a complete program that copies each character that is input from the keyboard-example-1
User Juusaw
by
5.9k points