Function, User defined Function, User function
Introduction to User-defined functions in C++

The function is the group of statements defined by the user to perform some specific task. We can define more than one function in a program. The function acts upon the data and returns the value. There are basically two types of functions.


1. Library functions: These functions are predefined in C++.
Example: getch(), clrscr(), sizeof(), exit(), atof(), abort(), atoi(), fabs(), acos(), asin(), floor(), fmod(), pow() etc.

2. User-defined function: These functions are defined by the user itself.
Syntax: return_type  function_name(argument1, argument2, ...... , argumentn)
Example: int add( int a, int b), float multiplication( float a, float b, float c)

Frequently asked user-defined function programs:

5. Write a C++ program which defines function that returns multiple values.
7. Write a C++ program to increment a number by some value using call by value.
8. Write a C++ program that explains the call by reference functionality.
9. Write a C++ program to swap two numbers by some value using call by reference.
10. Write a C++ program that explains the functionality of returning a reference by a user-defined function.
11. Write a C++ program to find the factorial of a number using recursion.

12. Write a C++ program to print the Fibonacci series using user-defined function.


Thanks
Mukesh Rajput

Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: