Kamis, 15 Desember 2011 0 komentar

Contoh Program Terapan

CONTOH PROGRAM MENGHITUNG NILAI PHI
program menghitung_phi;
uses wincrt ;
var
   hasil :real;

begin
     hasil:=22/7;
     writeln(hasil);
end.
1 komentar

Contoh Program Matrik

CONTOH PROGRAM BENTUK MATRIK

program matriks;
uses wincrt;
var
x:array[1..100,1..100] of integer;
p,l,i,j:integer;
begin
write('banyaknya kolom = '); read(p);
write('banyaknya baris = '); read(l);
 writeln('tulis kebawah sebanyak baris kali kolom');
for i:=1 to l do
for j:=1 to p do
readln(x[i,j]);
writeln('bentuk matriknya : ');
for i:=1 to l do
begin
for j:=1 to p do
write(x[i,j],' ');
writeln;
end;
end.

0 komentar

Contoh Program Statistika

CONTOH PROGRAM MEAN

program rata_rata;
uses wincrt;
var
i,n: integer;
x,sum,mean:real;
begin
write('banyaknya data = ');
readln(n);
sum:=0;
for i:=1 to n do
begin
writeln('data ke',i,'=');
readln(x);
sum:=sum+x;
end;
mean:=sum/n;
writeln('rata-rata = ',mean:9:4);
end.


0 komentar

Contoh Program Konversi

CONTOH PROGRAM KONVERSI BINER KE ANGKA
Program konversi_biner;
uses wincrt;
var   
     desimal,b,sisa,biner:integer;
begin
     write (' angka biner '); readln (biner);
    b:=0;
      repeat 
     sisa:= biner mod 10;
     biner:= biner div 10;
     if (b=0) then
     b:=1
     else
     b:=b*2;
    desimal:= desimal+sisa*b;
     until biner = 0;

      write ('desimal=', desimal );
    
end.

6 komentar

Contoh Program Faktorial

CONTOH PROGRAM FAKTORIAL PAKAI FOR TO DO

program faktorial;
uses wincrt;
var
i,n,f:integer;
begin
readln(n); f:=1;
for i:=1 to n do
    begin
    f:=f*i;
    end;
    writeln(n,' faktorial = ',f);
end.

0 komentar

Contoh Program Deret

CONTOH PROGRAM DERET GENAP

program deret_genap;
uses wincrt;
var
i:integer;
begin
i:=2; write(2,' ');
repeat
i:=i+2; write(i,' ');
until i=10;
end.
Rabu, 14 Desember 2011 0 komentar

Contoh Program Bentuk Segitiga

CONTOH PROGRAM SEGITIGA SATU KE SEPULUH

program segitiga_satu_ke_sepuluh;
uses wincrt;
var
n,i,j:integer;
begin
n:=1;
for i:=1 to 4 do
    begin
         for j:=1 to i do
         begin
         write(n,' ');
         n:=n+1;
         end;
         writeln(' ');
         end;
end.

 
;