Write a program in qbasic to accept three numbers and check whether they are Pythagorean triplet. The program must display the message accordingly
Answers
Answered by
21
ANSWER
.............
import java.util.*;
{
public
static
void main(String args)
{
Scanner sc= new Scanner(System.in);
int a,b,c;
System.out.println("Enter the three numbers");
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
if(a*a+b*b==c*c)
System.out.println("Pythagorean Triple");
else
System.out.println("Not Pythagorean Triple");
}
}
.............
import java.util.*;
{
public
static
void main(String args)
{
Scanner sc= new Scanner(System.in);
int a,b,c;
System.out.println("Enter the three numbers");
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
if(a*a+b*b==c*c)
System.out.println("Pythagorean Triple");
else
System.out.println("Not Pythagorean Triple");
}
}
Answered by
14
class Pythagoras
{
public static void main(int a,int b,int c)
{
System.out.println("Three no. are:"+a+","+b+","+c);
{
if(a*a+b*b=c*c)
{
System.out.println("it is Pythagoras triplet");
}
else
{
System.out.println("it is not a Pythagoras triplet");
}
}
}
}
Similar questions