Question: Your task in C is to develop a program that compares two rectangles and prints out which rectangle is smaller. We assume two rectangles in
Your task in C is to develop a program that compares two rectangles and prints out which rectangle is smaller.
We assume two rectangles in a D plane. Each rectangle is fully described by its height and width. Widths and heights are decimal numbers greater than zero.
The program is given numbers in the input, these numbers describe widthsheights of the two input rectangles.
The output of the program is the result of the comparison. The program computes the area of the input rectangles and prints out the rectangle with the smaller area, or it answers that the two rectangles have the same area. The exact format of the output is shown below in the example runs.
If the input is invalid eg input values are not decimal numbers, are negative, or inconsistent the program detects the problem and prints an error message. The format of the error message is again shown below. The following is considered invalid input:
nonnumeric value,
invalid widthheight negative zero, missing
If the program detects an error, it immediately stops asking for further input data, it prints out the error message and terminates. Thus, the program must validate input data as it reads them. Do not postpone the checks until the entire input is read. The error message shall be printed on the standard output do not send it to the standard error output
Please strictly adhere the format of the output. The output must exactly match the output of the reference program. The comparison is done by a machine, the machine requires an exact match. If your program provides output different from the reference, the program is considered malfunctioning. Be very careful, the machine is sensitive event to whitespace characters spaces newlines, tabulators Please note that all output lines are followed by a newline character
This applies even to the last line of the output, moreover, this applies even to the error message. Download the enclosed archive. The archive contains a set of testing inputs and the expected outputs. Use the attached files to simplify the testing of your program.
Your program will be tested in a restricted environment. The testing environment limits running time and available memory. The exact time and memory limits are shown in the reference solution testing log However, neither time nor memory limit could cause a problem in this simple program.
Example program output:
Rectangle #:
Rectangle #:
The area is the same.
Rectangle #:
Rectangle #:
The area of rectangle # is smaller.
Rectangle #:
e
Rectangle #:
ee
The area of rectangle # is smaller.
Rectangle #:
Rectangle #:
The area is the same.
Rectangle #:
Rectangle #:
Invalid input.
Rectangle #:
abcd
Invalid input.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
