Easy learning with example program codes

C Functions

A function is a piece of code that can be used repeatedly in a C program. A function is mainly of two types:

  • Built in Functions; which are already defined in C Library.
  • User Defined Functions; which are created and defined by users.



Return_type functionName(parameters)


    code to be executed;



Rules for using Functions:

  • Void return type is used when nothing need to be returned from the function.
  • Functions can also be used to return value. Return type such as int, long, char etc. are used to return a value from the function of the given type.
  • A function starts with an opening curly brace ( { ) and ends with a closing curly brace ( } ).
  • Arguments are the variables, inside the parentheses, after the function name which is used to pass informations to functions.
  • For multiple arguments, comma should be used for separation.
  • Default argument value can also be specified in a function. If no argument is specified, the function will take the default argument.


Calling a Function in C:

In order to get the value returned from the function, the function need to be called in the program.


Variable_name = function_name (parameters_values);


int writeMsg()
printf ("My First Program using Function!");
return 0;
void main()


My First Program using Function!
Posted in C   
Sign Up/ Sign In
Ask a Question

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2018 CodesJava Protection Status SiteMap Reference: Java Wiki