C Functions
In c, we can divide a large program into the basic building blocks known as function. The function contains the set of programming statements enclosed by {}. A function can be called multiple times to provide reusability and modularity to the C program. In other words, we can say that the collection of functions creates a program. The function is also known as procedureor subroutinein other programming languages.
Types of Functions
There are two types of functions in C programming:
- Library Functions: are the functions which are declared in the C header files such as scanf(), printf(), gets(), puts(), ceil(), floor() etc.
- User-defined functions: are the functions which are created by the C programmer, so that he/she can use it many times. It reduces the complexity of a big program and optimizes the code.
Example for Function without argument and with return value
Example 1
Output:-
Going to calculate the sum of two numbers: Enter two numbers 10 24 The sum is 34
Example 2: program to calculate the area of the square
Output
Going to calculate the area of the square Enter the length of the side in meters: 10 The area of the square: 100.000000