Segitiga dan Piramida bintang di pascal

Cara membuat segitiga dan Piramida bintang di pascal.


1. Segitiga bintang Pascal.


program segitiga;
uses crt;
var
i,j: integer;
begin
  clrscr;
  for i := 1 to 5 do
    begin
    for j := 1 to i do
      begin
      write('*');
      end;
    writeln;
    end;
  readln;
end.


Hasil :


2. Segitiga Bintang terbalik :

program segitigabalik;
uses crt;
var
i,j: integer;
begin
clrscr;
  for i := 1 to 5 do
    begin
      for j := 1 to (6-i) do
      begin
      write('*');
      end;
    writeln;
    end;
readln;
end.

Hasil :


3. Piramid Bintang Pascal :


program piramid;
uses crt;
var
a,b,c,d : Integer;
begin
Write('masukan jumlah baris piramid : ');ReadLn(a);
    for b := 1 to a do
      begin
      for c:= a downto b do
      write (' ');
        for d := 1 to b+b-1 do
        write ('*');
        writeln;
      end;
  readln;
end.


Hasil :

0 Response to "Segitiga dan Piramida bintang di pascal"