Browse Source

refactoring: pow

remotes/origin/Ulrich
Ulriche Nguefack 11 months ago
parent
commit
66b907eac2
  1. 12
      src/main/c/Calculator/calculator.c

12
src/main/c/Calculator/calculator.c

@ -1,5 +1,6 @@
#include <stdio.h>
#include <math.h>
#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;
}
Loading…
Cancel
Save