You have undefined behavior (so randomly bad things could, and you shouldn't expect anything good). With %f , the printf function expects a double (note that when passed as an argument, a float gets promoted to double ), but 0 is an int literal. In addition, different compilers (even different versions of the same compiler) or different optimization flags can create different bad effects.
Read the Lattner blog on What Every C Programmer Should Know About Undefined Behavior .
(a good attitude towards undefined behavior is to always try to avoid this, donβt waste time trying to figure out what exactly is happening, but consider UB as something very dirty or βsickβ, you always avoid)
To explain the observed behavior, you need to plunge into the specifics of your particular implementation, especially the ABI and the calling conventions (for Γ la printf variative functions). Also, look at the generated assembler code ( GCC , compile with gcc -fverbose-asm -S -O1 ); it is possible that a double register is passed to the register (or some stack of the call stack ), different from the int argument (so the printf function receives garbage to sit in this place or register); note also that quite often sizeof(int) can be 4, but sizeof(double) can be 8 (so the amount of data is not even right).
To avoid such errors, use the compilation habit with a good compiler (for example, GCC or Clang / LLVM in free software ) and include all warnings and debugging information (for example, compile with gcc -Wall -Wextra -g with GCC ). The compiler would warn you.
BTW, void main() is illegal. It should be at least int main(void) and preferably int main(int argc, char**argv) , and you should take care of the arguments.
In your example, gcc -Wall -Wextra (using GCC 7) reports (for your april.c source file):
april.c:4:10: warning: return type of 'main' is not 'int' [-Wmain] void main() { ^~~~ april.c: In function 'main': april.c:5:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'double' [-Wformat=] printf("%d\n", 1.5); ~^ %f april.c:6:14: warning: format '%f' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=] printf("%f", 0); ~^ %d
NB: Dev-C ++ and CodeBlocks are not compilers, but an IDE . They both run an external compiler (maybe GCC like MinGW on your system).