Paskal tilida matematik funksiyalarning yozilishi
abs(x) - |x|
|
sqrt(x) -
|
sqr(x) -
|
sin(x) - sin x
|
cos(x) - cos x
|
ln(x) - ln x
|
exp(x) -
|
arctan(x) - arctg x
|
Round(x) – x ni yaxlitlash
|
trunc(x) – x ning butun qismi
|
Matematika darsida masala yechishda chiziqli, tarmoqlanish va takrorlanuvchi algoritmlarga dasturlarni qarab o’tamiz. Chiziqli algoritmlar uchun misol va dastur.
1-Misol: Uchburchakning a, b, c berilgan bo’lsa uning balandliklarini hisoblovchi dastur tuzamiz.
Ma’lumki, balandliklar quyidagi munosabatlar yordamida ifodalanadi:
bunda,
Endi berilgan topshiriqni hisoblash jarayoniga mos Paskal tilidagi dasturni tuzamiz:
Program balandlik;
Var a, b, c, ha, hb, hc, p, s :real;
Begin
Write(‘a tomonni kiriting =’) Read(a);
Write(‘b tomonni kiriting =’) Read(b);
Write(‘c tomonni kiriting =’) Read(c);
p:=(a+b+c)/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c));
ha:=2*s/a;
hb:=2*s/b;
hc:=2*s/c;
writeln( ‘ha=’,ha, ‘hb=’, hb, ‘hc=’,hc); {Natijani chiqarish}
end.
2-Misol. Y=23X+2 funksiyaning qiymatini x ning -5,-4,-3, -2, -1, 0, 1, 2, 3, 4, 5 qiymatlarida qulay usulda kiritib hisoblash dasturini tuzing
program h-b;
var x: integer;
Begin
Write(‘x ni kiriting=’); Read (x);
Write(‘y=’, 23*x+2);
End.
3-Misol. Y=21x2+7x+1963 funksiyaning qiymatini x ning -5,-4,-3,-2,-1,0, 1, 2, 3, 4, 5 qiymatlarida qulay usulda kiritib hisoblash dasturini tuzing:
program h-b;
var x: integer;
Begin
Write(‘x ni kiriting=’); Read (x);
Write(‘y=’, 21*sqr(x)+7*x+1963);
End.
3-Misol. Tomonlari a=5, b=7, c=4 bo’lgan uchburchakning yuzini topish dasturini tuzing:
program h-b;
var a,b,c,P,S:real;
Begin
Write(‘a ni kiriting=’); ReadLn(a);
Write(‘b ni kiriting=’); ReadLn(b);
Write(‘c ni kiriting=’); ReadLn(c);
P:=(a+b+c)/2;
S:=sqrt(p*(p-a)*(p-b)*(p-c));
Write(‘S=’, S);
End.
4-Misol. ax2+bx+c=0 tenglamani a, b, c ning quyidagi qiymatlarida qulay usulda kiritib yechish dasturini tuzing:
a) a=1, b=1, c=3; b) a=1, b=4, c=4;
d) a=1, b=-4, c=4; e) a=1, b=5, c=3.
Program h-b;
var a,b,c: integer;
X1,X2,D: real;
Begin
Write(‘a ni kiriting=’); ReadLn(a);
Write(‘b ni kiriting=’); ReadLn(b);
Write(‘c ni kiriting=’); ReadLn(c);
D:=sqr(b)-4*a*c;
X1:=(-B-SQRT(D))/(2*A);
X2:=(-B+SQRT(D))/(2*A).
Write(‘X1=’, X1);
Write(‘X2=’, X2);
End.
Shunday qilib, matematika darslarida masalalarni yechishda kompyuterdan foydalanish maqsadga muvofiq bo’ladi.
Do'stlaringiz bilan baham: |