Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program that evaluates the equations provided below. The program must prompt the user for inputs to each equation and evaluate each based

image text in transcribed
image text in transcribed
Write a C program that evaluates the equations provided below. The program must prompt the user for inputs to each equation and evaluate each based on the inputs. All variables on the right hand sides of the equations must be input by the user. All variables, except for R1, R2, R3, and variable o (phi, equation 6) are floating-point values. R1, R2, R3, and o variables are integers. The constants used in the equations must be defined as constant macros (preprocessor # defined constants). You do not need to check for faulty user input or dividing by zero for this assignment. 1. Area of a rectangle: Area = a*b (note: a and b are the lengths of the two sides of a rectangle.) 2. Volume of a cylinder: cylinder volume = PI radius? * height 3. Total parallel resistive load: parallel resistance = 1/(1/R1+1/R2 + 1/R3), for 3 resistors. R1, R2, and R3 are integers. (Note: you will need to type cast the division results or data will be lost). 5. Distance between two points: distance - square root of ((x - x2)+(y1 - y2)) (note: you will need to use the sqrt() function from which is covered in Lecture 5) 4. Pythagorean Theorem: e-sqaure root of (a+b) (note: c is the hypotenuse of a right triangle, a and b are the perpendicular sides. should be used for the sqrt function once more here. Make sure to get new values from the user for a and b) 6. General equation: -# (3/4)+b+ (%2) a (recall: o is an integer, the 3 and 4 constants in the equation should be left as integers initially, but explicitly type-casted as floating-point values) For this assignment you are required to define the functions provided below. These can also be used as your required function prototypes at the top of your program after the preprocessor directives: double calculate_area of rectangle (double a double b) double calculate cylinder_volume (double radius, double height) double calculate parallel resistance (int rl, int r2, int r3) double calculate_hypotenuse (double a double b) double calculate distance between 2pts (double xl, double x2. double y, double y2) double calculate general equation (int phi, double a, double b) A function must be defined for each of the above function prototypes. The task that is performed by each function corresponds directly to the equations defined on the first page. For example, the calculate cylinder volume () function should evaluate the equation defined as "Pl* radius "height" and return the resultant volume. You must print the results to the hundredths place. Also, the functions listed above should not prompt the user for inputs, nor display the result. Prompts and displaying results should be performed in main() or in separate "get" or "display functions instead

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_2

Step: 3

blur-text-image_3

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 DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

Evaluate each exponential. 64 3/2

Answered: 1 week ago

Question

How does the concept of hegemony relate to culture?

Answered: 1 week ago