MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / power

Function power

Examples/NoModules/Appendix A/ExA_06/ExA_06.cpp:15–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13}
14
15double power(double x, int n) // A first definition
16{
17 if (n == 0) return 1.0;
18 else if (n > 0) return x * power(x, n - 1);
19 else /* n < 0 */ return 1.0 / power(x, -n);
20}
21
22double power(double x, int n); // Another redundant declaration (harmless)
23

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected