In some of the compilers the integer division returns an


In the following lines of code, the Miracle C compiler will not compile the line of code in the center (float x = 1/a;). Why does this occur?

How can it be corrected?

int a = 3;
float x = 1/a;
printf("The value in x is: %f",x);

In some of the compilers the integer division returns an integer and hence cannot be stored in a float variable and to correct this you need to change the second line here with "float x=1.0/a;". Adding ".0" to 1 will make a difference.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: In some of the compilers the integer division returns an
Reference No:- TGS01248604

Now Priced at $20 (50% Discount)

Recommended (92%)

Rated (4.4/5)