#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int n = 2;
int z = 2*pow(10,n);
int y = pow(10,n);
printf("%d %d" , z , y);
return 0;
}
Output is : 199 99
When I use 2 instead of n like int z = 2*pow(10,2) int y = pow(10,2).
Output is 200 100
I know how to eliminate this problem.
It gets eliminated if instead of integer z and y are float.
I want to know how really C does casting integer to float and other conversions?
Why does using 2 instead of n eliminate the problem?
Update
This Question What is happening here in pow function? Talks About This Thing and has some pretty good answers.