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: 24

Answer

def CodeWrite (num): while (num < 100): flag=0; for (i = 1; i <= num/2; ++i): if (i*i == num): flag = 1; break; if (i*i>num) break; if (flag == 0) print (num); num ++;

Work Step by Step

The above code checks for all value of i from 1 to num/2 if any of them is the exact square root of the num then num is a perfect square and it's value is printed.
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.