C C++

Functions in C


Functions in C

A function in C is a reusable block of code that performs a specific task. Functions help make programs more organized, reusable, and easier to maintain.

Every C program, whether large or small, begins execution with the main() function. It serves as the entry point of the program.

Advantages of Functions in C

  • Reduce code duplication
  • Improve code readability
  • Make programs easier to maintain
  • Break complex problems into smaller, manageable parts
  • Promote code reuse

Function Declaration in C

Example

int max(int num1, int num2);