Saturday, 4 June 2016

Functions in C++


What are Functions?

Now functions are modules or its like a part of a device which performs its work indivually. All parts of the computer like monitor or mouse or speakers can be seen as small small modules which together makes a computer. They can work indiviually as well. Speakers can work independently. This example is to show you guys that function in C++ is just a part of program which does it work when called.

Why do we use Function?

To modularise the program. Segmenting the program into small modules so that it can be easy to debug or update easily. If there’s a problem in your speaker you dont change you entire PC, you just repair or replace the speaker. Likewise, here too if there’s a problem in any segment of the program you just correct the function. The key point is functions helps in modularising the program.

How do we use it?

In C++, function is anything after which () is written. Even after void main(), we use the symbol (). () indicates that it is function. Functions can be named anything(Except keywords). However, there is a return type with every function. Return type is what does you function return to the program(Like your speaker plays songs). Data type can be int,float,double,void etc.

Programs on Functions are given on the ALL PROGRAMS option or you can search it. Detailed explanation is provided at each step. Comment below to ask any question or anything that might be useful to your knowlege.

No comments:

Post a Comment