I ran this simple program, but when I convert from int
to double
, the result is zero. The sqrt
of the zeros then displays negative values. This is an example from an online tutorial so I'm not sure why this is happening. I tried in Windows and Unix.
/* Hello World program */
#include<stdio.h>
#include<math.h>
main()
{ int i;
printf(" Number Square Root of Number
");
for (i=0; i<=360; ++i)
printf(" %d %d
",i, sqrt((double) i));
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…