Function – Declaration Arguments Return Types

Functions Overview

Function is a set of statements and operations which performs a specific task.Every code has atleast one function (main function) and more can be created for simplifying and reducing the same code over and over again.

Example for a code in c++

[code language=”cpp”]
using namespace std;
int myFunction(int x, int y) //declaration of the function and the arguments .
int z;
return z; //returns the integer value z

void main() //declaration of main function with no arguments
int a,b;
myFunction(a,b); //calling the function to add the numbers


When creating a new function we need to tell the computer the name, the arguments(if any) and the type of the function which is called as the declaration of that function.

Example :

[code language=”cpp”]
int add(int a,int b)

Note 1- Good declarations are always in camelCase as they are more readable, example Рdeclaring a functioname name as myfunctionname is bad coding standard and myFunction name is good.


The values given/passed to the function that it may use in it’s operation are known as it’s arguments. A function may or may not have any values in it.


[code language=”cpp”]
int add(int a,int b) // here a,b are the arguments and int tells us they are integer

Return Types

A function may value after it runs completely, the type of value it returns is called the return type, it can be int (integer), float (decimal),char (alphabet of symbols), void (nothing is returned )… etc .

Examples :

[code language=”cpp”]
int add() //returns integer value
float divide()//returns decimal value
void print()//no value is returned