This topic details functions and program execution in C.
Table of Contents
What is a Function?
A function is a group or block of statements enclosed in flower brackets that can be executed independently upon calling.
A group of functions makes a program.
Every function must return a value.
What are the Different Types of Function?
There are two types of functions. One is the pre-defined functions and user-defined functions.
The user need not create the pre-defined functions as they are already defined inside the ‘C’ program, and the compiler knows them as they are already defined. One example of a pre-defined function is the main function.
Another function is the user-defined function, where the user has to create the function.
How to Create a Function?
To create or declare a function, one has to follow three steps. That is, one, specify the function name along with the data type, two include parentheses (), and thirdly the curly or flower brackets {}.
Functions help in Program Execution in C, and it involves following steps,
- At first, the programmer needs to perform the calling function.
- The called functions that include the function definition perform the logic.
- After performing the logic, the called function returns the value.
- In the final step, the control shifts to the calling or main function after the value reaches the closing bracket.
Share
Share Course
Page Link
Share on social media