Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C LANGUAGE 3. [50 pts] Complete the following function by writing C statements that correspond to the description in each comment in the code. Hinclude

C LANGUAGE

image text in transcribedimage text in transcribed

3. [50 pts] Complete the following function by writing C statements that correspond to the description in each comment in the code. Hinclude int main II Declare a floating point variable to store a rectangle's width II Declare a floating point variable to store a rectangle's length l Declare a third floating point variable that will store the area of the rectangle. II Prompt the user to enter a width for the rectangle. Il Get the user's input, and store it in your previously declared variable for width Il Prompt the user to enter a length for the rectangle. II Get the user's input, and store it in your previously declared variable for length II Using an if statement, print out "Error: invalid side length" if either length or width are Il less than or equal to O. ll El II Calculate the area of the rectangle as a product of length times width, and store the I/ result in your variable for storing the area. l Print "The area of a rectangle with sides and to the screen. II Replace , , and with the value of the associate variables. se. int main0 II Declare a floating point variable to store a rectangle's width I Declare a floating point variable to store a rectangle's length II Declare a third floating point variable that will store the area of the rectangle. Il Prompt the user to enter a width for the rectangle. II Get the user's input, and store it in your previously declared variable for width Prompt the user to enter a length for the rectangle II Get the user's input, and store it in your previously declared variable for length II Using an if statement, print out "Error: invalid side length" if either length or width are ll less than or equal to 0. II Else... II Calculate the area of the rectangle as a product of length times width, and store the II result in your variable for storing the area. Print "The area of a rectangle with sides and is to the screen Il Replace , , and with the value of the associate variables. II All floating point values should be printed out with 1 decimal place of precision. return 0

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

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

Find the principal value. Show details. (3 + 4i) 1/3

Answered: 1 week ago