What is a function in C?
a) A block of code that performs a specific task
b) A variable that stores data
c) A loop that iterates a fixed number of times
d) A memory location
Answer:
a) A block of code that performs a specific task
Explanation:
A function in C is a block of code that performs a specific task. Functions allow for code modularity and reuse, enabling complex programs to be broken down into manageable pieces. Each function can be called from other functions, including the main()
function, which is the entry point of every C program. Functions can accept input parameters and return values, making them highly flexible and powerful tools for structuring code.
Understanding functions is crucial for writing organized and maintainable C programs, as they allow for separating concerns and reusing code efficiently.