Hello,
I am working on a non-recursive function that computes a to the power n. I have one error which is cpp(23) : error C3861: 'mypower': identifier not found
#include "stdafx.h"
#include "stdio.h"
double power(float a, int n); // function prototype//
int main (void)
{
float a;
int n;
int power;
printf("\n enter a value of a\n");
scanf ("%d", &a);
printf("\n enter value of n\n");
scanf ("%d", &n);
power= mypower (a,n);
printf("The result is %d\n", power);
return 0;
}
double mypower(float a, int n)
{
if (a==0.0)
{
return 0.0;
}
else if(n==0)
{
return 1.0;
}
else if (n>0)
{
return( a* mypower(a,n-1));
}
else
{
return (1.0/ mypower(a,-n));
}
}