Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Programming This program takes a stream of text (strings) and formats the text into a set of lines with a specific width. However, rather

C Programming

This program takes a stream of text (strings) and formats the text into a set of lines with a specific width. However, rather than just do the standard left-justified text that you see in this paragraph, we take the approach used by Leonardo Di Vinci and generate a mirror output of the text. That is, we print the text from right-to-left rather than left-to-right. The program prompts the user for the length of an output line. The program then uses this as the width of all output lines. We right justify each line, as this is a true mirror of a standard leftjustified paragraph. We cannot do a true mirror of the text, as we do not have the ability to change the direction of our letters. We cannot generate instead of e (and so on). So we will just print the text out backwards.

As an example, consider the input: The quick brown fox jumps over the lazy old dog. This text, written backwards, is .god dlo yzal eht revo spmuj xof nworb kciuq ehT

Two sample executions of the program are shown below. The bottom row (black numbers) is added to show you there are that many columns, you do not have to generate that line of numbers as part of your output. Note that all lines are right-justified.

image text in transcribed

Two quick comments on this program:

First, you will never have a case where a single word (string of text) in the input is longer than the size of the output line specified by the user.

Second, the longest output line that a user can specify is 100 characters in length. The smallest output line that can be specified is 10 characters in length

In mirror.c, write the code needed to implement this program. Make sure that you:

o Include a header block of comments with your name and a brief overview of the program. o Prompt the user for the width of your output line.

o Read the users text (a set of strings) from standard input until the end-of-file, printing the mirrored words in lines of width characters

./a.out Enter the output line length: 25 . /a.out Enter the output line length: 10 Enter your text (control-d to exit) Enter your text (control-d to exit) The quick brown fox jumps over the The quick brown fox jumps over the lazy old dog lazy old dog kciuq ehT xof nworb revo spmuj yzal eht spmuj xof nworb kciug ehT .god dlo yzal eht revo 1234567890 1234567890123456789012345

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Question What are the advantages of a written bonus plan?

Answered: 1 week ago