Reta Noorina Prastika 1311100090

Welcome to my blog..!! Enjoy to read and get your knowledge. Hopefully, you can understand it

Kamis, 05 Januari 2012

PROGRAM STATISTIKA DESKRIPTIF

0komentar
program statistika_deskriptif;
uses wincrt;
var
x:array [1..100] of real;
mean,rata,varians,s_2,standar_deviasi,s_d:real;
n,j,i:integer;
begin
write('masukkan n banyaknya angka = ');
readln(n);
for i:=1 to n do
begin
write(i, ' = ' );
readln(x[i]);
end;
rata:=0;
for i:=1 to n do
rata:=rata+x[i];
mean:=rata/n;
writeln('mean= ',mean:0:0);
varians:=0;
for i:=1 to n do
begin
write('varians= ');
readln(s_2);
s_2:=sqr(x[i]-mean);
writeln('varians= ',s_2:0:0);
end;
s_d:=0;
for i:=1 to n do
begin
write('standar deviasi= ');
writeln(s_d);
s_d:=sqrt(s_2);
writeln('standar deviasi= ',s_d:0:0);
end;
end.

PROGRAM BINOMIAL

0komentar
program binomial;
uses wincrt;
var i,j,k,n,x: longint;
a,b,c,d,e,p:real;
begin
readln(n,x,p);
a:=1; b:=1; c:=1; d:=1; e:=1;
for i:=1 to n do
a:=a*i;
for j:=1 to x do
begin
b:=b*j;
c:=c*p;
end;
for k:=1 to (n-x) do
begin
d:=d*k;
e:=e*(1-p);
end;
writeln(a/(b*d)*c*e);
end.

Senin, 19 Desember 2011

PROGRAM DETERMINAN DAN INVERS

0komentar
program determinan_invers;
uses wincrt;
var
x,y:array [1..50,1..50] of integer;
i,j,det:integer;
begin
writeln('Masukkan nilai matriks ordo 2 x 2 !');
for i:=1 to 2 do
for j:=1 to 2 do
begin
write('nilai x[',i,',',j,'] = ');readln(x[i,j]);
end;
writeln;
writeln('Bentuk matriks nya');
for i:=1 to 2 do
begin
for j:=1 to 2 do
write(x[i,j]:5);
writeln;
end;
det:=x[1,1]*x[2,2]-x[1,2]*x[2,1];
writeln;
writeln('Determinan matriks = ',det);
y[1,1]:=x[2,2];
y[1,2]:=-x[2,1];
y[2,1]:=-x[1,2];
y[2,2]:=x[1,1];
writeln;
writeln('Invers matriks nya');
for i:=1 to 2 do
begin
for j:=1 to 2 do
write(y[i,j]/det:8:2);
writeln;
end;
end.

PROGRAM MATRIKS

