Question: Write templated functions to perform math on varying numeric data types. Use a source code management tool as you develop this program. Commit changes frequently
Write templated functions to perform math on varying numeric data types.
Use a source code management tool as you develop this program. Commit changes frequently using descriptive commit messages. Push your changes to GitHub or other publicly accessible location for your instructor to clone.
Requirements
Read the tips in the next section.
Define functions named "half" that accept a single argument, and return a value of that same type.
For floatingpoint types float double return half of the value passed in as argument.
For integer types int return half the value, rounded according to usual rounding rules or higher, round up; otherwise round down.
Build a driver in main to test these functions and display their output.
Functions must pass parameters and return values as needed, using only local variables. Global variables are not allowed.
Use comments to document your program as you see fit. Include comments at the beginning of your program with your name, the class with section and the date.
Josh Junior
CIS
January
Submit the URL for your repository to the dropbox. No screen shots are needed.
Sample Output
Tips
In C templates can use generic types, explicit types, or both.
For the case of double and float, write a templated function. For integers, explicitly specify the type.
In C the round function expects a floatingpoint type. Use staticcast to convert the argument in the case of integers.
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
