Advertisement
a3f

Square Equation Solver

a3f
Mar 14th, 2012
1,334
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. REM 7al el mo3adla el tarbee3iya
  2.  
  3. 10 INPUT "Enter a,b,c in ax²+bx+c=0 ?"; a,b,c
  4.  
  5. if a = 0 then
  6.     print "Co-effecient of x² can't be 0, try again."
  7.     print 'satr fady
  8.     goto 10
  9. end if
  10.  
  11. momayez = b^2 - 4 * a * c
  12.  
  13. if momayez >= 0 then ' Di el 7ala el 3adiya
  14.  
  15.     x1 = (-1*b + momayez^.5) / (2 * a)
  16.     x2 = (-1*b - momayez^.5) / (2 * a)
  17.  
  18.     print "Real square roots are: "; x1,x2
  19.  
  20. else ' law el gzoor morakaba
  21.     momayez = momayez*-1 'me3iar el momayez
  22.     awel7ad = -1*b / (2 * a) 'el goz2 el 7aqeeqy
  23.     tany7ad = momayez^.5 / (2 * a) 'el goz2 el ta5ayoly men 5eer el i
  24.  
  25.     print "Complex square roots are: "; awel7ad;"±";tany7ad;"i"
  26. end if
Advertisement
RAW Paste Data Copied
Advertisement