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:...
please use text only! Instructions Consider the provided C++ code in the main.cpp file: The function...
please use text only! Instructions Consider the provided C++ code in the main.cpp file: The function func2 has three parameters of type int, int, and double, say a, b, and c, respectively. Write the definition of func2 so that its action is as follows: Prompt the user to input two integers and store the numbers in a and b, respectively. If both of the numbers are nonzero: If a >= b, the value assigned to c is a to the...
5.11 LAB: Drawing a right triangle c++ This program will output a right triangle based on...
5.11 LAB: Drawing a right triangle c++ This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user-specified triangleChar character. (1 pt) (2) Modify the program to use a nested loop to output a right triangle of height triangleHeight. The first line will have one user-specified character, such as...
Please complete the following code in C using the comments as instructions. Further instructions are below...
Please complete the following code in C using the comments as instructions. Further instructions are below the code. challenge.c // goal: print the environment variables to the file "env.txt", one per line // (If envp is NULL, the file should be empty, opening in write mode will do that.) // example: // inputs: // envp/environ = {"E1=2","E2=7",NULL} // outputs: // env.txt as a string would be "E1=2\nE2=7\n" // example: // inputs: // envp/environ = {NULL} or NULL // outputs: //...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT