InterviewSolution
Saved Bookmarks
| 1. |
A class DeciOct has been defined to convert a decimal number into its equivalent octal number. Some of the members of the class are given below: Class name: DeciOct Data members/instance variables: n: stores the decimal number oct: stores the octal equivalent number Member functions:DeciOct(): constructor to initialize the data members n = 0, oct = 0. void getnum(int nn): assign nn to n void deci_oct(): calculates the octal equivalent of ‘n’ and stores it in oct using the recursive technique void show(): displays the decimal number ‘n’, calls the function deci_oct() and displays its octal equivalent. State any two disadvantages of using recursion. |
|
Answer» The two disadvantages of recursion are: (i) It takes more time to compile. (ii) Much memory blocks are wasted. |
|