In C programming, the term nested functions is often used to describe a function that is called from another function. This allows a program to divide a task into smaller functions.
In C programming, the term nested functions is often used to describe a function that is called from another function. This allows a program to divide a task into smaller functions.
Here, main() calls another function
calculateSum() to perform the calculation.
Standard C does not allow a function definition inside another function. Functions are normally defined separately and can call one another.
Functions divide a large program into smaller and manageable parts. One function can call another function whenever a particular task needs to be performed.
A student result program can use one function to calculate marks and another function to display the result.
Sum = 25
Write a C program in which the main() function calls
another function to calculate the square of a number and displays
the result.
Create a function named square() that accepts one integer
and returns its square. Call this function from main().
A function can call another function to perform a specific task. The called function executes its statements and can return a value to the calling function.
Enter a number: 7
Square = 49
The function square() is defined separately from
main(). The main() function calls it,
passes a value, and receives the returned result.
| Concept | Remember |
|---|---|
| Function | A reusable block of code for a specific task. |
| Function Call | Used to execute another function. |
| Calling Function | The function that calls another function. |
| Called Function | The function that is called to perform a task. |
| Return Value | The result sent back by the called function. |
Watch a beginner-friendly explanation of function calling and functions working together in C.
A short handwritten-style revision sheet for nested functions and function calling will be provided here.
Use the mind map for quick revision of calling function, called function and return value.