Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculating with complex numbers
#1
This is from the QBasic Tech Reference book, and is intended to demonstrate math with complex numbers. I myself can't see through it anymore, but anyone who deals with mathematics can perhaps use it.

Code: (Select All)
'Loesung quadratischer Gleichungen S. 231, QBasic Referenz - 5. Juli 2022

Option _Explicit

Dim a, b, c, det As Double
Dim j As String

Do
  Cls
  Print "Geben Sie die Parameter a, b, c der Gleichung ax^2 + bx + c = 0 ein: "
  Input "a = "; a: Input "b = "; b: Input "c = "; c
  Print "Loesung: ";
  If a = 0 Then
    If b = 0 Then Print "alle Zahlen" Else Print "x = "; -c / b
  Else det = b * b - 4 * a * c
    If det >= 0 Then
      Print "x1 = "; (-b + Sqr(det)) / 2 / a; "x2 = "; (-b - Sqr(det)) / 2 / a
    Else
      Print "x1 = "; b / 2 / a; "+"; Sqr(det) / 2 / a; "* i;";
      Print " x2 = "; b / 2 / a; "-"; Sqr(det) / 2 / a; "* i"
    End If
  End If
  Print
  Input "Nochmal (J/N)", j
Loop Until UCase$(j) = "N"

End
Reply


Messages In This Thread
Calculating with complex numbers - by Kernelpanic - 07-05-2022, 02:05 PM
RE: Calculating with complex numbers - by bplus - 07-06-2022, 04:34 PM



Users browsing this thread: 2 Guest(s)