Sabtu, 17 Januari 2009

Membuat Persegi Berongga dengan Pascal

program kotak_kosong;
uses wincrt;
var
i,j,s:integer;
x:char;
begin
repeat
write('Masukkan sisi persegi = ');readln(s);
if s>1 then
for i:=1 to s do
begin
if (i=1) or (i=s) then
begin
j:=1;
repeat
write('*');
j:=j+1;
until j=s;
end
else
begin
write('*');
j:=1;
repeat
write(' ');
j:=j+1;
until j=(s-1);
end;
writeln('*');
end
else
if s=1 then
begin
write('*');
end
else
begin
writeln('Sisi Persegi Harus bulat positf!');
end;
readln;
writeln('Ingin Mengulang? [Y/T]');readln(x);
until upcase (x)='T';
writeln('Program Selesai');
end.

Tidak ada komentar:

Posting Komentar

Kirim Komentar Anda
(Send Your Comment)