<
ax^2+bx+c=0'
برنامج لحساب جذور المعادلة:
input "give me the three coefficients, please",a,b,c
d = (b^2-4 * a *c) if d = 0 then
x1 = - b / (2 * a)
x2 = x1
elseif d>0 then d = sqr(d)
calculating the descriminent
6
roots are equal case
6
real roots case
x1 = (-b + d) / ( 2 * a )
x2 = (-b - d) / ( 2 * a )
else
'complex roots case...
print "roots are complex"
'do'nt go any further...
stop
end if
print "for the equation"; a; "x^2 +"; b ; " x +"; c
print "the roots are:-
print "x1
"; x1
print "x2=
x2
end
١٣٦
مثال : أكتب برنامجا لقراءة عدد من ١ إلى ۱۲ يمثل رقم الشهر، ويطبع اسم الشهر المقابل ، أي عند إدخال الرقم ٣ مثلا فالبرنامج يجب أن يطبع march
... وهكذا .
الحل:
ج٢ ص١٣٦