This is definitely a newbie question. I've got a very simple example where I expected to get a compile or runtime error, but it actually works, albeit with the wrong answer:
If I compile it and run it, I get the following:Code:#include <stdio.h> int square(int x) { return x*x; } int main() { float a = 12.5; int b = square(a); printf("%f^2 = %d\n", a, b); return 0; }
It's the wrong answer and the wrong data type for the function call, but the C compiler allows it. Can someone point me to a reason?Code:12.500000^2 = 144
Many thanks!