101
Agar L mantiqiy ifodaning qiymati birinchi tekshirishdayoq yolg‗on bo‗lsa, M
operatori biron marta ham bajarilmaydi va boshqaruv
WHILE operatoridan keyingi
operatorga uzatiladi.
Misollar.
1) N! ni hisoblash dasturi tuzilsin.
Program fact;
Var n, i,p: integer;
Begin
Read(n); P:=1; I:=0;
While I
Begin
I:=I+1;P:=P*I;
End;
Write ('n! =', P)
End.
2) Sonni o`nlik sanoq tizimidan ikkilikka o`tkazish dasturi tuzilsin
PROGRAM sanoq;
TYPE massiv=array [1..50] of integer;
var a:massiv;
n,i:integer;
begin write('vvedite chislo:');
readln(n);
i:=1;
while n>=2 do
begin a[i]:= n mod 2;
i:=i+1;
n:= n div 2;
end;
i:=i-1;
102
write(n);
while i<>0 do
begin write(' ',a[i]);
i:=i-1;
end;
writeln
end.
3) Quyidagi dasturning bajaradigan funksiyasini tushuntiring
program pasc;
const a = pi / 4;
b = pi/2;
h = pi/60;
var x,fx :real;
begin x:=a;
writeln(' x y');
while x<=b do
begin fx:=sin(x)+0.5*cos(x);
writeln ('f (',x:4:2,')=',fx:4:2);
x:=x+h;
end;
end.
Dostları ilə paylaş: