#include <stdio.h>
#include <stdlib.h>
int main()
{
float i;
i=6.0/7;
printf("i=%f\n",i);
return 0;
}
For example, C programmers learn early on that the result of dividing an integer by an integer is always an integer:
int x = 37;
int y = 8;
double quotient = x / y; // classic mistake, result is rounded to an int
cout << quotient; // prints " 4.000000"
double quotient = (double)x/y; // cast result as double so it's not rounded
cout << quotient; // prints "4.625000"
...
Thanks for any help,
JB