program GT_lon_nhat;
uses crt;
var a, b, c: integer;
begin
write('nhap so a= '); readln(a);
write('nhap so b= '); readln(b);
write('nhap so c= '); readln(c);
if a>b then write('gia tri lon nhat la ',a) else if b>c then write('gia tri lon nhat la ',b) else write('gia tri lon nhat la ',c);
readln;
end.
Đoạn chương trình trên có sử dụng hai câu lệnh if...then lồng nhau đó.
uses crt;
var a,b,c,max:integer;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
write('c='); readln(c);
max:=a;
if max<b then max:=b;
if max<c then max:=c;
writeln('so lon nhat la: ',max);
readln;
end.
program ho_tro;
uses crt;
var a,b,c,max: real;
begin
clrscr;
writeln(' nhap 3 so:'); readln(a,b,c);
max:=a;
max:=b;
max:=c;
if max<a then max:=a;
if max<b then max:=b;
if max<c then max:=c;
writeln(' so lon nhat la:',max);
readln;
end.