You are on page 1of 9

PRESENTATION ON

*PASSING ARGUMENTS TO
FUNCTION &
*RETURNING VALUES
FROM FUNCTION
IN

-BY Anushthan Dhamala


 Function
 Functions are used to provide modularity to a program. Creating an application
using function makes it easier to understand, edit, check errors etc.

Basic Syntax for using Functions in C++


Here is how you define a function in C++

return-type function-name(parameter1, parameter2, ...)


{
// function-body
}
return-type: suggests what the function will return. It can be int, char, some
pointer or even a class object. There can be functions which does not return
anything, they are mentioned with void.
Function Name: is the name of the function, using the function name it is called.
Parameters: are variables to hold values of arguments passed while function is
called. A function may or may not contain parameter listhow you define a function
in C++
 Value Returning
Function:
 • All functions are either value-returning or
void
• All value-returning functions perform a task
and then return precisely one value
• In most cases, the value is returned to the
statement that called the function
• Typically, a statement that calls a function
assigns the return value to a variable –
However, a return value could also be used in a
comparison or calculation or could be printed to
the screen
Returning values
from function
Passing Arguments to
function
Return type

Int sqr(int);
argument

Function name

You might also like