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]
4 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]4 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
Manipulate the SQL statement to pull ALL fields and rows from Customers table that have a PostalCode of 44000. TIP: Since Postal
padilas [110]

Answer:

There are two customers in the PostalCode.

SQL statement for select all the fields and the rows from the Customers table where PostalCode is 44000.

SELECT *  FROM Customers  WHERE PostalCode = "44000";

Explanation:

The SELECT statement retrieve zero or more than one row from 1 or more than one the database tables or the database views.  

In most of the applications, the SELECT query is most commonly used for DQL(Data Query Language) command.  

SQL is the declarative programming language and the SELECT statement specifies the result set, but they do not specifies how to calculate it.

6 0
3 years ago
Some projectors use a connection technology called _______________ that enables long-range connectivity for uncompressed HD vide
Rzqust [24]

Answer:

HDbaseT

Explanation:

HDbaseT is  a global connectivity standard for transmitting uncompressed high definition videos, audios, power, usb, ethernet home networking and some control signals for up to 100 meters, over a category cable like Cat 5a or Cat 6 cables.

The projector uses the HDbaseT for these reasons and for the fact that it eliminates clusters in cables without affecting its performance or high quality. This gives a high quality output display from the projector.

5 0
3 years ago
Which statement reflect a culture that value collectivism
Morgarella [4.7K]

Answer: To be honest i believe its D. All of the above reflect collectivism

hope this helps :)

8 0
4 years ago
If i'm wanting to use hydra on linux to crack a password and the issue regarding hashes occurs, what shall i do?
Inessa05 [86]
Give up do research and then try again
7 0
4 years ago
Wright a 3 paragraph 5 sentences per graph story bout computers or the internet
boyakko [2]

Ah yes, technology.

Firsly, let's start at the begining. Because we can't have internet without computers. Think of it from the old quote, "Which came first? The chicken or the egg?"

Computers, or the very first programmable one was created by German Konrad Zuse. A man with too much free time, invented a computer in his parents' living room. And yes, it was considered  to be the very first electromechanical binary programmable PC. He called it the "Z1". There's actually no right answer to this to be quite frank, considering the many different classifications you'd call a computer back then.

Why was the computer invented? Why, where would we be without it? Certainly not here (hence brainly and you asking this question). Computers were created for the sole purpose of a repetitive calculation to perform more quick and accurately information.

5 0
3 years ago
Other questions:
  • An engineer is assigned to replace an older data-grade autonomous wireless network with a cisco controllerbased wireless network
    6·1 answer
  • If you're able to understand directions more easily when you hear them instead of reading them you are most likely
    12·1 answer
  • Quien quiera jugar fortnote en una hora y media o antes pase id
    12·1 answer
  • Which of the following are examples of how a company might use consumer data it had collected? a To decide what types of product
    10·1 answer
  • PLEASE AWNSER 50 POINTS PLUS BRAINLEST ILL FAIL MY GRADE IF I DONT AWNSER IN A HOUR!
    15·1 answer
  • Choose the correct option below:Part A1. WAN link 2. Client 3. Server 4. Hub 5. Switch 6. Router 7. Media Part BA. This serves u
    9·1 answer
  • What intangible benefits might an organization obtain from the development of an
    5·2 answers
  • Who still plays old Nintendo 64 games?
    6·2 answers
  • Yooooooooooooooo
    5·2 answers
  • missy just hired a software development team to create an educational simulation app for a high school course. she has specific
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!