Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Task 3 Write a program that calculates the length of the hypotenuse of a right triangle with the Pythagorean Theorem.

user-image
Question added by Tomasz Modrzejewski , Programmer , Company Skraw-Mech
Date Posted: 2014/08/24
Tomasz Modrzejewski
by Tomasz Modrzejewski , Programmer , Company Skraw-Mech

answer Pythagoras program; var   a, b: real; begin   write ('Enter the length of the hypotenuse:');   readln (a, b);   writeln ('The length of the hypotenuse c =', sqrt (a * a + b * b));   readln; end.

هاشم المشارقة
by هاشم المشارقة , Key Account Manager , Advanced United Systems Ltd. ( A member of Taj Holding Group)

I will write a very simple program using C++ language.

------------------------------------------------------------

#include <iostream.h>

void main(){

float a, b;

cin >> a;

cin >> b;

cout << "the hypotenuse equal to: " << sqrt(a*a+b*b);

}

Shagufta Mubasher
by Shagufta Mubasher , Web Developer , MP CJ O Shopping Sdn. Bhd.

Using Java

--------------------------------------------------------------------

package com.java2novice.math;

 

public class MyHypotEx {

 

    public static void main(String[] args) {

         

        int x =10;

        int y =20;

        System.out.println("The length of hypotenuse is: "+Math.hypot(x, y));

    }

}

... Void main (){ float a, b; cout <<" Enter the length of hypotenuse : " ; cin>> a; cin>> b; cout <<"the length is : "<

Wolf Klaas Kinsbergen
by Wolf Klaas Kinsbergen , Managing Director, Designer , ingenieursbureau KB International NV

Use excel, using  hyp C^2= length A^2 + width B^2, you can fill it in for every Length and Width.

Abdulelah Fallatah
by Abdulelah Fallatah , Tech-Support Specialist & Programmer , Al-Rayan Colleges

I'll use plain English to write the algorithm ;) :

 

- Get the input of the first line and store it in a variable called "line1".

- Get the input of the second line and store it in a variable called "line2".

- Get the sum of "line1" and "line2" and store it in a variable called "hypotenuse_squared".

- Take the square root of "hypotenuse_squared" and, after that, display it to the user as output.

sheik abdullah
by sheik abdullah , CNC PROGRAMMER/SETTER-CNC lathe-VMC,HMC , shall engineering

simple....

 

 

L ABC is a triangle  where  B is90 degree , and  AC is hypo. 

 

so     AC(hypo) = (BC square +AB square)

 

 

Gayasuddin Mohammed
by Gayasuddin Mohammed , Advocate , Practicing Law before High Court at Hyderabad

Assume ABC is a Right Angled Triangle, Angle B is90 degrees. AC is your Hypotenuse,  AB is your opposite side and BC is your Adjacent side.

Pythagorean theorem is  (hyp)^2 = (opp.side)^2 + (adj.side)^2

 

#include <stdio.h>

#include<math.h>

main()

{

float oppSide,adjSide,hypotenuse;

scanf("Enter value of the opposite side =%f ", &oppSide);

scanf("Enter value of the Adjacent side =%f", &adjSide);

 

hypotenuse = sqrt( ((oppSide)* (oppSide)) +((adjSide)*(adjSide)) );

 

printf(" hypotenuse of the given other sides of right angled triangle is :%f", hypotenuse );

 

}

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.