I've come here for confirmation. The question is in two parts, I've done the first part (calculate exponent) and I've attempted the second part (calculate sine). I don't know what a sine is, as I haven't reached that part in my school maths, so I googled a quick formula.
Here is the question: For the second function you will compute the sine of an angle. Your function should accept the opposite and hypotenuse lengths and return the sine value.
Have I done the second part correctly (calculate sine)? This is how the formula should work to calculate sine right?
The logic is right but double or float instead of int is required for all the variables involved, perhaps with the exception of opp, but I wouldn't bother.
(For a 3,4, 5 right angle triangle, the sine of the smaller acute angle is 3/5 = 0.6. If you use ints then sine = 0 because of integer division has no fractional part)
Be careful with line 2. Both pow and sin exist in the std namespace, the minute you #include <cmath> , you will have a problem, well not a problem - just that you will call the library functions not yours. The best thing is to avoid line altogether, and put std:: before each std thing.
As I explained in one of you other Topics, you have an overlap with your logic on lines 6 and 15, although it doesn't matter here make a difference to the answer, avoid doing that, the code from line 15 to 18 is unreachable. Change line 6 to be >= 1
And the other warning. Warnings are there for a reason, ignore them at your peril.
In function 'int pow(int, unsigned int)':
8:15: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
11:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]