In "c" code should compile without issues.
However C++ should flag this as an error.
in "int main" the int part sends a return value indicating the return status of the code executed.
typically "return" statement value at end of the main will be propagated back to OS & finally to us showing whether the code executed successfully or not.
if you use linux ,u can check the exit status of the last app run usinf "echo $?"
//Simulating code with issue, by doing illegal division, in real world almost anything could go wrong
#include <stdio.h>
int main()
{
printf("Hello World");
int x = 1/0; // It is illegal to divide by 0,
//lets assumse numerator & divisor are returned
//based on some computation done elswhere & their values returned to us
return 0;
}
//Exit status is 136 , if all goes ok we return 0 & would expect exit status as 0.
/*****************************************************************
*****************************************************************/
//Good code
#include <stdio.h>
int main()
{
printf("Hello World");
return 0;
}
//Exit code is 0 , if all is ok we return 0 ,which differs from above example.
Now if u change the return value to float (or other than int), the OS would be confused as to what value was returned when trying to read the value & always report an error even if the code was executed without issues.
#include <stdio.h>
float main()
{
printf("Hello World");
return 0;
}
//...Program finished with exit code 11