Question

In: Computer Science

TEXT ONLY PLEASE ( PLEASE NO PDF OR WRITING) C++ CODE Instructions In a right triangle,...

TEXT ONLY PLEASE ( PLEASE NO PDF OR WRITING)

C++ CODE

Instructions

In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides.

Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle.

If the triangle is a right triangle, output It is a right angled triangle

If the triangle is not a right triangle, output It is not a right angled triangle

Solutions

Expert Solution

Note: The OR (||) operator will return true when either of the three condition is true.

Code to copy:

#include <iostream>

using namespace std;

int main()

{

// Declare the necessary int variables

int side1, side2, side3;

// Prompt user to enter the length of the sides

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

// Read the user inputs

cin>>side1>>side2>>side3;

// Check if the square of one side is equal to the sum of squares of the other two sides

if(((side1*side1) == ((side2*side2)+(side3*side3))) || ((side2*side2) == ((side1*side1)+(side3*side3))) || ((side3*side3) == ((side1*side1)+(side2*side2))))

{

// Print the triangle is right-angled

cout<<"It is a right angled triangle"<<endl;

}

else

{

// Print the triangle is not right-angled

cout<<"It is not a right angled triangle"<<endl;

}

}

Screenshot of code:

Sample output:

1

2


Related Solutions

TEXT ONLY PLEASE (PLEASE NO PDF OR WRITING) C++ CODE Instructions Write a program that implements...
TEXT ONLY PLEASE (PLEASE NO PDF OR WRITING) C++ CODE Instructions Write a program that implements the algorithm given in Example 1 - 3 (Chapter 1), which determines the monthly wages of a salesperson. The instructions for Example 1 - 3have been posted below for your convenience. Example 1 - 3 Every salesperson has a base salary. The salesperson also receives a bonus at the end of each month, based on the following criteria: If the salesperson has been with...
TEXT ONLY PLEASE (PLEASE NO PDF OR WRITING) C++ CODE Summary Samantha and Vikas are looking...
TEXT ONLY PLEASE (PLEASE NO PDF OR WRITING) C++ CODE Summary Samantha and Vikas are looking to buy a house in a new development. After looking at various models, the three models they like are colonial, split-entry, and single-story. The builder gave them the base price and the finished area in square feet of the three models. They want to know the model(s) with the least price per square foot. Instructions Write a program that accepts as input the base...
PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ PLEASE Summary For each used...
PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ PLEASE Summary For each used car a salesperson sells, the commission is paid as follows: $20 plus 30% of the selling price in excess of the cost of the car. Typically, the minimum selling price of the car is the cost of the car plus $200 and the maximum selling price is the cost of the car and $2,000. Instructions Write a program that prompts the user to enter:...
Translate the C function code below to the MIPS True Assembler Language code (machine instructions only)....
Translate the C function code below to the MIPS True Assembler Language code (machine instructions only). The function code should follow the conventions for MIPS function calls including passing parameters and returning results. Your function code must be written with the minimum number of machine instructions to be executed and without any use of MIPS pseudo-instructions. Myfunction(unsigned int a, unsigned int b, unsigned int c) { int i=0; while (a > c) { a /= b; i++; } return i;...
Find a b c of a right triangle. with a perimeter of 18.
Find a b c of a right triangle. with a perimeter of 18.
a) The triangle △ ABC is right-angled with right angle at corner C and angle α...
a) The triangle △ ABC is right-angled with right angle at corner C and angle α at corner A. Calculate a = | BC |, given that c = | AB | = 8, and that tan α = 12. Calculate a= ? b) In the triangle △ ABC before the designations a = | BC |, b = | CA |, c = | AB |, and ∠A = α, ∠B = β and ∠C = γ. Find c,...
Instructions: 1. Please use only C as the language of programming. 2. Please submit the following:...
Instructions: 1. Please use only C as the language of programming. 2. Please submit the following: (1) the client and the server source files each (2) a brief Readme le that shows the usage of the program. 3. Please appropriately comment your program and name all the identifiers suitable, to enable enhanced readability of the code. Problem: Write an ftp client and an ftp server such that the client sends a request to ftp server for downloading a file. The...
provide a C code (only C please) that gives the output below: ************************************ *         Menu HW...
provide a C code (only C please) that gives the output below: ************************************ *         Menu HW #4 * * POLYNOMIAL OPERATIONS * * 1. Creating polynomials * * 2. Adding polynomials * * 3. Multiplying polynomials. * * 4. Displaying polynomials * * 5. Clearing polynomials. * * 6. Quit. * *********************************** Select the option (1 through 6): 7 You should not be in this class! ************************************* *         Menu HW #4 * * POLYNOMIAL OPERATIONS * * 1. Creating polynomials...
Find the lengths of the arms of a right triangle whose hypotenuse has length c if...
Find the lengths of the arms of a right triangle whose hypotenuse has length c if these arms have a ratio of (a) 3;4 and c=15, (b) 5;12 and c=26, (c) 8;15 and c =170 and (d) 1;2 and c=10
ABC is an isoceles right-angled triangle in which ∠A = 90°. Find ∠B and ∠C.
ABC is an isoceles right-angled triangle in which ∠A = 90°. Find ∠B and ∠C.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT