If square root multiplied by itself equals number, then it is a perfect square.
package functional.tests.aaas;
import java.util.Arrays;
//perfect square
public class progprac {
public static void main(String[] args) {
int num = 25;
int root = (int)Math.sqrt(num);
if(root * root == num) {
System.out.println(num + " is Perfect Square");
} else {
System.out.println(num + " is Not Perfect Square");
}
}
}
No comments:
Post a Comment
Please comment below to feedback or ask questions.