Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double power(double x, int n) {
- if (n==0) return 1;
- if (n>0) return power(x, n-1)*x;
- else return power(x, n+1)/x;
- }
- int main(){
- double x=2.0;
- int n=-3;
- printf("%f", power(x, n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment