Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 21

C++ Programming

Functions
What is a functions?
How to declare a function?
Composition of a function.
Composition of a function.

Function name

Parameters

Return type

Function body
Function Declarations
Calling a Function
Example
TYPES OF FUNCTIONS:
• VOID FUNCTION WITHOUT PARAMETERS
• VOID FUNCTION WITH PARAMETERS
• NON VOID FUNCTION WITHOUT PARAMETERS
• NON VOID FUNCTION WITH PARAMETERS
VOID FUNCTIONS WITHOUT
PARAMETER:

Void functions have no return type


VOID FUNCTIONS WITH
PARAMETERS:
Void functions have no return type
NON-VOID FUNCTIONS WITHOUT
PARAMETERS:

Non void functions are data types of int,


double, float
char, bool, etc. These data types require
return value.
NON-VOID FUNCTIONS WITH
PARAMETERS:

Non void functions are data types of int,


double, float
char, bool, etc. These data types require
return value.
Default values

Output
TYPES OF ARGUMENTS OF
FUNCTION
FUNCTIONS – CALL BY VALUE
FUNCTIONS – CALL BY VALUE -
EXAMPLE

RESULT:
FUNCTIONS – CALL BY POINTER
FUNCTIONS – CALL BY POINTER -
EXAMPLE

RESULT:
FUNCTIONS – CALL BY REFERENCE
FUNCTIONS – CALL BY REFERENCE -
EXAMPLE

RESULT:

You might also like