Category: Pascal

Category: Pascal

Pascal : Coding Konversi Biner to Desimal
Image December 21, 2019 Ari Usman,Artikel Komputer,Pascal admin

Program konversi_Biner_to_Dec;uses crt;var bilBiner : String; function pangkat(a, b : integer): integer;var i, hasil : integer;beginhasil := 1;for i:=1 to b dobeginhasil := hasil * a;end;pangkat := hasil;end; function bin2Dec(biner : string) : integer;var n, sum, i : integer;beginn := length(biner);sum := 0;for i := n-1 downto 0 dobeginif (biner [n-1] = ‘0’) then sum

Details
Pascal : Coding Konversi Desimal to Biner
Image December 21, 2019 Ari Usman,Artikel Komputer,Pascal admin

Program konversi_Desimal_to_Biner;uses crt;var bilangan:integer; function decToBin(desimal:integer):string;var hasilbagi, sisa:integer;bin:char;bilBiner:string;beginhasilBagi := desimal div 2;bilBiner := ”; while (hasilBagi >= 1) dobeginsisa := desimal mod 2;if (sisa = 0)then bin := ‘0’else if (sisa = 1) then bin := ‘1’; bilBiner:=bin + bilBiner; desimal := hasilBagi;hasilBagi := desimal div 2;end;decToBin:=’1′ + bilBiner;end; beginclrscr;writeln(‘KONVERSI BILANGAN DESIMAL KE BINER’);writeln;write(‘masukkan bilangan

Details
Pascal : Coding Penjumlahan Matriks
Image December 21, 2019 Ari Usman,Artikel Komputer,Pascal admin

program Penjumlahan_Matrix;uses crt;const kolom=10;baris=10;type matrix=array[1..baris,1..kolom] of integer;var matrix_A,matrix_B:matrix;a,b:integer;procedure InputMatrix(var x:matrix);var i,j:integer;beginfor i := 1 to a dobeginfor j := 1 to b dobeginwrite(‘Masukkan Elemen[‘,i,’,’,j,’]:’);readln(x[i,j]);end;end;end;procedure CetakMatrix(var x:matrix);var i,j:integer;beginfor i := 1 to a dobeginfor j := 1 to b dobeginwrite(x[i,j]:4);end;writeln;end;end;procedure JumlahMatrix(var x,y:matrix);var z:matrix;i,j:integer;beginfor i:=1 to a dobeginfor j:=1 to b dobeginz[i,j]:=x[i,j] + y[i,j];write(z[i,j]:4);end;writeln;end;end;beginclrscr;write(‘Masukkan Jumlah Baris :

Details
Pascal : Coding Bintang Piramid
Image December 21, 2019 Ari Usman,Artikel Komputer,Pascal admin

Program Bintang1;uses crt;var i,j,n:integer;beginclrscr;writeln(‘———————————————–‘);writeln(‘ PROGRAM BINTANG BERBENTUK PIRAMID ‘);writeln(‘———————————————–‘);write(‘masukkan nilai = ‘); readln (n);for i:=1 to n dobeginif (i mod 2 = 1) thenbeginfor j:=1 to ((n-i) div 2) do write(‘ ‘);for j:=1 to i do write(‘*’);writeln;end;end;readln;readkey;end.

Details
Pascal : Coding Hitung Jumlah Karakter dalam Kalimat
Image December 21, 2019 Ari Usman,Artikel Komputer,Pascal admin

Program Hitung_Karakter_dalam_Kalimat;uses crt;var kalimat:string;i,p,karakter:integer;beginclrscr;writeln(‘ ———————————————— ‘);writeln(‘ PROGRAM MENGHITUNG JUMLAH KARAKTER DALAM KALIMAT ‘);writeln(‘ ———————————————— ‘);writeln;writeln(‘ Ketikkan sebuah kalimat : ‘);writeln;write(‘ ‘);readln(kalimat);p:=length(kalimat); karakter:= 0;for i:=1 to p dobeginif kalimat[i]in[‘a’..’z’,’ ‘] then karakter := karakter+1;end;writeln;writeln(‘ Jumlah karakter yang anda ketik ada : ‘,karakter,’ karakter ‘);readkey;end.

Details
Pascal : Coding Hitung Kata dalam Kalimat
Image December 21, 2019 Ari Usman,Artikel Komputer,Pascal admin

Program Hitung_Kata_dalam_Kalimat;uses crt; var kalimat:string;jumlah:integer; procedure jumlah_kata(kata:String; var jumlah:integer);var i:integer;beginif(kata[1]=”) then jumlah:=0else jumlah:=1;for i:=1 to length(kata) dobeginif (kata[i]=”) and (kata[i+1]<>”) and (kata[i+2]<>”) then inc(jumlah)Else if (kata[i]=’ ‘) and (kata[i-1]<>”) and (kata[i+1]<>”) then inc(jumlah);end;end; beginclrscr;writeln(‘ ———————————————— ‘);writeln(‘ PROGRAM MENGHITUNG JUMLAH KATA DALAM KALIMAT ‘);writeln(‘ ———————————————— ‘);writeln;write(‘ Ketikkan sebuah kalimat : ‘);readln(kalimat);jumlah_kata(kalimat,jumlah);writeln(‘ Jumlah kata yang anda ketik

Details