28 lines
349 B
C
28 lines
349 B
C
/* Puissance */
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int puissance(int, int);
|
|
|
|
int main() {
|
|
int a, b, p;
|
|
|
|
a = 2;
|
|
b = 3;
|
|
p = puissance(a, b);
|
|
|
|
printf("%d puissance %d = %d\n", a, b, p);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int puissance(int a, int b) {
|
|
int p = 1;
|
|
|
|
for (int i = 0; i < b; i++) {
|
|
p = p * a;
|
|
}
|
|
|
|
return p;
|
|
}
|