Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 230

Custom pow function returns 0 for large exponent in C [closed]

$
0
0

As a beginner in C, I made my own pow function.The type of arguments in the function and the return value are all long long int.Here is the code:

typedef long long int lli;lli p0wer(lli base, lli exp){    lli p = 1;    for(int i = 1; i <= exp; i++){        p = p*base;  //we multiply exp times the base    }    return p;}

The problem is for large exponent, it returns 0.(For small values, like 10^10 it returns the result correctly)How can I fix this?


Viewing all articles
Browse latest Browse all 230

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>