Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 QUADRATIC SOLVER
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
lapo3399




PostPosted: Sun Nov 21, 2004 2:35 pm   Post subject: QUADRATIC SOLVER

Heres a program I made (i just learned turing today) for solving quadratic equations in math. Just enter the a, b, and c values and itll give u the roots. (y=ax**2+bx+[b]c[/b
WARNING!!!-THE PROGRAM MAY HAVE AN ERROR IF THERE ARE NO REAL ROOTS



findrootquad.t
 Description:

Download
 Filename:  findrootquad.t
 Filesize:  564 Bytes
 Downloaded:  417 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Nov 21, 2004 3:33 pm   Post subject: (No subject)

Confused
don't you mean
code:

e:=(b**2-4*a*c)
    if e<0 then
    put "There are no real roots"

because otherwise (sqrt(e)) the program will crash.

its a good start, but now you should try to encorporate all of the roots. Its not that hard. Here's a hit

code:

if e<0 then
e *= -1
flagi := true

and here you go - squareroot part becomes possitive, you just got to keep in mind that you have to add in "i" later on (but flagi is marked as true to remind you)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Andy




PostPosted: Sun Nov 21, 2004 8:09 pm   Post subject: (No subject)

heh i wrote one on my ti83 that can do the unreal roots.. too bad i lost it :'(
Tony




PostPosted: Sun Nov 21, 2004 8:42 pm   Post subject: (No subject)

I had lots of stuff on my TI83.. you know how you used to have to do dozens of the same problems over and over with different numbers? yeah - just solve once for the variable values instead, and write down the function in TI Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Andy




PostPosted: Mon Nov 22, 2004 4:21 pm   Post subject: (No subject)

heh yea.. same here
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: