top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Summary of Functions in C

0 votes

A function is a group of statements those perform a specific task. Every function in C has following components -

returnType functionName(parameters list )
  Function Body 

returnType: A function may or may not return a value. returnType is the data type of the value the function returns. When function is not returning anything the returnType can be void or may not be specified.
functionName: Name of the function, along with the returnType and Parameter it constitute the function signature.
Parameter List: A parameter list a the variable list which is passed from the caller to the called function.
Function Body: A set of statements about the task of the function.

Advantages of Functions

  1. We can divide c program in smaller modules which can be tested and reused in the system as per need.
  2. Function increases modularity of a program which makes the code more readable.
  3. Program development become easy because of function i.e. top-down approach.
  4. Frequently used functions can be put together in the customized library
  5. A function can call other functions & also itself and can reduce the programming effort.

Arguments to the function

A function must declare variables that accept the values passed from the caller function. These variables are called the formal parameters of the function. These are like other local variables inside the function and are created upon entry into the function and destroyed upon exit.

There are two types of arguments can be passed to a function:

Call by value: This method copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.
Call by reference: This method copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. This means that changes made to the parameter affect the argument.

Sample Function


//Prototype Declaration
void myFunction();

void main()

void myFunction()
posted Jun 30, 2014 by Salil Agrawal

  Promote This Article
Facebook Share Button Twitter Share Button LinkedIn Share Button

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.