#include // functies void macht(int Getal1, int Getal2); void main() { int grondtal, exponent; cout << "grondtal :\t"; cin >> grondtal ; cout << "exponent : \t"; cin >> exponent; macht(grondtal,exponent); cout << endl; } void macht (int Getal1, int Getal2) { int resultaat = 1; //anders is resultaat altijd 0 (vermenigvuldig met 0) //macht 0 : loop wordt niet uitgevoerd, resultaat = 1 if (Getal2 >= 0) { for (int i = 1; i <= Getal2; i++) { resultaat = resultaat * Getal1; } } else { // oplossing voor macht tot negatief getal ? cout << "negatieve exponent.Niet voorzien. Sorry. "; }; cout << endl << Getal1 << " ^" << Getal2 << " = " << resultaat; }