From 66b907eac2aff6eb3229a86f4e223f1ad01313f6 Mon Sep 17 00:00:00 2001 From: Ulriche Nguefack Date: Fri, 9 Feb 2024 09:28:04 +0100 Subject: [PATCH] refactoring: pow --- src/main/c/Calculator/calculator.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/c/Calculator/calculator.c b/src/main/c/Calculator/calculator.c index 5110e69..abf70e0 100644 --- a/src/main/c/Calculator/calculator.c +++ b/src/main/c/Calculator/calculator.c @@ -1,5 +1,6 @@ #include -#include +#define M_PI 3.14159265358979323 + // Function prototypes void displayMenu(); @@ -9,6 +10,7 @@ int getIntInput(const char *message); double factorial(double num); double permutation(int n, int r); double combination(int n, int r); +double pow(double num1, int num2); int main() { int choice; @@ -146,3 +148,11 @@ int getIntInput(const char *message) { scanf("%d", &input); return input; } + +double pow(double num1, int num2){ + double product = 1; + for(int i = 0; i < num2; ){ + product *= num1; + } + return product; +} \ No newline at end of file