Unable to understand pow

#include<bits/stdc++.h>
int main(){
printf("%d",pow(10,2));
return 0;
}

Output is coming 0. Why?

Can anybody explain.
#include<bits/stdc++.h>

int main(){
printf("%f",pow(10,2));
return 0;
}

output is 100.000000

In the first case you are using %d with float which is leading printf to fail doing its operation. That’s why It is giving 0.

So try using printf("%d",(int)pow(10,2)); it will give 100.

The pow function is just to calculate the power of number a to the number b according to the syntax pow(a,b) …And regarding the header file this this and this must help you

pow() returns double and in printf(), making it to implicitly convert from double to decimal makes it loose precision as the there is huge difference in bits magnitude of double and decimal.