What is function in c++?

Introduction of Function:-
• It provides the organize the program into smaller modules.
• It enable the reuses of program code.
• Function has three components
o Return value
o Function name
o Set of arguments
Function name: – It enables users to refer to the function and it is also used when user wants to call and execute the code which is defined in the function.
Return value:- Every function may or may not return a value. During declaration of function the data type of return value should be specified.  If there is no value returned then it should be specified as void.
Set of arguments:-  After function name there is parenthesis where arguments are defined that arguments is known as set of arguments in function. Functions have no or any number of arguments. Arguments are input function and are used inside the function.
 If there is no argument in parenthesis means function is default function. If there is one argument in parenthesis means that function is single parameterized function. If there is two arguments in parenthesis means that function is double parameterized function and so on.  For Example,

Note:-  Every user defined funtion should be declared in the program before it is used.

Leave a Reply