0% found this document useful (0 votes)
22 views

Naredba If..Then..Else.

The document contains 3 procedures that use If/Then/Else statements to compare variables and assign values. The first procedure compares the values of x and y, assigns the larger value to Max, and displays Max. The second procedure compares the values of a, b, and c, assigns the largest value to Max, and displays Max. The third procedure compares the value of x to 0, assigns -1 if x < 0, 0 if x = 0, and 1 if x > 0, and displays the result.

Uploaded by

Sanja Djurdjevic
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Naredba If..Then..Else.

The document contains 3 procedures that use If/Then/Else statements to compare variables and assign values. The first procedure compares the values of x and y, assigns the larger value to Max, and displays Max. The second procedure compares the values of a, b, and c, assigns the largest value to Max, and displays Max. The third procedure compares the value of x to 0, assigns -1 if x < 0, 0 if x = 0, and 1 if x > 0, and displays the result.

Uploaded by

Sanja Djurdjevic
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Naredba If..Then..Else..

Procedure TForm1.Button1Click ( SEnder:


Tobject );
Var
x, y, Max : Integer;
Begin
x := StrToInt ( Edit1.Text );
y := StrToInt ( Edit2.Text );
If x > y
Then Max := x
Else Max := y;
Label4.Caption := IntToStr ( Max );
End;
Procedure TForm1.Button1Click( SEnder:
TObject );
Var
a, b, c, Max : Integer;
Begin
a := StrToInt ( Edit1.Text );
b := StrToInt ( Edit2.Text );
c := StrToInt ( Edit3.Text );
Max := a;
If b > Max Then Max := b;
If c > Max Then Max := c;
Label5.Caption := IntToStr ( Max );
End;
 1, x  0

y   0, x  0
 1, x  0

Procedure TForm1.Button1Click( SEnder:
TObject );
Var x,y:integer;
begin
x:=StrToInt (Edit1.Text);
if x<0 then y:=-1
else if x=0 then y:=0
else y:=1;
Label3.Caption:=IntToStr(y);
End;
 x1  x 2, x1  x 2

y   3x1, x1  x 2
5 x1  x 2, x1  x 2

Procedure TForm1.Button1Click( SEnder: TObject );
Var x1,x2,y:integer;
begin
x1:=StrToInt(Edit1.Text);
x2:=StrToInt(Edit2.Text);
if x1<x2 then y:=x1+x2
else if x1=x2 then y:=3*x1
else y:=5*x1-x2;
Label4.Caption:=IntToStr(y);
End;

You might also like