Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

27 lines (20 sloc) 0.381 kB
// Section 1.7 Example 1 from page 25
#include <stdio.h>
int power(int m, int n);
// Test power function
main() {
int i;
for (i = 0; i < 10; ++i) {
printf("%d %d %d\n", i, power(2, i), power(-3, i));
}
return 0;
}
// Power: raise `base` to n-th power; n >= 0
int power(int base, int n) {
int i, p;
p = 1;
for (i = 1; i <= n; ++i) {
p = p * base;
}
return p;
}
Jump to Line
Something went wrong with that request. Please try again.