I read that every function in C should have a prototype and also that if a function takes in arguments or returns a value, their data types should be mentioned in both the prototype and the definition. However, I recently tried a piece of code which involved a call to a user defined function, which didn't satisfy the above requirements. Yet the program didn't throw any errors, although the result was incorrect. Can anyone provide with an explanation?
The code I tried was as follows:
#include<stdio.h>
int main(){
printf("%f",sum(3.2, 5.6));
return 0;
}
sum(a, b){
return a+b;
}
The code compiles and runs successfully with the output being 0.000000. The process exits with an exit code of 0. I ran the code on various online compilers.