Functions C Tutorial

Bodhak functions c tutorial in this chapter let us learn in detail along with syntaxes and examples about  Introduction to Functions, Modular programming, Advantages of functions, Function components.

What is function prototype, Function Declaration Vs Definition, Function types   1)Function with return type with parameters 2)Function with return type without parameters 3) Function without return type with parameters 4)Function without return type without parameters.



functions c tutorial:-

Introduction to Functions:

A function is a self –contained program segment that carries out some specific, well-defined task. Every C program consists of one or more functions. One of these functions, we must call the main. Additional functions will be subordinate to main, and perhaps to one another.

If a program contains multiple functions, their definitions may appear in any order though they must be independent of one another. That is one function definition cannot be embedded within another.

When ever we access the function it will carry out its intended action (i.e. whenever we “Call” the function) from some other portion of the program.

We can access the same function from several different places within the program.

Once the function has carried out its intended action, control returns to the point from where the function was accessed

Modular programming

Definition: A programming style that brakes down program functions into modules, each of which accomplishes one function and contains all the source code and variables needed to accomplish that function. Modular programming is a solution to the problem of very large programs that are difficult to debug and maintain. By segmenting the program into modules that perform clearly defined functions, you can determine the source of program errors more easily.

Advantages :

We can develop a single procedure for reuse, eliminating the need to retype the code many times.

We can design the Programs more easily because a small team deals with only a small part of the entire code.

Modular programming allows many programmers to collaborate on the same application.

The code is stored in multiple files.

A code is short, simple and easy to understand.

Errors can easily be identified, as they are localized to a subroutine or function.

We can easily control the scoping of variables.

Next Page