Created
March 22, 2022 13:36
-
-
Save thomasw-mitutoyo-ctl/acf8e4c4c1a098d7fd1fa34011174558 to your computer and use it in GitHub Desktop.
Programmiere eine Funktion, die das gleiche Ergebnis liefert wie math.pow(), jedoch nur für Zahlen in N0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
print(pow(2,3)); | |
print(pow(2,4)); | |
print(pow(3,3)); | |
print(pow(2,0)); | |
} | |
int pow(int basis, int exponent) | |
{ | |
int ergebnis = 1; | |
for (int i=0; i<exponent; i++) | |
{ | |
ergebnis *= basis; | |
} | |
return ergebnis; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment