Examine the code below and answer the following questions: 1) What is the findSo
ID: 3531054 • Letter: E
Question
Examine the code below and answer the following questions: 1) What is the findSomething function trying to do? 2) What should the name of the findSomething function really be called? 3) What is the expected output of this particular program? int findSomething(int n, int m) { if (n <= 1) return 0; else return 1 + findSomething(n / m, m); } int _tmain(int argc, _TCHAR* argv[]) { cout << findSomething(1, 2) << endl; cout << findSomething(4, 2) << endl; cout << findSomething(100, 10) << endl; cout << findSomething(36, 2) << endl; return 0; }Explanation / Answer
1. It is recursively dividing n by m till n is less than or equal to 1. And keeping the number of times it does so by adding 1 to each return.
2. Not too sure what would be the best way to name it, TimesDivisibleByBeforeDecimals seems kind of long and silly.
3.Output:
0
2
2
5
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.