Rabu, 09 Desember 2009

Tugas Pemrograman Komputer 1

Bagi teman-teman yang sedang belajar Pascal, bisa melihat contoh berikut ini tentang terbilang.

Program Terbilang;
Uses Wincrt;
Var
a,b,c:longint;
Begin
Write('Masukkan Angka: ');readln(a);
b:=a div 10;
c:=a mod 10;
Writeln;
Begin
If (b=1) and (c=0) then write('sepuluh');
If (b=1) and (c=1) then write('sebelas');
If (b=1) and (c=2) then write('dua belas');
If (b=1) and (c=3) then write('tiga belas');
If (b=1) and (c=4) then write('empat belas');
If (b=1) and (c=5) then write('lima belas');
If (b=1) and (c=6) then write('enam belas');
If (b=1) and (c=7) then write('tujuh belas');
If (b=1) and (c=8) then write('delapan belas');
If (b=1) and (c=9) then write('sembilan belas');
Begin
If (b=0) and (c=1) then write('satu');
If (b=0) and (c=2) then write('dua');
If (b=0) and (c=3) then write('tiga');
If (b=0) and (c=4) then write('empat');
If (b=0) and (c=5) then write('lima');
If (b=0) and (c=6) then write('enam');
If (b=0) and (c=7) then write('tujuh');
If (b=0) and (c=8) then write('delapan');
If (b=0) and (c=9) then write('sembilan');
End;
Case b of
2: Write('dua puluh ');
3: Write('tiga puluh ');
4: Write('empat puluh ');
5: Write('lima puluh ');
6: Write('enam puluh ');
7: Write('tujuh puluh ');
8: Write('delapan puluh ');
9: Write('sembilan puluh ');
End;
If b>1 then
Case c of
1: Write('satu');
2: Write('dua');
3: Write('tiga');
4: Write('empat');
5: Write('lima');
6: Write('enam');
7: Write('tujuh');
8: Write('delapan');
9: Write('sembilan');
End;
End;
End.

0 komentar:

Posting Komentar

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Best Buy Printable Coupons