Final answer:
A recursive function is a function that calls itself within its own definition. Here's an example of a recursive function in C++.
Step-by-step explanation:
A recursive function is a function that calls itself within its own definition. Here's an example of a recursive function in C++:
int search (int arr[], int size, int key) {
if (size == 0) {
return -1.
}
if (arr[size 1] == key) {
return size 1.
}
return search (arr, size-1, key).
}
This recursive function takes an array of integers, the size of the array, and a target key as parameters. It starts searching from the end of the array and compares each element with the key. If it finds a match, it returns the index of the element. If the end of the array is reached without finding a match, it returns -1.