• Twitter
  • Technocrati
  • stumbleupon
  • flickr
  • digg
  • youtube
  • facebook

Follow our Network

Contoh Program Sederhana TPW bag. 7

0

Label:

Reaksi: 


------------------------------------------------------------------
Program Repeat_Until;
Uses wincrt;
Var
X:integer;
I:integer;
Begin
Write ('Mengulang sebanyak: ');readln(i);
X:=0;
If i > 0 then
Repeat
x:=x+1;
writeln(' I Love U forever');
until x=i
else
writeln('Pengulangan harus  > 0');
end.

------------------------------------------------------------------

Program Factorial;
Uses wincrt;
Var
I,n,f:integer;
Begin
f:=1;
write('nilai n: ');readln(n);

for i:=1 to n do
f:= f*I;
writeln('nilai factorial dari n= ',f);
end.

------------------------------------------------------------------



Program Kombinasi;
Uses wincrt;
Var
f,g,a,n,r,i:integer;
c:real;
begin
f:=1;
g:=1;
a:=1;
write('nilai n= ');readln(n);
write('nilai r= ');readln(r);

for i:=1 to n do
f:=f*i;
for i:=1 to n-r do
g:=a*i;
for i:=1 to r do
a:=a*I;

c:=f/(g*a);
writeln('----------------------');
writeln('C (n,r)= ', c:0:0);
writeln('----------------------');
writeln(' ');
writeln('Thank You..!!');

end.

-----------------------------------------------------------------

Program Permutasi;
Uses wincrt;
Var
f,g,n,r,i:integer;
p:real;
begin
f:=1;
g:=1;
write('Nilai n= ');readln(n);
write('Nilai r= ');readln(r);
 for i:=1 to n do
f:= f*I;
for i:=1 to n-r do
g:=g*I;
p:=f/g;

writeln('---------------------');
writeln('P (n,r) = ', p:0:0);
writeln('---------------------');
writeln(' ');
writeln('Syukron...!!!');


end.

-------------------------------------------------------------------

NB: Boleh CoPas..tapi ingat, cantumin sumber dan penulisnya yahhh..!!!

MuchFa... ^^

Comments (0)

Posting Komentar

Social Media

  • Subscribe via email

    Enter your email address:

    Delivered by FeedBurner

    Techno 4 U