uses wincrt;
var
prima:array[1..100] of integer;
hasil:real;
i,pilih,a,x,n:integer;
status:boolean;
b:char;
begin
repeat
clrscr;
writeln('1. Pemangkatan');
writeln('2. Faktorial');
writeln('3. Deret Angka');
writeln('4. Balik Huruf');
writeln('5. Bilangan Prima');
writeln('6. Perulangan for tersarang');
writeln('7. Keluar');
writeln;
write('Masukkan Pilihan Anda : ');readln(pilih);
case pilih of
1: begin
clrscr;
gotoxy(20,1);writeln('Program Pemangkatan');writeln;
write('Masukkan Sembarang Angka : ');readln(x);
write('Akan dipangkatkan berapa : ');readln(a);
writeln;
hasil:=1;
for i:=1 to a do hasil:=x*hasil;
writeln('Jadi ',x,' dipangkatkan ',a,' : ',Hasil:2:2);
status:=false;
end;
2: begin
clrscr;
gotoxy(20,1);writeln('Program Faktorial');writeln;
write('Masukkan Sembarang Angka : ');readln(n);
writeln;
if (n<=0) then
Writeln('Hasil Faktorial: ',1)
else
Begin
x:=1;
For i := 1 to n do
x:=x*i;
Writeln('Hasil Faktorial: ',x);
End;
status:=false;
end;
3: begin
clrscr;
gotoxy(20,1);writeln('Program Deret Angka');writeln;
write('Masukkan Maksimal Angka : ');readln(a);
writeln;
for i:=1 to a do
write(i:4);
end;
4: begin
clrscr;
gotoxy(20,1);writeln('Program Balik Huruf');writeln;
for b:='Z' downto 'A' do
write(b:4);
end;
5: begin
clrscr;
gotoxy(20,1);writeln('Program Bilangan Prima');writeln;
for i:=2 to 100 do
begin
prima[i]:=i;
for a:=2 to i-1 do
begin
x:=(i mod a);
if x=0 then prima[i]:=0;
end;
if prima[i]<>0 then
write(prima[i],' ');
end;
end;
6: begin
clrscr;
gotoxy(20,1);writeln('Program Perulangan for tersarang');writeln;
write('Masukkan jumlah Nilai cetak : ');readln(x);
write('Masukkan Nilai yang dicetak : ');readln(n);
writeln;
for i:=1 to x do
begin
for a:=1 to n do
write(i:4,a:2);
writeln;
end;
end;
7: status:=true;
else
begin
writeln('Pilihan Anda Salah !');status:=false;
end;
end;
readln;
until status;
end.
Share this post!