45 pts.
 can any one give me the source code using java?
Write a function named isSquare that returns 1 if its integer argument is a square of some integer, otherwise it returns 0. Your function 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

Software/Hardware used:
ASKED: October 6, 2008  7:27 AM
UPDATED: October 6, 2008  6:18 PM

Answer Wiki:
If you cannot use ANY function, your function should look something like this: <pre> public int isSquare (int n) { int iRootTest = 1; int iSquareTest = 0; if (n == 0 || n == 1) return 1; while (iSquareTest <= n) { iSquareTest = iRootTest*iRootTest; if (iSquareTest == n) return 1; iRootTest += 1; }; return 0; };</pre> This function will try any integer starting from 1 until the square of that integer is equal or greater than n. If it is equal, then return 1, and when it is bigger exits from the loop and return 0;
Last Wiki Answer Submitted:  October 6, 2008  6:18 pm  by  Belete   45 pts.
All Answer Wiki Contributors:  Belete   45 pts. , TRam   130 pts. , Denny Cherry   64,520 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _