PROGRAM MENGHITUNG JUMLAH KARAKTER DALAM KALIMAT (PASCAL)

Program Hitung_Karakter_dalam_Kalimat;
uses crt;
var kalimat:string;
i,p,karakter:integer;
begin
clrscr;
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 do
begin
if kalimat[i]in['a'..'z',' '] then karakter := karakter+1;
end;
writeln;
writeln(' Jumlah karakter yang anda ketik ada : ',karakter,' karakter ');
readkey;
end.

PROGRAM BINTANG BERBENTUK PIRAMID (PASCAL)

Program Bintang1;
uses crt;
var i,j,n:integer;
begin
clrscr;
writeln('-----------------------------------------------');
writeln(' PROGRAM BINTANG BERBENTUK PIRAMID ');
writeln('-----------------------------------------------');
write('masukkan nilai = '); readln (n);
for i:=1 to n do
begin
if (i mod 2 = 1) then
begin
for j:=1 to ((n-i) div 2) do write(' ');
for j:=1 to i do write('*');
writeln;
end;
end;
readln;
readkey;
end.

Program Hitung Kata dalam Kalimat (PASCAL)

Program Hitung_Kata_dalam_Kalimat;
uses crt;

var kalimat:string;
jumlah:integer;

procedure jumlah_kata(kata:String; var jumlah:integer);
var i:integer;
begin
if(kata[1]='') then jumlah:=0
else jumlah:=1;
for i:=1 to length(kata) do
begin
if (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;

begin
clrscr;
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 : ',jumlah,' buah kata');
readkey;
end.
 

Usage Rights

DesignBlog BloggerTheme comes under a Creative Commons License.This template is free of charge to create a personal blog.You can make changes to the templates to suit your needs.But You must keep the footer links Intact.