The syntax of repeat statement is :

**repeat**

* first statement*

.

.

* last statement*

**until** *boolean expression*

The first statement until the last statement will be executed once. If the boolean expression is false, all statements will be executed again until the boolean expression is true.

**Example 1 ( writing numbers from 1 to 10 ) :**

*{$APPTYPE CONSOLE}*

uses

SysUtils;

var

number : integer;

begin

number := 1;

repeat

writeln(number);

number := number + 1;

until number = 11;

readln;

end.

**Example 2 ( adding numbers from 1 to 100 ) :**

*{$APPTYPE CONSOLE}*

uses

SysUtils;

var

number, sum : integer;

begin

number := 1;

sum := 0;

repeat

sum := sum + number;

number := number + 1;

until number = 101;

writeln(sum);

readln;

end.

**Example 3 ( adding odd numbers from 1 to 10 ) :**

*{$APPTYPE CONSOLE}*

uses

SysUtils;

var

number, sum : integer;

begin

number := 1;

sum := 0;

repeat

if Odd(number) then sum := sum + number;

number := number + 1;

until number = 101;

writeln(sum);

readln;

end.

**Example 4 ( adding even numbers from 1 to 100 ) :**

*{$APPTYPE CONSOLE}*

uses

SysUtils;

var

number, sum : integer;

begin

number := 1;

sum := 0;

repeat

if not Odd(number) then sum := sum + number;

number := number + 1;

until number = 101;

writeln(sum);

readln;

end.

You can download the complete code here.

Go to Previous Tutorial or Next Tutorial

ijin download script sobat untuk literasi catatan saya. nice article. programmer ya, salam kenal aja ^_^

ReplyDeleteHello,Ari Christianto!

ReplyDeleteI am grateful that you visited my blog.

Welcome again.You have a nice blog here.

All the best in your life^_^

perlu memahami lebih lanjut dulu nih, ga paham bahasa program :)

ReplyDelete@Akhmad Syaiful : Ok, it's free to download.Thank you 4 visiting

ReplyDelete@Katariina : Hi, I'm grateful too, seeing you in this blog Katariina, thank you for dropping by. ^_^

@richoyul : Ok... let's learn together, I suggest you follow this blog from the first tutorial. thank you

pakde coba pahami dulu kawan, thank atas sharingnya

ReplyDeletemoga sukses selalu

@Pakde : thank you pakde for visiting and encouraging

ReplyDelete