0komentar
  • Penjumlahan Matrik
              program matrik_penjumlahan;
              uses wincrt;
              var a,b,c: array[1..10,1..10] of integer;
              i,j,k1,k2,b1,b2,sum,r:integer;

             begin
             write('Masukkan baris Matrik A = ');readln(b1);
             write('Masukkan kolom Matrik A = ');readln(k1);
             write('Masukkan baris Matrik B = ');readln(b2);
             write('Masukkan kolom Matrik B = ');readln(k2);
             for i:=1 to b1 do
             for j:=1 to k1 do
             readln(a[i,j]);
             writeln;
             for i:=1 to b2 do
             for j:=1 to k2 do
             readln(b[i,j]);
             writeln;
             writeln('Matrik A');
             writeln('==================');
             for i:=1 to b1 do
             begin
             for j:=1 to k1 do
             write(a[i,j],' ');
             writeln;
             end;
             writeln;
             writeln('Matrik B');
             writeln('===================');
             for i:=1 to b2 do
            begin
            for j:=1 to k2 do
            write(b[i,j],' ');
            writeln;
            end;
            writeln;
            writeln('Matrik A*B');
            writeln('================');
            for i:=1 to b1 do
            begin
            for j:=1 to k2 do
            begin
            sum:=0;
            for r:=1 to k1 do
            sum:=sum+a[i,r]*b[r,j];
            c[i,j]:=sum;
            write(c[i,j]:2,' ');
            end;
            writeln;
            end;
            end.

    • Perkalian Matriks
                program perkalian_matrix;
                uses crt;
                var
                a,b,c : array [1..50,1..50] of integer;
                i,j,k,x,y,z : integer;
                begin
                clrscr;
                writeln(‘Ukuran matrix A’);
                write(‘Baris : ‘);
                readln(x);
                write(‘Kolom : ‘);
                readln(y);
                writeln;
                writeln;
                writeln(‘Ukuran matrix B’);
                writeln(‘Baris : ‘,y);
                write(‘Kolom : ‘);
                readln(z);
                for i:=1 to x do
                for j:=1 to y do
                begin
                write(‘Elemen A[',i,',',j,'] : ‘);
                readln(a[i,j]);
                end;
                writeln;
                for i:=1 to y do
                for j:=1 to z do
                begin
                write(‘Elemen B[',i,',',j,'] : ‘);
                readln(b[i,j]);
                end;
                for i:=1 to x do
                for j:=1 to z do
                for k:=1 to y do
                c[i,j] := c[i,j] + a[i,k]*b[k,j];
                writeln;
                writeln;
                writeln(‘Hasil dari perkalian Matrix A dengan Matrix B adalah : ‘);
                Writeln;
                for i:=1 to x do
                begin
                for j:=1 to z do
                write(c[i,j],’ ‘);
                writeln;
                end;
                writeln;
                readln;
                end.

      CONTOH PROGRAM PASCAL

      0komentar
      •  Contoh 1 :
                 program penghitung_umur;
                 uses wincrt;
                 var nama:string;
                 umur,tahunlahir:integer;
                 begin
                 write('Nama : ');
                 readln(nama);
                 write('Tahun Lahir : ');
                 readln(tahunlahir);
                 umur:= 2011 - tahunlahir;
                 write('Umur : ', umur);
                 end.

      • Contoh 2 :
                program penghitung_angka;
                uses wincrt;
                var b,n:integer;
                begin
                n:=0;
                repeat b:=1+3*n;
                n:=n+1;
                write (b, ' ');
                until
                n=6;
                end.
      • Contoh 3 :
                program mahasiswa;
                uses wincrt;
                var
                i:integer;
                begin
                i:=1; write(i);write(' ');
                repeat
                i:=i+3;
                write(i);write(' ');
                until i=16;
                end.

      • Contoh 4 :
                program pemangkatan;
                uses wincrt;
                var a,b,i:integer;n:real;
                begin
                write('A = ');readln(a);
                write('B = ');readln(b);
                n:=1;
                for i:=1 to abs(b) do
                n:=n*a;
                if (b>=0) then
                begin
                writeln('A pangkat B = ',n);
                end
                else
                begin
                writeln('A pangkat B = ',1/n);
                end
                end.

      • Contoh 5 :program faktorial;
        uses wincrt;
        var a:real;
        n,i:integer;

        begin
        write('n = ');readln(n);
        write('n faktorial = ');
        a:=1;
        if n<0 then write('tidak terdefinisi')
        else
        if n<2 then
        write(1)
        else

        begin
        for i:=n downto 2 do
        begin
        write(i,' x ');
        a:=a*i;
        end;
        write(1,' = ',a:0:0);
        end;
        end.    
      • Contoh 6 :program segitiga_pascal;
        uses wincrt;
        var
        n,i,j,x:integer;

        begin
        n:=1;
        read(x);
        writeln(x);
        for i:=1 to x do

        begin
        for j:= 1 to i do
        begin
        write(n,' ');
        n:=n+1;
        end;
        writeln(' ');
        end;
        end.
      • Contoh 7 :program deret_fibbonacci;
        uses wincrt;
        var a,b,c,i,n: integer;

        begin
        write('masukkan n = ');
        readln(n);
        a:=1; b:=0;
        for i:=1 to n do

        begin
        c:=a+b;
        a:=b;
        b:=c;
        write(c,',');
        end;
        end.

      PROGRAM KONVERSI

      0komentar
      program konversi_biner_desimal;
      uses wincrt;
      var
         desimal,d,sisa,biner:integer;
      begin
           write('Angka Desimal');readln(desimal);
           d:=0;
           repeat
           sisa:=desimal mod 2;
           desimal:=desimal div 2;
           if (d=0) then
           d:=1
           else
           d:= d * 10;
           biner:= biner + sisa * d;
           until desimal=0;
           write('Biner = ',biner);
      end.

      program konversi_desimal_biner;
      uses wincrt;
      var
         desimal,d,biner,sisa:longint;
      begin
           write('Biner = ');readln(biner);
           d:=0;
           repeat
           sisa:=biner mod 10;
           biner:=biner div 10;
           if (d=0) then
           d:=1
           else
           d:= d*2;
           desimal:=desimal+sisa*d;
           until biner=0;
           write('Angka Desimal = ',desimal);
      end.

      ALGORITMA

      0komentar
      Algoritma..???
      mungkin kita masih bingung apa itu algoritma dan gimana cara pengubahannya..
      Ayo, baca dengan antusias yaa..:-)

      Konversi Desimal ke Biner
      1. Mulai d = 1, biner 0
      2. Baca desimal
      3. Desimal = desimal div 2
      4. Sisa = desimal mod 2
      5. d baru = d x 10
      6. biner baru = biner + (sisa x d)
      7. Jika desimal = 0, pergi langkah 9
      8. Jika desimal tidak 0, pergi ke langkah 3
      9. Cetak biner
      10. Selesai
      Konversi Biner ke Desimal
      1. Mulai
      2. Baca biner
      3. Biner = biner div 10
      4. Sisa = biner mod 10
      5. d baru = d x 2
      6. Desimal baru = (sisa x d) + desimal
      7. Jika biner 0, pergi ke langkah 9
      8. Jika biner tidak 0, maka ulangi mulai  langkah 3
      9. Cetak desimal
      10. Selesai
       

      Reta Noorina Prastika 1311100090 Blak Magik is Designed by productive dreams for smashing magazine Bloggerized by Ipiet
      Thanks to Blogger Templates Blog | Distributed by Deluxe Templates © 2008