Computer Science, asked by Parichay1, 1 year ago

write a program to input two unequal positive number and check whether they are perfect square or not. if the user in the negative numbers in the program display message 'square root of negative number cannot be determined'.

Answers

Answered by IamSatyam
174
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 sneha413639
11

Answer:

Your answer is in the ATTACHMENT

Attachments:
Similar questions