Jump to content

Hypotenuse of a Right Triangle


NELyon
 Share

Recommended Posts

Super simple implementation of the Pythagorean Theorem in Autoit and in PHP.

Autoit:

MsgBox(0, "Hypotenuse", "The hypotenuse of a trangle with side lengths of "&@CRLF&"3 and 4 are"&Hypotenuse(3, 4));

func Hypotenuse($a, $b)
     $c = $a*$a+$b*$b;
     return sqrt($c);
endfunc

Quick, Easy, Made it to cheat in math :) J/K

PHP:

<?php
echo hypotenuse($_GET['a'], $_GET['b']);
function hypotenuse($a, $b)
{
    $c2 = $a*$a+$b*$b;
    return sqrt($c2);
}
?>

Example of PHP:

http://dbak.mine.nu/kenton/hypoexam.php?a=3&b=4

I love math.

Edited by Senton-Bomb
Link to comment
Share on other sites

func Hypotenuse($a, $:)

return sqrt($a^2+$b^2)

endfunc

;>

I think it might take longer to type it then to actually do it on your own ;>

Not when your teacher makes you write it out like this ;)

A^2+B^2=C^2

3^2+4^2=C^2

9+16=c^2

C^2 = 25

Sqrt(25) = C

C=5

When i type Sqrt, I mean the _/-- symbol that I just don't have sitting on my keyboard :D

If we do it on a calculator or other means, we just have to give the answer.

Link to comment
Share on other sites

If you need to cheat in math class you can also use this so you dont need to keep opening the.au3 files

$a = InputBox(" Pythagrorean Thingy","Leg 1 = ???")

$b = InputBox("Pythagrorean Thingy","Leg 2 = ???")

MsgBox(0,"Thing","If A= " & $a & " And B= " & $b & " Then the Hypotenuse is " & Hypotenuse($a, $:));

func Hypotenuse($a, $;)

$c = $a*$a+$b*$b;

return sqrt($c);

endfunc

code
Link to comment
Share on other sites

Super simple implementation of the Pythagorean Theorem in Autoit and in PHP.

Autoit:

MsgBox(0, "Hypotenuse", "The hypotenuse of a trangle with side lengths of "&@CRLF&"3 and 4 are"&Hypotenuse(3, 4));

func Hypotenuse($a, $b)
     $c = $a*$a+$b*$b;
     return sqrt($c);
endfunc

Quick, Easy, Made it to cheat in math ;) J/K

PHP:

<?php
echo hypotenuse($_GET['a'], $_GET['b']);
function hypotenuse($a, $b)
{
    $c2 = $a*$a+$b*$b;
    return sqrt($c2);
}
?>

Example of PHP:

http://dbak.mine.nu/kenton/hypoexam.php?a=3&b=4

I love math.

Good but it would be easier to understand if you write the $C = line as

$c = ($a*$a)+($b*$:);

Or

$c = ($a^2)+($b^2);

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...