PROGRAM PENJUMLAHAN DENGAN REPEAT UNTIL

program penjumlahan_dengam_repeat_until;

uses wincrt;

var

s,a,n:integer;

begin

writeln(‘PROGRAM PENJUMLAHAN DENGAN REPEAT UNTIL’);

writeln(‘—————————————‘);

write(‘n =’);readln(n);

write(‘S’,n,’ =’);

if n>1 then

begin

a:=1;

s:=1;

repeat

begin

write(a,’+’);

a:=a+1;

s:=s+a;

end;

until a>n-1;

write(n,’=’,s);

end;

if n=1 then

begin

write(‘1=1’);

end;

if n<1 then

begin

writeln;

write(‘data yang anda masukkan salah.’);

end;

end

Iklan

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s

%d blogger menyukai ini: