Protsedura ha'm funksiya


type TForm1 = class(TForm)


Download 335 Kb.
bet7/9
Sana04.02.2023
Hajmi335 Kb.
#1162549
1   2   3   4   5   6   7   8   9
Bog'liq
9.Prosedura hám Funkciyalar

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const n=10;
procedure shig'ariw;
var
i:integer;
begin
for i:=1 to n do
Memo1.Lines.add('5');
end;
begin
Shig'ariw; Memo1.Lines.add(' ekranda 10 dana bes');
Shig'ariw; Memo1.Lines.add(' ekranda 20 dana bes');
end;
end.

3.6.1-suwret. 5 tsifrdi shig'ariwshi programma.


3-masele. n! Di esaplaw programmasin duzin'.
Programma kodi ha'm aynanin' uliwmaliq ko‘rinisin keltiremiz:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
n: integer; y: integer;
function fact(m: integer): integer;
var
k: integer;
begin
if m=0 then fact:=1 else fact:=fact(m-1) * m;
end;
begin
n:=strtoint(edit1.Text);
y:= fact(n);
Memo1.Lines.add('Natiyje='+inttostr(y));
end;
end.

3.6.2-suwret. 1 den n ge deyin bo‘lgan tsifrlardin' ko‘beymesi


Izoh: berip bo‘lg'an programmada paydalanip faktariyaldi esaplawin'iz mumkin. Bunin' ushin joqari bolimine manis kiritip, esaplaw tuymesin saylasaq boldi.


4-misol. funksiyani araliqda qadem menen esaplaw programmasin duzin'.
Programma kodi ha'm aynanin' uliwmaliq ko‘rinisin keltiremiz:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i:real;
procedure bolim programma(x:real);
var
y:real;
begin
y:=x+4;
Memo1.Lines.add('Tub son='+floattostr(y));
end;
begin
i:=-2;
repeat
Bolim programma(i); i:=i+1;
until i=10;
end; end.

3.6.3-suwret. Protsedurag'a baylanisli masele.


5-masele. Tomendegi figurani maydanin esaplaymiz.




3.6.1-sizma.
Programma kodi ha'm aynanin' uliwmaliq ko‘rinisin ko'restip otemiz:
unit Unit1;

Download 335 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9




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