Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use C language. Extend your module: Extend your myMath module such that it includes a new function that calculates the hypotenuse (c) of a

Please use C language.

Extend your module: Extend your myMath module such that it includes a new function that calculates the hypotenuse (c) of a right-angle triangle given the other two sides of the triangle (a and b). An example of the Pythagorean theorem is given below.

image text in transcribed

The function for calculating c should take the form:

double pythag( int a, int b )

This function will accept two integers and treat them as the two sides (a, b) of a right-angle triangle and return the length (c) of the hypotenuse. To do so you will want to use the square root and maybe the power functions from the math.h library. The calculation for c is as follows:

image text in transcribed

Note that to use the functions in math.h you will need to include the compiler flag -lm at the end of your compile statement, so you will need to modify your makefile appropriately. Why?

Conditional compilation: To make this code more interesting, I want you to add an option via conditional compilation where, if debugging is turned on, then instead of using the pythag function, your main function uses macros to calculate the value for the hypotenuse (c) instead. To achieve this, you need to write macros that take parameters for ADD, SQRT, and POW. Build your code with conditional compilation so that when the -DDEBUG flag is used, then the three macros are used instead of the pythag function. Modify your makefile so that it has a debug target that turns on the -DDEBUG flag. When the -DDEBUG flag is turned on, the program should print out "In debugging mode..." as a part of the menu options.

hypotenuse C 9.43 a 5 b 8 8 2 c = Va+b

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

What is focal length? Explain with a diagram and give an example.

Answered: 1 week ago