im getting an error when using program.. compiles fine! - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

im getting an error when using program.. compiles fine!

bobhahabobhaha Posts: 1Member
ok i made a program which works out x from a quadratic formula when you enter values for a, b and c (which are "real" numbers) it puts the numbers in an equation but it does not work! it compiles fine.. but when i try using the program it says ERROR 207: invalid floating point operation

This is the line of code that it points too


i think its got something to do with all the operations happening in one line.. do you think this is a problem? also is there supposed to be any statement under "uses" (eg uses crt;)so i can use the sqrt operation?

Thanks in advance!


  • anthrax11anthrax11 Posts: 511Member
    With such equations you need to make some checks first. Check that a isn't 0, because you can't divide by 0. Also check that b*b-4ac isn't negative, because you can't root a negative number. If the conditions aren't met, then there are no solutions and the program should handle that.

    Usually the best thing to do in these situations is to debug the program.

    And the quadratic formula should be:
    instead of:
  • ducnthbducnthb Posts: 1Member
    the equation is incorrect, that is:
    var x1,x2,a,b,c:real;
    if b*b-4*a*c>0 then
  • costas100costas100 Posts: 3Member
    Make sure that you haven't forget the ' ; ' at the privious sentense
Sign In or Register to comment.