Tag Archives: function

Area of Circle using function

for formula: http://www.mathsisfun.com/area.htm

code:

We have to always remember that value that define is always pass from main function to customized function named by user so here r=3 is passing to function britto and then the britto formula pi*r*r is applying and returned the value and it is printed in the main function where the variable defined as khetrofol.

Here pi declared as global variable with it’s value.

Function in C++

Syntax:

return will work for any function_type except void….void does not return any value but it returns..so we can use return keyword in void to exit but no value after return keyword  in void method / function

Normally we have to declare function protoype if we add the calling function after the main function

We can also use without function prototype when main function is after the calling function

We can also use function when there is not equal parameter is passing like

One example below created by me:

Another example

Recursive function: Factolrial
courtesy:cplusplus.com

Another one:

 

C++ Functioon Call By Value

 

C++ Function call by Reference

C++ Function call by Pointer