Computer Science: An Overview: Global Edition (12th Edition)

Published by Pearson Higher Education
ISBN 10: 1292061162
ISBN 13: 978-1-29206-116-0

Chapter 5 - Algorithms - Chapter Review Problems - Page 265: 31

Answer

Check1 will not print anything Check2 will print 1

Work Step by Step

In Check1 the condition of the if statement is num%2 == 0 which is false for num=1 hence the control will not enter if block and the function will end without printing anything. In Check2 the condition of the if statement is num%2 == 1 which is true for num=1 hence the control will enter if block and it will print(1) after that it will recursively call Check2 at num ==2 and now the condition of if block will become false and the program will end.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.