Write a program to input two unequal positive numbers and check whether
they are perfect square numbers or not. If the user enters a negative number
than the program displays the message 'Square root of a negative number
can't be determined
QGP:
Which Programming Language do you want it in?
Answers
Answered by
4
i am doing java :
if want an other lang pls tell
import java.io.*;
class test
{
public static void main()
{
BufferedReader var=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter two numbers");
int a=Integer.parseInt(var.readLine());
int b=Integer.parseInt(var.readLine());
if(a<0 || b<0)
{
System.out.println("Square of negative number cannot be determined");
return;
}
if(Math.sqrt(a)==(int)Math.sqrt(a)) System.out.println("a is a perfect square");
else System.out.println("a is not");
if(Math.sqrt(b)==(int)Math.sqrt(b)) System.out.println("b is a perfect square");
else System.out.println("b is not");
}
}
Answered by
4
Answer:
Your answer is in the ATTACHMENT
Attachments:
Similar questions