I've written this code:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int x,n,result;
cout<<"enter the value"<<endl;
cin>>x;
cout<<"enter the power"<<endl;
cin>>n;
result=pow(x,n);
cout<<"the result of power\t"<<x<<"to\t"<<n<<"=\t"<<result;
}
When I assign x=10 n=2
the result is 99 not 100.
When i change x,n,result to float type, the output is x=10 n=2 result=100.
Can someone explain me why this difference?