A. Program Procedure
Uses crt;
Var
a,b,c: integer;
k,l,s: real;
procedure Luas_segitiga;
begin
clrscr;
write ('masukkan sisi a : ');readln(a);
write ('masukkan sisi b : ');readln(b);
write ('masukkan sisi c : ');readln(c);
writeln;
K:=a+b+c;
S:=k/2;
L:= SQRT (S*(s-a)*(s-b)*(s-c));
writeln ('luas Segitiga = ',L:0:2);
writeln ('Keliling segitiga = ',K:4:2);
readln;
end;
begin
Luas_segitiga;
end.
B.IF-THEN
usescrt;
var
uts, uas, tot : real;
ket : string;
begin
clrscr;
write ('Masukkan nilai uts :'); readln (uts);
write ('Masukkan nilai uas :'); readln (uas);
tot := (uas+uts)/2;
if tot <= 100 then ket := 'A';
if tot <= 89 then ket := 'B';
if tot <= 79 then ket := 'C';
if tot <= 69 then ket := 'D';
writeln ('Total nilai : ', tot:2:0);
writeln ('Nilai yang didapat : ', ket);
readln;
end.
C.repeat until
usescrt;
var
angka,q: integer;
fangka: real;
begin
clrscr;
writeln ('Masukkan angka yang ingin difaktorialkan : ');
readln(angka);
q:=angka;
fangka:= 1;
repeat
fangka:= fangka*q;
q:=q-1;
until q=1 ;
writeln ('Faktorial dari ', angka , '! adalah ' , fangka:2:0);
readln;
end.
D. Function
usescrt;
var
F: integer;
Ream,Celc:real;
Function Reamur(F:integer):real;
begin
Reamur := (F-32)*4/9;
end;
function Celcius(F:integer):real;
begin
celcius := (F-32)*5/9;
end;
procedure Input;
begin
writeln ('Masukkan nilai Derajat Fahrenheit : '); readln(F);
end;
begin
clrscr;
Input;
Ream:=Reamur(F);
Celc:=Celcius(F);
writeln ('Hasil konversi ke Reamur menjadi ', Ream:2:0);
writeln ('Hasil konversi ke Celcius menjadi ', Celc:2:0);
readln;
end.
E.arrray
uses crt;var
a,b:array [1..100] of integer;
c,l:array [1..100] of real;
d,e,f,g:integer;
begin
clrscr;
d:=0;
e:=0;
g:=0;
write ('masukkan jumlah data : ');readln(f);
repeat
d:=d+1;
clrscr;
write ('masukkan panjang sisi A ke ',d,' : ');readln(a[d]);
write ('masukkan panjang sisi B ke ',d,' : ');readln(b[d]);
until d=f;
repeat
e:=e+1;
c[e]:=sqrt(sqr(a[e]+sqr(b[e])));
l[e]:=a[e]*b[e]/2;
until e=f;
writeln ('============================================');
writeln ('no sisi A sisi B sisi C Luas ');
writeln ('============================================');
repeat
g:=g+1;
writeln (g,' ',a[g],' ',b[g],' ',c[g]:0:2,' ',l[g]:0:2);
until g=f;
readln;
end.
0 :
Posting Komentar