Which of the following return-type cannot be used for a function in C?
a) void
b) int
c) struct
d) array
Answer:
d) array
Explanation:
In C, a function cannot have an array as its return type. While functions can return other data types, such as int
, void
, and even struct
, they cannot return an array directly. However, a function can return a pointer to an array or return an array as part of a structure.
Understanding the constraints on function return types is crucial for defining functions that interact correctly with various data types in C.