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
When should you use a union type component in a structured variable?
Eduardwww [97]

Answer:

The answers to 1st question and part 2A is given. However, the 2B is not given complete and thus cannot be answered.

Explanation:

UNION is a keyword used in C Language to have a commonly shared memory that can be used by multiple elements. It is a data-type that allows different data types to use the same shared memory location.

Importance: If you want to minimize the use of memory by sharing it between different datatype variables, then use UNION. For Ex. Let's suppose I want to use 2 variables a and b of type char and int respectively. Now, suppose int takes memory space of 2 bytes and char takes 1 byte then the total amount of memory needed = 2 + 1 = 3 Bytes. But, we want to first make use of a, and once done, we want to declare variable b. We can limit the memory use by declaring a memory space of 2 bytes (max of a and b). First, we can use this space to store the int variable and when done with it, we can use it to store the char variable.

PART 2A

typedef struct{

  int partNum;

  char partName[25];

} partin;

#define Partin partin

7 0
3 years ago
What number is needed to complete the pattern 66, 73, 13, 21, 52,_, 10, 20?
Lilit [14]
66,73 73-66=7
13,21 21-13=8
10,20 20-10=10

the missing no. is 9 so
52+9=61.

the pattern is
66,73,13,21,52,61,10,20





8 0
2 years ago
Match the appropriate color mode with the correct definition
Gemiola [76]

Answer:

1.RGB: Best for projects intended to be used on the web or video

Explanation:

On websites or making project RGB combination of colors is used. This combination of colors is used to store images in electronic components.

2. CMYK: best for professional printing projects using process colors

Explanation:

Printing professional use CMYK combinations of color for better printing results.

3.) indexed:The only colors saved are the colors used in the image

To manage digital images we use Indexed mode of colors.

Explanation:

4.) bitmap: uses black and white

Explanation:

bitmap is the combination of the black and white colors. As the images are large in size so that, to reduce the size of the image we store image in bitmap to reduce the size.

5.) gray scale: uses different shades of grey

Explanation:

The different shades of gray colors are found in the gray scale. These shades are used to produce images.

4 0
3 years ago
Jamie is not sure a new medication will work because it has not had a large test group. Is Jamie being creative?
Mumz [18]
No, they're being skeptical.
4 0
2 years ago
Read 2 more answers
1. If Earth's plates are constantly moving, why don't we need to update the locations of -
Dmitriy789 [7]

Answer:

Because the tectonic plates are moving so slowly in such small incraments that it would take a while before there was any noticable change.

Explanation:

4 0
2 years ago
Other questions:
  • Which of the following applications can be used as a data source for a Microsoft® Word® mail merge? A.Outlook Contacts B.Microso
    9·2 answers
  • You use worksheets to perform calculations. How do you perform these calculations?
    15·2 answers
  • Computers store temporary Internet files in the Recycle Bin. These files take up space and slow down a computer. Which tool can
    10·1 answer
  • Write a program that uses for loops to perform the following steps: Prompt the user to input two integers: firstNum and secondNu
    15·1 answer
  • How do i get around goguardian from a chromebook
    14·1 answer
  • Is greedy algorithm non deterministic by nature?
    13·1 answer
  • Although your project has been accepted by the customer, the contract with the system vendor specifies that it will support the
    13·1 answer
  • Will, there be any presents this year
    15·1 answer
  • B. WAP to check whether input number is palindrome number or not using SUB...... END SUB.​
    15·1 answer
  • in a block in a blockchain what represents the transactional data, sender, receiver, and number of coins? group of answer choice
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!