Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

Pythagorean Theorem

This a program that can solve geometric problems based on Pythagorean Theorem. We suppose everybody is already familiar with the above Theorem. However, some of you might have forgotten this theorem. So, let us list the formula here. By referring to a right angled triangle AB , if the sides are AB, A and A respectively, where A is the hypotenuse, then AB, A and B are connected by the formula AB!"A !#B ! $sing the above formula, you can calculate the third side if the the length of any two sides are %now. &or e'ample, if AB#( and A #) then B #*. We have designed the +B program for the user to input any two sides and then he or she is able to calculate the third side automatically. The third side B can be found by finding the s,uare root of AB !"A ! . -n visual basic, the synta' is BC= Sqr(AB ^ 2 + AC ^ 2) We can also the function Round to round the value to two decimal places using the synta' Round(BC, 2). The Interfa e

The Code Private Sub ommand./ lic%01 As Single

2im AB, A , B A B

AB # +al0T't/AB.Te't1 # +al0T't/A .Te't1 # +al0T't/B .Te't1

-f AB 34 5 And A B

34 5 Then 6 !1

# S,r0AB 6 ! " A

T't/B .Te't # 7ound0B , !1 8lse-f AB 34 5 And B 34 5 Then A # S,r0B 6 ! 9 AB 6 !1 34 5 Then 6 !1 T't/A .Te't # 7ound0A , !1 8lse-f A 34 5 And B 6!9A AB # S,r0B 8nd -f 8nd Sub

T't/AB.Te't # 7ound0AB, !1

- See more at: http://www.vbtutor.net/VB_Sample/pythagoras.html#sthash.bOYD6 !l."pu#

You might also like