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
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Implicit Type Conversion in C with Examples
- Difference between const int*, const int * const, and int const *
- Implicit initialization of variables with 0 or 1 in C
- What is return type of getchar(), fgetc() and getc() ?
- Difference between "int main()" and "int main(void)" in C/C++?
- Difference between sizeof(int *) and sizeof(int) in C/C++
- Difference between Type Casting and Type Conversion
- How can I return multiple values from a function?
- Return values of printf() and scanf() in C/C++
- return statement vs exit() in main()
- Return from void functions in C++
- C function argument and return values
- How to return multiple values from a function in C or C++?
- What does main() return in C and C++?
- return statement in C/C++ with Examples
- How to return a Pointer from a Function in C
- Print a long int in C using putchar() only
- What’s difference between “array” and “&array” for “int array” ?
- Assigning multiple characters in an int in C language
- int (1 sign bit + 31 data bits) keyword in C