What is the default return type of a function in C if not specified?
a) int
b) void
c) float
d) char
Answer:
a) int
Explanation:
In C, if a function’s return type is not explicitly specified, it defaults to int
. This behavior stems from older versions of C, where functions without a specified return type were assumed to return an integer. However, it is considered good practice to always specify the return type explicitly to improve code clarity and avoid potential issues.
Understanding default behaviors in C, such as the default return type, is important for writing clear and predictable code.