Predict the output of following C program.
The important thing to note is, there is no return type for fun(), the program still compiles and runs fine in most of the C compilers. In C, if we do not specify a return type, compiler assumes an implicit return type as int. However, C99 standard doesn’t allow return type to be omitted even if return type is int. This was allowed in older C standard C89.
In C++, the above program is not valid except few old C++ compilers like Turbo C++. Every function should specify the return type in C++.
This article is contributed by Pravasi Meet. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
- int (1 sign bit + 31 data bits) keyword in C
- Callbacks in C
- _Noreturn function specifier in C
- Pointers in C and C++ | Set 1 (Introduction, Arithmetic and Array)
- Functions in C/C++
- Interesting Facts about Macros and Preprocessors in C
- C Language Introduction
- Difference between ++*p, *p++ and *++p
- C Program to count number of lines in a file
- C Programming Language Standard
- Difference between "int main()" and "int main(void)" in C/C++?
- Is it fine to write "void main()" or "main()" in C/C++?
- What happens when a function is called before its declaration in C?
- exit(), abort() and assert()
- Static functions in C