#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
how int z = 2*pow(10,2)
int y = pow(10,2)
.
Output is 200 100
I know how to fix this problem.
It is excluded if, instead of integers, z
they y
are float.
I want to know how really C does an integer listing for swimming and other conversions?
Why use 2
instead n
fixes the problem?
Refresh
This question. What happens here in the pow function? Discusses this topic and has some good answers.
source
share