Dhruv Sb Dhruv Sb - 1 year ago 158
C++ Question

Power function is not working in c++

int n;
n = 2;
int d;
d = pow(10,n);

It displays 99 instead of 100.
I have indcluded math.h

Answer Source

Try using this code printf ("%f\n", d);. printf is come from stdio.h and is faster than cout. Also, change the type of d from int to double because pow return double

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download