Hello,
I need to modify the following function to compare with the library power using power (double, double)
#include "stdafx.h"
#include "stdio.h"
double mypower(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));
}
}
My error is showing that
(23) : error C2064: term does not evaluate to a function taking 2 arguments. Do I have to include the power library in the function?