Does pow() work for int data type in C? [duplicate]
This question already has an answer here: Strange behaviour of the pow function 5 answers I was simply writing a program to calculate the power of an integer. But the output was not as expected. It worked for all the integer numbers except for the power of 5. My code is: #include <stdio.h> #include <math.h> int main(void) { int a,b; printf("Enter the number."); scanf("\n%d",&a); b=pow(a,2); printf("\n%d",b); } The output is something like this: "Enter the number. 2 4 "Enter the number. 5 24 "Enter the number. 4 16 "Enter the number. 10 99 Can't we use pow() function for int data type??