Sign in to follow this  
Followers 0
NELyon

Hypotenuse of a Right Triangle

7 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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 ;>

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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!"

Share this post


Link to post
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
Sign in to follow this  
Followers 0