Quick Revision: Functions in c++

Hi, guys this is short but very smart understanding for functions in c++ programming language. You can learn this in very simple way and lucid way we have explained the functions.

C++ functions are the building blocks of the C++ programs. The main function of the function is to hold the executable code of our written program. The entry and the exit of any C or the C++ program is usually done in the main function. The main function as its name suggest is the basic main function of your program it is used to store the entire programs and it is also capable of having many more other function in it to make the program much more easies and also helps the space complexity by saving us to rewrite the same code again and again whether the output of our program may be the same. The calling function suspends until the call of on e function may return.

A function has a function header and it also has the statement body of the entire main function. The function must have the following components so as to make the function work and respond properly as per the user’s requirements:

  1. A return type
  2. A name
  3. A parameter list

A return value is a C++ data type (the basic structure of the data you are using)a pointer to one of the data type, a pointer to a structure, a pointer to  a pointer, a pointer to an array, a pointer to an string etc. The function name is always unique within the code you have written. It always obeys the rules of identifiers. The functions may also include in them the list of arguments or the list of parameters so as to get the specified output.  The functions are called in the program. The function name may differ as per the users requirement and  as per the output we want in our program we can use different function name for the different programs if we want to calculate the sum of the entire marks then we may also take the function name as the calculate function. The main concept is that we need to write a return type before the function name.

The main function statement block:

Int main ()

This main function states the beginning of the main statement which has its own prototype. Prototype means the total number of arguments and the return type of the starting of the function

This function has its return type as int which is a data type of an integer value which means it will return an integer value but this function has 0 arguments or a null argument function. Similarly we can also pass the arguments in the main function which is known to be function overwriting. Function over writing means writing or passing the arguments in the function arguments may be of any data type it may be an integer argument and float argument we can also pass a reference of another variable as an argument.


Quick Revision: Functions in cpp


The main function basically declares the start of the main program. Usually the basic C and the C++ program’s main function are started as:

Void main ( )

This means start of our program. it has its prototype as void which is also known as the return type usually void is declared as the null return type that is it can return any kind of value.

We think article will surely will be helpful. This will help to understand the function concepts. It will be very beneficial to student to understand.

For more reading about technology news in singapore or from all over the world in all aspect from seo to online marketing do view more about other pages.

Sourabh Bhunje

Sourabh Bhunje, B.E. IT from Pune University. Currently Working at Techliebe. Professional Skills: Programming - Software & Mobile, Web & Graphic Design, Localization, Content Writing, Sub-Titling etc. http://techliebe.com/about-us

Leave a Reply