Functions in C Programming
Functions in C Programming
Definition:
It can be called multiple times to perform the same operation without rewriting the code.
Types of Functions:
1. Library Functions:
2. User-defined Functions:
- Abstraction: Users can use a function without knowing its internal details.
Function Components:
2. Function Definition:
int add(int a, int b) {
return a + b;
3. Function Call:
Syntax:
// Function body
Example Program:
#include <stdio.h>
int main() {
int x = 4, y = 5;
return 0;
return a * b;
}
1. No arguments, no return
2. Arguments, no return
3. No arguments, return
Example:
int factorial(int n) {
if (n == 0) return 1;
Conclusion:
Functions in C are essential for writing efficient, organized, and maintainable code.
They enable modular design, reduce code duplication, and enhance code clarity.