Explore BrainMass

Why Does it Work with Visual C++ but not with Miracle C?

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.
(My Question)
Doesn't the C language feature automatic conversion in mixed expressions? In a situation where you are converting integer to float, there is no loss of any numeric value as there would be in assigning a float to an int. So why would Miracle C block this but Visual C++ does not?

Solution Preview

When it comes to implementation, different compilers (gcc, Turbo C, Borlan C, Visual C++) all adhere to the core standards of ANSI C. Some compiler have functions, implementations that ...

Solution Summary

Some specific help on why Miracle C compiler does not allow some feature of C compilation.