Catatan Si DjaiL

Program Menghitung jumlah huruf dan program konversi bilangan

Posted by: zonder77 in , , , , ,

Nih gan, ada beberapa program pascal untuk menghitung jumlah huruf dalam sebuah kalimat atau paragraf dan program konversi bilangan dari desimal ke heksadesimal.


program banyak_huruf_dalam_kalimat;
uses wincrt;
var n:array[1..26] of integer;
i,j:integer;
kata : String;

begin
for i:=1 to 26 do n[i]:=0;

write('Ketikkan sebuah kalimat : ');readln(kata);
for i:=1 to length(kata) do for j:=1 to 26 do
if ord(upcase(kata[i]))=64+j then inc(n[j]);

for i:=1 to 13 do
writeln(chr(64+2*i-1),' = ',n[2*i-1],' ',chr(64+2*i),' =
',n[2*i]);

end.



Program Konversi_Bilangan;
Uses WinCrt; Var
des,desi : integer;
Heks,temp : String; Begin
Write('Masukkan Suatu Bilangan Desimal :');Readln(des);
desi:=des; Heks:=''; repeat
if (des mod 16 < 10) then Heks:=chr(48+ des mod 16)+Heks else Heks:=chr(55+ des mod 16)+Heks; des:=des div 16; writeln(des:4,Heks:20); until des=0; writeln('(',desi,') desimal =',Heks,' (Heksadesimal)');end.

This entry was posted on 8:55 PM and is filed under , , , , , . You can leave a response and follow any responses to this entry through the Subscribe to: Post Comments (Atom) .

0 komentar

Post a Comment

>

ShoutMix chat widget

Guestbook Rolling Widget