Recursion With Template Functions
Explanation: The template function generates a random number and displays it each time the function display() is invoked. The function rand() defined in stdlib.h is used. The function calls itself recursively until the value of d becomes 1. The assert() statement checks the value of d and terminates the program when the condition is satisfied. The assert() is defined in assert.h. We can also use the if statement followed by the exit() statement as given in the comment statement.