by Dinesh Thakur Category: Functions

When a function is called by value, the values of the actual arguments are copied into the formal arguments and the function works with these copied values. As a result, any changes made to the copied value in the called function do not affect the value of the actual argument in the calling function.

 
by Dinesh Thakur Category: Functions

strcpy () : If Sl and S2 are the names of two strings, the function call strcpy (S1, S2) copies

the contents of S2 including null character on to Sl. If S2 is smaller than Sl, there is no problem, however, if S2 is bigger than Sl the operation will eat into adjacent memory.

 
by Dinesh Thakur Category: Functions

In order to use a function in a program, the function must be first defined somewhere in a program. A function definition contains the code that specifies the actions to be performed. The syntax for defining a function is

 
by Dinesh Thakur Category: Functions

A recursive function is a function which invokes itself repeatedly. In this case function name appears within the function. Two examples of recursive function are given as follows:

 
by Dinesh Thakur Category: Functions

Like C, C++ enables to pass arguments to the main () function also. These arguments are passed by typing them after the program name on the command line. Hence, these arguments are known as command line arguments. Command line arguments help in providing data to the program.

 
by Dinesh Thakur Category: Functions

Like variables, functions also need to be declared before they are used in programs. A function declaration is also known as function prototype. Function prototype is a model or a blueprint for a function that informs the C++ compiler about the return type, the function name, and the number and data type of the arguments passed to the function. Function name together with parameter list is known as function signature and it does not include return type of a function. The syntax for declaring a function is



 
by Dinesh Thakur Category: Functions

In order to use a function in different parts of a program, the function must be called or invoked by another function. In C++, functions are called by specifying the name of the function, followed by the parentheses. The parentheses mayor may not contain a list of arguments depending on the function definition.

 
by Dinesh Thakur Category: Functions

Arguments in a function can also be of array type. When the arrays are passed by value in a function, it is written as shown in the following example:

 

Page 8 of 18



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.