1-Write a function named isSquare that returns 1 if its integer argumentis a square of some integer, otherwise it returns 0. Yourfunction must not use any function or method (e.g. sqrt)that comes with a runtime library or class library!
The signature of the function is
int isSquare(int n)
Examples:
| if n is | return | reason |
| 4 | 1 | because 4 = 2*2 |
| 25 | 1 | because 25 = 5*5/td> |
| -4 | 0 | because there is no integer that when squared equals -4. (note, -2 squared is 4) |
| 8 | 0 | because the square root of 8 is not an integer. |
| 0 | 1 | because 0 = 0*0 |
2,856 Views |
No comments yet.