Example 57: Angle Conversion
Learn how to convert an angle from degrees to radians and vice versa. Also, learn how to find the nearest odd/even number using macro definitions.
We'll cover the following
Problem
Write macro definitions for the following and use them in main()
:
- DEGREES: Converts radians into degrees
- RADIANS: Converts degrees into radians
- ODD: Rounds a number up to the nearest odd integer
- EVEN: Rounds a number up to the nearest even integer
Solution
Given below is our recommended way to approach this problem.
Get hands-on with 1400+ tech skills courses.