0

How is this code written?

Write a program that receives a positive integer from the user and checks whether it can be written as a sum of two whole squares. If true, display the letter 7, otherwise display the letter N. Example: 26 = 5^2 +1^1

9th Apr 2022, 10:26 AM
Mhdis
Mhdis - avatar
3 Answers
+ 2
Make a nested for loop (similar to a bubble sort argo) that go from 1 to square root of the number., use two pow functions from the cmath header, add them together and test against the number. (probably easier to write the actual code than explain).
9th Apr 2022, 10:55 AM
rodwynnejones
rodwynnejones - avatar