The default data type of function is
Answers
Answered by
0
Answer:
The default return type for c language function is integer.
Answered by
0
Answer
First of all everything that is not correct is not ERROR in C. C language has evolved from 1970s and C89 (ANSI) was the first standard followed by C99 and now C11. These standards were introduced based on current architectures to ensure best performance for C code. But backward compatibility is always an issue and no one wants an old code just not compiling.
Return type of a function is assumed to be "int" in C. But this assumption is removed from C99 standard on wards. Compiler might not show error for this, but you can tell compiler to do this. See the compiler warnings for the above code:
gcc func.c
func.c:2:1: warning: data definition has no type or storage class
func(a,b);
^
func.c:2:1: warning: parameter names (without types) in function declaration
func.c: In function ‘main’:
func.c:6:1: warning: ‘return’ with a value, in function returning void
return 0;
^
Just giving "-Werror" option to gcc
gcc -Werror func.c
func.c:2:1: error: data definition has no type or storage class [-Werror]
func(a,b);
^
func.c:2:1: error: parameter names (without types) in function declaration [-Werror]
func.c: In function ‘main’:
func.c:6:1: error: ‘return’ with a value, in function returning void [-Werror]
return 0;
^
cc1: all warnings being treated as errors
All warnings became error.
Now, as per standard, main must always return "int".
hope you mark me as a brainlist .........
thank you.
Similar questions