1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
frozen [14]
3 years ago
12

Integers and booleans. Write a program RightTriangle that takes three int command-line arguments and determines whether they con

stitute the side lengths of some right triangle. right triangle The following two conditions are necessary and sufficient: Each integer must be positive. The sum of the squares of two of the integers must equal the square of the third integer.
Computers and Technology
1 answer:
icang [17]3 years ago
4 0

Answer:

<em>The programming language is not stated;</em>

<em>I'll answer using C++</em>

#include<iostream>

#include<cmath>

using namespace std;

int main()

{

int side1, side2, side3;

cout<<"Enter the three sides of the triangle: "<<endl;

cin>>side1>>side2>>side3;

if(side1<=0 || side2 <= 0 || side3 <= 0) {

 cout<<"Invalid Inputs";

}

else {

 if(abs(pow(side1,2) - (pow(side2,2) + pow(side3, 2)))<0.001) {

  cout<<"Right Angled";

 }

 else if(abs(pow(side2,2) - (pow(side1,2) + pow(side3, 2)))<0.001) {

  cout<<"Right Angled";

 }

 else if(abs(pow(side3,2) - (pow(side2,2) + pow(side1, 2)))<0.001) {

  cout<<"Right Angled";

 }

 else {

  cout<<"Not Right Angled";

 }

}

return 0;

}

Explanation:

The following line declares the three variables

int side1, side2, side3;

The next line prompts user for input of the three sides

cout<<"Enter the three sides of the triangle: "<<endl;

The next line gets user input

cin>>side1>>side2>>side3;

The following if condition checks if any of user input is negative or 0

<em> if(side1<=0 || side2 <= 0 || side3 <= 0) { </em>

<em>  cout<<"Invalid Inputs"; </em>

<em> } </em>

If otherwise

else {

The following if condition assumes that side1 is the largest and test using Pythagoras Theorem

<em>if(abs(pow(side1,2) - (pow(side2,2) + pow(side3, 2)))<0.001) { </em>

<em>   cout<<"Right Angled"; </em>

<em>  } </em>

The following if condition assumes that side2 is the largest and test using Pythagoras Theorem

<em>  else if(abs(pow(side2,2) - (pow(side1,2) + pow(side3, 2)))<0.001) { </em>

<em>   cout<<"Right Angled"; </em>

<em>  } </em>

The following if condition assumes that side3 is the largest and test using Pythagoras Theorem

<em>  else if(abs(pow(side3,2) - (pow(side2,2) + pow(side1, 2)))<0.001) { </em>

<em>   cout<<"Right Angled"; </em>

<em>  } </em>

If none of the above conditions is true, then the triangle is not a right angles triangle

<em>  else { </em>

<em>   cout<<"Not Right Angled"; </em>

<em>  } </em>

}

return 0;

Download cpp
You might be interested in
Code the function definition for aNonclassFunction, picking up co. aNonclassFunction has no return value.
enot [183]

Answer:

b)void aNonclassFunction (Banana co);

Explanation:

In the function definition you have to pass the tell the function which type of argument it is taking.In our case we are taking a variable co of Banana type passing it to the function named aNonclassFunction having no return type.

So the definition will be like this.

void aNonclassFunction (Banana co);

6 0
3 years ago
Can I have some help?
Ad libitum [116K]
I believe its A as the image provided says plain message
6 0
2 years ago
Knowledge of html and css is considered essential for the job of a(n _______.
7nadin3 [17]
<span>Knowledge of html and css is considered essential for the job of a web-designer. Html and css are useful if you want to build an informational web-site or landing page. Html is used for page structure and basic style. Css used for advanced styles, it helps you to make your web-site look prettier. If you want to make the advanced functions on your web-site, you should use javascript or php.</span>
4 0
2 years ago
1. Select the Volatile Memory *
fomenos

Answer:

1 no.

ram

2

harmful software to the computer

3

local area network

4

bit

5

ram

6

morris malware

7

hard disk drive

8

read only memory9

gigabyte

hope this will help u

6 0
2 years ago
How do you show your parents you are responsible enough for a phone?
alexandr1967 [171]
You can show your parents that you're responsible enough for a phone by volunteering to wash the dishes, or taking care of your siblings. Doing little stuff can prove that you're responsible. You should ask them, what they require you do to for a phone.
Good Luck!
4 0
3 years ago
Read 2 more answers
Other questions:
  • The packets used to transmit voice on the Internet are similar to the packets that are used to send email. What are some of the
    7·1 answer
  • Someone help ASAP! Match the type of information system with its description.
    13·2 answers
  • Which of the following is NOT one of the Big 3 Google Applications that we discussed?
    9·2 answers
  • You are attending to a neighbor who is unresponsive, not breathing normally, and pulseless. Your spouse has left to activate EMS
    8·1 answer
  • Computer privacy typically occurs when which of the following is violated?
    6·1 answer
  • Face book suggests Friends for users based on their
    13·1 answer
  • What factors do network consultants consider when determining the network needs of a business? Use the space provided below to a
    6·1 answer
  • Add my sna-p dkarpik58?...
    9·1 answer
  • Explain to Alana why she might not want to blast her boss on social media just yet.<br>​
    6·1 answer
  • a customer receives a message from the bank asking him/her to provide login information. assuming the message is intended to def
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!