CPM Homework Banner

Home > PC > Chapter 1 > Lesson 1.2.2 > Problem 1-79

1-79.

PROGRAMMING EXTENSION PROBLEM

Try your QUADFORM program with the following inputs; , , . Describe what happened and why. The following five lines can be added to your program to fix this problem. Your challenge is to see if you can figure out where to put them and in what order. Ask your teacher for help only after you have entered the lines and tested the program several times.

  1. :If

  2. : Goto

  3. : Stop

  4. : Lbl

  5. : Disp “COMPLEX ROOTS”

The program will “crash” since the program tries to take the square root of a negative number.

Possible Solution:

  1. Program: QuadForm
    : When
    : Goto 3
    : Else

  2. Program: QuadForm
    : ClrHome
    : Input “A=”, A
    : Input “B=”, B
    : Input “C=”, C

    : If 
    Then 

  3. Program: QuadForm
    : Disp R
    : Disp S
    : End
    : Stop
    : Lbl 3
    : Disp “COMP RTS”