0
HELP when I run this program (in c language) and input the value 2 the output comes out to be 99. I'm using GNU GCC compiler. Can anyone please explain?
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int x,y; printf("\n\nenter the value of 10 = "); scanf("%d",&x); y=pow(10,x); printf("\nRESULT OF POWER OF Y = %d\n",y); return 0; }
2 Réponses
+ 1
Re-install your compiler. The code should work.
- 1
Because of integer truncation. pow()returns a floating point value, and due to floating point arithmetic, it is probably ~99.999...; however, due to integer truncation, even 99.999... gets truncated down to 99.
ref--google