Wednesday, April 30, 2014

Praktikum 1

program P0101;
uses wincrt;
var nama, alamat, hobby:string;
begin
writeln('program penampil data');
writeln ('********************');
write ('masukkan nama: '); readln (nama);
write ('masukkan alamat: '); readln (alamat);
write ('masukkan hobby: '); readln (hobby);
writeln;
writeln('hallo ',nama,' !!! kamu tinggal di ',alamat,' dan hobbymu adalah ',hobby);
readln;
end.
-------------------------------------
program P10102;
uses wincrt;
var bil1, bil2, jumlah:integer;
begin
writeln ('program penjumlahan sederhana');
writeln ('*****************************');
write ('masukkan bilangan 1: '); readln (bil1);
write ('masukkan bilangan 2: '); readln (bil2);
jumlah := bil1+bil2;
writeln ('luas lingkaran adalah : ',jumlah); readln ;
end.

program terbalik;
uses wincrt;
var s,t,u,v,w,x,y,z:string;
    p,q,i,j,k:integer;
begin
   clrscr;
   writeln;
   writeln('--------------------------------');
   writeln('-*((Program Huruf Terbalik))*-');
   writeln;
   writeln;
   writeln('masukan kalimat yang akan dibalik: ');
   readln(s);
   p:=length(s);
   i:=1;
   for q:=p downto 1 do
   begin
   insert(s[q],t,i);
   inc(i);
   end;
   writeln;
   writeln( 'hasilnya: ',t);
   readln;
end.
---------------------------------------------------

program deret_angka;
uses wincrt;
var i,n,deret: integer;
    coba:char;

begin
     clrscr;
     coba:='y';
     while coba='y' do
     begin
     writeln;
     writeln('---------------------------');
     writeln('-*((Program Deret_angka))*-');
     writeln;
     writeln;
     deret := 3;
     for i := 1 to 8 do
     begin
     write (deret);
     write (' ');
     deret := deret*3;
     end;
     writeln;
     writeln;
     write ('Coba Program Lagi? [y/t]: ');
     readln(coba);
     if coba='y' then coba:= 'y';
     end;
     readln;
end.
---------------------------------------------------

program deret_hitung;
uses wincrt;
var i,n,deret: integer;
    coba:char;

begin
     clrscr;
     coba:='y';
     while coba='y' do
     begin
     writeln;
     writeln;
     writeln(' " Program Deret_Hitung "');
     writeln(' ========================');
     writeln;
     deret := 3;
     for i := 1 to 10 do
     begin
     write (deret);
     write (' ');
     deret := deret + 3;
     end;
     writeln;
     writeln;
     write ('Coba Program Lagi? [y/t]: ');
     readln(coba);
     if coba='y' then coba:= 'y';
     end;
     readln;
end.
---------------------------------------------------

Program Faktorial_pascal;
uses wincrt;
function Faktorial(a:integer):longint;
   begin
   if (A=1)then
   Faktorial:=1
   else
   Faktorial:=a*faktorial(a-1);
   end;
   var
   x:integer;
   coba:char;
begin
   clrscr;
   coba:='y';
   while coba='y' do
   begin
   writeln;
   writeln(' " Program Faktorial "');
   writeln(' =====================');
   writeln;
   write(' Masukan Faktorial : ');readln(x);
   writeln(x, ' faktorial ','= ',faktorial(x));
   writeln;
   write (' Coba Program Lagi? [y/t]: ');
   readln(coba);
   if coba='y' then coba:= 'y';
   end;
   readln;
end.
---------------------------------------------------

program Deret_Kuadrat;
uses wincrt;
var max, i, a : integer;
    coba:char;

begin
  clrscr;
    coba:='y';
    while coba='y' do
  begin
    writeln;
    writeln('---------------------------');
    writeln('-*((Program Deret_Kuadrat))*-');
    writeln;
    writeln;
    i:=0;
    while i < 10 do
  begin
    i:= i + 1;
    a := i * i;
    write( a,' ');
  end;
    writeln;
    writeln;
    write ('Coba Program Lagi? [y/t]: ');
    readln(coba);
    if coba='y' then coba:= 'y';
  end;
  readln;
end.
---------------------------------------------------
program Login ;
uses wincrt;

var
 bil1,bil2,hasil,sisabagi: integer;


begin
 gotoxy(22,3);writeln(' ==================================== ');
 gotoxy(22,4);writeln(' PROGRAM HASIL & SISA PEMBAGIAN BULAT ');
 gotoxy(22,5);writeln(' ==================================== ');
 writeln;
 write(' masukkan bilangan yang akan dibagi: ');readln(bil1);
 write(' masukkan bilangan pembaginya: ');readln(bil2);
 hasil:= bil1 div bil2;
 sisabagi:= bil1 mod bil2;
 write('jadi hasil bagi bilangan tersebut adalah: ',hasil,' dan sisa baginya adalah: ',sisabagi);
 readln;
end.
---------------------------------------------------

program seleksi;
uses wincrt;
var i:integer;
begin
i:=0;
repeat i:=i+1;
writeln (i:2);
until i=5;
readln;
end.


---------------------------------------------------
program angka 9;
uses wincrt;
var ai,ao:integer;
begin
     for ai:=1 to 5 do
     begin
     for ao:=1 to 5 do
     if (((ai=1)or(ai=3))and((ao=2)or(ao=3)or(ao=4)))or((ao=1)and(ai<4))or(ao=5)or(ai=5)then
     write('*')
     else
     write(' ');
     writeln;
     end;
end.

---------------------------------------------------

program biodata;
uses crt; {atau uses wincrt;}
var nama, alamat : string; umur : integer;
begin clrscr;
 writeln('==========================================='); writeln(' Biodata'); writeln('==========================================='); write('Nama : '); readln(nama); write('Umur : '); readln(umur); write('Alamat : '); readln(alamat);
writeln('-------------------------------------------'); writeln('Jadi data Anda : ');
writeln('Anda bernama ',nama,'. Umur Anda ',umur,' tahun. Anda tinggal di ',alamat,'.'); writeln;
readkey;
 end.

---------------------------------------------------

program menampilkandatamahasiswa;
uses wincrt;

var
NRP,nilai_tugas,nilai_uts,nilai_uas,total_nilai,nilai_rata_rata : integer;
nama: char;

Begin
gotoxy(20,2);writeln('====================================');
gotoxy(20,3);writeln('= menampilkan data nilai mahasiswa =');
gotoxy(20,4);writeln('====================================');
writeln;
write('masukkan NRP: ');Readln(NRP);
write('masukkan nama: ');Readln(nama);
write('masukkan nilai tugas: ');Readln(nilai_tugas);
write('masukkan nilai uts: ');Readln(nilai_uts);
write('masukkan nilai uas: ');Readln(nilai_uas);
writeln;

total_nilai:=nilai_tugas + nilai_uts + nilai_uas;
nilai_rata_rata:=total_nilai div 3;

writeln('NRP:',NRP,' atas nama:',nama,' memperoleh nilai tugas:',nilai_tugas,' nilai uts:',nilai_uts,' nilai uas:',nilai_uas);
readln;
writeln('total nilainya adalah : ',total_nilai);readln;
writeln('nilai rata-ratanya adalah : ',nilai_rata_rata);readln;
End.


No comments:

Post a Comment