Қarshi muҳandislik-iқtisodiyot instituti “Axborot texnologiyalari va matematik modellashtirish” kafedrasi assistenti J


Download 1.29 Mb.
bet89/117
Sana01.11.2023
Hajmi1.29 Mb.
#1737958
1   ...   85   86   87   88   89   90   91   92   ...   117
Bog'liq
Informatika va informatsion texnologiyalar faniga kirish va kursning

Program N1(input, output);
Var s: real;
n: integer;
begin
s:=o; n:=1;
while n<=50 do
begin s:=s+1/n;
n:=n+1;
end;
writeln(‘yigindi kiymati s=’,s);
end.

bu yugindini hisoblash dasturida takrorlanish jarayoni n ning kiymati 50ga teng bulguncha davom etadi.


N ning kiymati 50 dan katta bo’lganidan yigindini kymatlarini hisoblash jarayoni tuxtatiladi va natija ekranga chikariladi.

Natija s=4.499...




n=1…500

tamom

S=

S=s+1/n


boshlash



Endi ushbu dasturni for operatoridan foydalanib tuzamiz


Program N2(input, output);
Var s: real;
n: integer;
begin
s:=0;
for n:=1 to 50 do
s:=s+1/n;
writeln(‘yigindi kiymati s=’,s);
end.

yigindini kiymati s=4.499…



FOR va WHILE operatorlaridan tashkari REPAET operatori yordamida ham takrorlanish jarayonini tashkil etish mumkin. REPAET operatorining umumiy ko’rinishi quyidagicha:


repaet a until b; Bu yerda а-operatorlar tsikl tanasi, b-mantiqiy ifoda.
Agar b shart bajarilsa boshqarish V dan keyingi operatorga utadi, V bajarilmasa tsikl davom etishi tuxtaydi.



Download 1.29 Mb.

Do'stlaringiz bilan baham:
1   ...   85   86   87   88   89   90   91   92   ...   117




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling