Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NOTE: PROGRAM MUST BE WRITTEN IN #C Write a program that uses two functions compute_area(l, w, h)and compute_volume(l, w, h)to compute the area and volume

NOTE: PROGRAM MUST BE WRITTEN IN #C

Write a program that uses two functions compute_area(l, w, h)and compute_volume(l, w, h)to compute the area and volume of a rectangular prism. The functions take as parameters the dimensions of the prism and return the area and volume. All parameters and return values should be integers. Your program should ask the user to enter the three dimensions length, width, height, then it calls the two functions and displays the results. Your program should verify that the user has entered a positive integer for all dimensions and should ask the user to enter the values again if a negative number is given. The program should function as follows (the items underlined are to be entered by the user): Enter the dimensions of the square prism (l, w, h): 1, 2, 3 The area of the prism is: 22 The volume of the prism is: 6 Algorithm design process 1.What variables are needed and what type? a. Variables to store the dimensions entered by the user b. The area and volume returned by the two functions 2. Write the main program: a. Print out the text to prompt the user, then use scanf to read the dimensions. Check that all dimensions are positive integers, ask the user to re-enter if not. b. Call function compute_area and then print out the value returned by the function. c. Call function compute_volume and then print out the value returned by the function.

3.Implement functions compute_area and compute_volume, placing their definitions after function main, and using prototypes to declare the functions at the beginning of the program. a. Define the input parameters and return value b. Any local variables needed? c. Inside the functions compute the area and volume of the prism based on the input parameters. Do not forget to return the computed values.

image text in transcribed

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

Logistics Lifeline Supply Chain Strategies

Authors: Ehsan Sheroy

1st Edition

7419377502, 978-7419377503

More Books

Students also viewed these Databases questions