I tried to solve problem set 16 in projecteuler.net. I am trying to find 2^1000 for which I had written a code in C with a function named power().The problem here is that if i place printf() inside power() to get the result value, the answer is 10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376.000000 but if I use return value in power() and try to print the result from main() the answer is -2147483648.000000.
here is my code.
#include <stdio.h>
int power(double base,int ex)
{
    int i = 1;
    double final = 0;
    double ans = 1;
    while (i <= ex){
        ans *= base;
        i++;
    }
    printf("%lf\n",ans);     // return ans;
}
int main()
{
    double num;
    double result;
    int power_value;
    printf("enter the base value\n");
    scanf("%lf",&num);
    printf("enter the exponent value\n");
    scanf("%d",&power_value);
    power(num,power_value); //result = power(num,power_value)
    //printf("%lf",result);
}
 
     
     
    