Adam Mukharil Bachtiar
English Class
Informatics Engineering 2011
Algorithms and Programming
Looping Structure
Steps of the Day
Let’s Start
For Structure While Do
Structure
Repeat Until
Structure
WhyWeNeedLooping
Structure?
Make a program to showing “I LOVE
ALGORITHM” on the screen as much as 1000
times. WHAT WILL YOU DO?
WhatisLoopingStructure
An Algorithm structure that allow us to REPEAT
some statements that fulfill LOOPING CONDITION.
ComponentsinLooping
Structure
• Looping condition
• Body statement
• Initialization
• Termination
TypesofLoopingStructure
• FOR
• WHILE
• REPEAT
For Structure
Definition and Structures of For Structure
ForStructure
• For structure was used in looping that have
specified ending of repetition.
• Number of repetition have been known in
the beginning.
• Can be in ASCENDING or DESCENDING way
Format of For Structure (Ascending)
Algorithm Notation:
for variable  start_value to end_value do
statement
endfor
Pascal Notation I:
for variable := start_value to end_value do
statement;
Format of For Structure (Ascending)
Pascal Notation II:
for variable := start_value to end_value do
begin
statement;
end;
Algorithm and Programming (Looping Structure)
Example of For in Ascending Way (Algorithm)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Algoritma Deret_Bilangan_Ganjil
{I.S: Diinputkan satu nilai akhir oleh user}
{F.S: Menampilkan jumlah deret ganjil}
Kamus:
x,akhir:integer
jumlah:integer
Algoritma:
input(akhir)
jumlah  0
for x  1 to akhir do
if x mod 2 = 1 then
jumlah  jumlah + x;
endfor
output(‘Jumlah deret ganjil dari 1 – ‘,akhir,’ = ‘,jumlah)
Example of For in Ascending Way (Pascal)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
program Deret_Bilangan_Ganjil;
uses crt;
var
x,akhir:integer;
jumlah:integer;
begin
write('Masukan batas akhir angka : ');readln(akhir);
jumlah:=0;
for x:=1 to akhir do
begin
if x mod 2=1 then
jumlah:=jumlah+x;
end;
writeln('Jumlah Deret ganjil dari 1 - ',akhir,' = ',jumlah);
writeln();
write('Tekan sembarang tombol untuk menutup...');
readkey();
end.
Format of For Structure (Descending)
Algorithm Notation:
for variable  end_value downto start_value do
statement
endfor
Pascal Notation I:
for variable := end_value downto start_value do
statement;
Format of For Structure (Ascending)
Pascal Notation II:
for variable := end_value downto start_value do
begin
statement;
end;
Algorithm and Programming (Looping Structure)
Example of For in Descending Way (Algorithm)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Algoritma Deret_Faktorial
{I.S: Diinputkan satu nilai oleh user}
{F.S: Menampilkan faktorial dari bilangan tersebut}
Kamus:
i,nilai:integer
faktorial:integer
Algoritma:
input(nilai)
faktorial1
for i  nilai downto 1 do
faktorialfaktorial*i
endfor
output(nilai,’! = ‘,faktorial)
Example of For in Descending Way (Pascal)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
program Deret_Faktorial;
uses crt;
var
i,nilai:integer;
faktorial:integer;
begin
write('Masukan nilai = ');readln(nilai);
faktorial:=1;
for i:=nilai downto 1 do
faktorial:=faktorial*i;
writeln(nilai,'! = ',faktorial);
writeln();
write('Tekan sembarang tombol untuk menutup...');
readkey();
end.
While Structure
Definition and Structures of For Structure
WhileStructure
• While structure always be executed while its
condition value is true.
• If the condition value is false, it means stop
repetition.
• While structure have condition in the
beginning of structure.
Format of While Structure
Algorithm Notation:
while kondisi do
statement
endwhile
Pascal Notation I:
while kondisi do
statement;
Format of While Structure
Pascal Notation II:
while kondisi do
begin
statement;
end;
Algorithm and Programming (Looping Structure)
Example of While (Algorithm)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Algoritma Deret_Bilangan
{I.S: Diinputkan satu angka oleh user}
{F.S: Menampilkan jumlah deret dari 1 sampai angka}
Kamus:
i,deret:integer
angka:integer
Algoritma:
input(angka)
deret0
i1
while i<=angka do
deretderet+i
ii+1;
endwhile
output(‘Jumlah deret dari 1 – ‘,angka,’ = ‘,deret)
Example of While (Pascal)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
program Deret_Angka;
uses crt;
var
i,deret:integer;
angka:integer;
begin
write('Masukan angka = ');readln(angka);
deret:=0;
i:=1;
while i<=angka do
begin
deret:=deret+i;
i:=i+1;
end;
writeln('Jumlah deret dari 1 - ',angka,' = ',deret);
writeln();
write('Tekan sembarang tombol untuk menutup...');
readkey();
end.
Repeat Structure
Definition and Structures of For Structure
RepeatStructure
• Repeat structure always be executed until its
condition value is true.
• If the condition value is true, it means stop
repetition.
• Repeat structure have condition in the end
of structure.
Format of While Structure
Algorithm Notation:
repeat
statement
until kondisi
Pascal Notation:
repeat
statement;
until kondisi;
Algorithm and Programming (Looping Structure)
Example of Repeat (Algorithm)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Algoritma Coba_Password
{I.S: Diinputkan password oleh user}
{F.S: Menampilkan pesan benar atau salah}
Kamus:
const
password=1234
pass,i,j:integer
Algoritma:
i1
j3
repeat
input(pass)
if pass=password then
output(‘Password anda benar!’);
else
ii+1
jj-1
output(‘Password salah (‘,j,’ kali lagi)!’)
endif
until (pass=password)or(i=4)
Example of Repeat (Pascal)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
21
22
23
24
25
26
27
28
29
30
31
32
program Coba_Password;
uses crt;
const
password=1234;
var
pass,i,j:integer;
begin
i:=1;
j:=3;
repeat
write('Masukan password (',i,'): ');readln(pass);
if pass=password then
begin
writeln('Password anda benar!');
writeln();
writeln('Tekan sembarang tombol untuk menutup...');
readkey();
end
else
begin
i:=i+1;
j:=j-1;
writeln('Password salah (',j,' kali lagi)!');
readkey();
end;
clrscr();
until (pass=password)or(i=4);
end.
EXERCISE
Exercise 1
Make the algorithm to solve this problem below (Color of
stars will be different each row):
N=5
*
* *
* * *
* * * *
* * * * *
Exercise 2
Make the algortihm to solve this problem below (Color of
stars will be different each row):
N=3
*
* *
* * *
* *
*
Exercise 3
Make algorithm to count:
s = 1 – 2/3 + 3/5 – 4/7+….
Exercise 4
Make algorithm to count the maximum value and
mean value from n students.
Contact Person:
Adam Mukharil Bachtiar
Informatics Engineering UNIKOM
Jalan Dipati Ukur Nomor. 112-114 Bandung 40132
Email: adfbipotter@gmail.com
Blog: http://adfbipotter.wordpress.com
Copyright © Adam Mukharil Bachtiar 2011

More Related Content

PPTX
Structure in C
PPTX
Operating system critical section
PPTX
Intro to Python Programming Language
PDF
PPTX
Types of function call
PDF
Python decision making
PPTX
Types of Statements in Python Programming Language
PDF
Python Flow Control
Structure in C
Operating system critical section
Intro to Python Programming Language
Types of function call
Python decision making
Types of Statements in Python Programming Language
Python Flow Control

What's hot (20)

PPT
Os Threads
PPTX
Data structures and algorithms
PPT
Peterson Critical Section Problem Solution
PPTX
Advanced topics in artificial neural networks
PDF
Methods in Java
PPT
presentation_jumping_statements_.ppt
PPTX
PHP FUNCTIONS
PPT
While loop
PPT
Python Control structures
PDF
Fixed partitioning of memory
PPTX
Strings in Java
PPTX
Java Data Types
PPT
Operating Systems Process Scheduling Algorithms
PPTX
C# Loops
PPTX
PPTX
Analysis and Design of Algorithms
PDF
Python programming : Control statements
PPTX
Regular expressions
PPTX
Java awt (abstract window toolkit)
Os Threads
Data structures and algorithms
Peterson Critical Section Problem Solution
Advanced topics in artificial neural networks
Methods in Java
presentation_jumping_statements_.ppt
PHP FUNCTIONS
While loop
Python Control structures
Fixed partitioning of memory
Strings in Java
Java Data Types
Operating Systems Process Scheduling Algorithms
C# Loops
Analysis and Design of Algorithms
Python programming : Control statements
Regular expressions
Java awt (abstract window toolkit)
Ad

Viewers also liked (17)

PDF
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
PDF
Algorithm and Programming (Sequential Structure)
PDF
Php & mysql course syllabus
PPT
Control structures repetition
PDF
Algorithm and Programming (Procedure and Function)
PPT
Fil11 -mga tungkulin ng wika (1)
PPTX
Looping and switch cases
PDF
Data Management (Data Mining Klasifikasi)
PDF
Algorithm and Programming (Branching Structure)
PDF
Algorithm and Programming (Record)
PPSX
Algorithm and Programming (Sorting)
PPSX
Algorithm and Programming (Searching)
PDF
Algorithm and Programming (Array)
PDF
Algorithm and Programming (Introduction of Algorithms)
PPT
Ang Tungkulin Ng Wika
PPT
C++ programming
PDF
Writing algorithms
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Sequential Structure)
Php & mysql course syllabus
Control structures repetition
Algorithm and Programming (Procedure and Function)
Fil11 -mga tungkulin ng wika (1)
Looping and switch cases
Data Management (Data Mining Klasifikasi)
Algorithm and Programming (Branching Structure)
Algorithm and Programming (Record)
Algorithm and Programming (Sorting)
Algorithm and Programming (Searching)
Algorithm and Programming (Array)
Algorithm and Programming (Introduction of Algorithms)
Ang Tungkulin Ng Wika
C++ programming
Writing algorithms
Ad

Similar to Algorithm and Programming (Looping Structure) (14)

PDF
Control structures c2 c3
PPT
Algoritma 1 pertemuan 6
PPT
Control structures ii
DOCX
Tugas3
PDF
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
PDF
Programming paradigms c1
PPT
04 control structures 1
PPS
02 ds and algorithm session_02
PPS
02 ds and algorithm session_02
PDF
Tugas alpro
PPTX
Algoritma pemrograman 12
PPT
Repetition Structure
PPT
Conditional Loops Python
PPT
Control structures c2 c3
Algoritma 1 pertemuan 6
Control structures ii
Tugas3
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
Programming paradigms c1
04 control structures 1
02 ds and algorithm session_02
02 ds and algorithm session_02
Tugas alpro
Algoritma pemrograman 12
Repetition Structure
Conditional Loops Python

More from Adam Mukharil Bachtiar (20)

PDF
Materi 8 - Data Mining Association Rule.pdf
PDF
Clean Code - Formatting Code
PDF
Clean Code - Clean Comments
PDF
PDF
Clean Code and Design Pattern - Meaningful Names
PDF
Model Driven Software Development
PDF
Scrum: How to Implement
PDF
Pengujian Perangkat Lunak
PDF
Data Mining Clustering
PPTX
Data Mining Klasifikasi (Updated 30 Desember 2020)
PDF
Analisis Algoritma - Strategi Algoritma Dynamic Programming
PDF
Analisis Algoritma - Strategi Algoritma Divide and Conquer
PDF
Analisis Algoritma - Strategi Algoritma Greedy
PDF
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
PDF
Analisis Algoritma - Strategi Algoritma Brute Force
PDF
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
PDF
Analisis Algoritma - Teorema Notasi Asimptotik
PDF
Analisis Algoritma - Notasi Asimptotik
PDF
Activity Diagram
PDF
UML dan Use Case View
Materi 8 - Data Mining Association Rule.pdf
Clean Code - Formatting Code
Clean Code - Clean Comments
Clean Code and Design Pattern - Meaningful Names
Model Driven Software Development
Scrum: How to Implement
Pengujian Perangkat Lunak
Data Mining Clustering
Data Mining Klasifikasi (Updated 30 Desember 2020)
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Notasi Asimptotik
Activity Diagram
UML dan Use Case View

Recently uploaded (20)

PPTX
Trending Python Topics for Data Visualization in 2025
DOC
UTEP毕业证学历认证,宾夕法尼亚克拉里恩大学毕业证未毕业
PPTX
Tech Workshop Escape Room Tech Workshop
PPTX
Matchmaking for JVMs: How to Pick the Perfect GC Partner
PDF
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
PPTX
Introduction to Windows Operating System
PDF
Guide to Food Delivery App Development.pdf
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PPTX
Airline CRS | Airline CRS Systems | CRS System
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PDF
MCP Security Tutorial - Beginner to Advanced
PDF
Workplace Software and Skills - OpenStax
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PPTX
CNN LeNet5 Architecture: Neural Networks
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PPTX
Python is a high-level, interpreted programming language
PDF
BoxLang Dynamic AWS Lambda - Japan Edition
Trending Python Topics for Data Visualization in 2025
UTEP毕业证学历认证,宾夕法尼亚克拉里恩大学毕业证未毕业
Tech Workshop Escape Room Tech Workshop
Matchmaking for JVMs: How to Pick the Perfect GC Partner
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
Introduction to Windows Operating System
Guide to Food Delivery App Development.pdf
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
Airline CRS | Airline CRS Systems | CRS System
Wondershare Recoverit Full Crack New Version (Latest 2025)
Topaz Photo AI Crack New Download (Latest 2025)
MCP Security Tutorial - Beginner to Advanced
Workplace Software and Skills - OpenStax
How Tridens DevSecOps Ensures Compliance, Security, and Agility
GSA Content Generator Crack (2025 Latest)
DNT Brochure 2025 – ISV Solutions @ D365
CNN LeNet5 Architecture: Neural Networks
How to Use SharePoint as an ISO-Compliant Document Management System
Python is a high-level, interpreted programming language
BoxLang Dynamic AWS Lambda - Japan Edition

Algorithm and Programming (Looping Structure)

  • 1. Adam Mukharil Bachtiar English Class Informatics Engineering 2011 Algorithms and Programming Looping Structure
  • 2. Steps of the Day Let’s Start For Structure While Do Structure Repeat Until Structure
  • 3. WhyWeNeedLooping Structure? Make a program to showing “I LOVE ALGORITHM” on the screen as much as 1000 times. WHAT WILL YOU DO?
  • 4. WhatisLoopingStructure An Algorithm structure that allow us to REPEAT some statements that fulfill LOOPING CONDITION.
  • 5. ComponentsinLooping Structure • Looping condition • Body statement • Initialization • Termination
  • 7. For Structure Definition and Structures of For Structure
  • 8. ForStructure • For structure was used in looping that have specified ending of repetition. • Number of repetition have been known in the beginning. • Can be in ASCENDING or DESCENDING way
  • 9. Format of For Structure (Ascending) Algorithm Notation: for variable  start_value to end_value do statement endfor Pascal Notation I: for variable := start_value to end_value do statement;
  • 10. Format of For Structure (Ascending) Pascal Notation II: for variable := start_value to end_value do begin statement; end;
  • 12. Example of For in Ascending Way (Algorithm) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Algoritma Deret_Bilangan_Ganjil {I.S: Diinputkan satu nilai akhir oleh user} {F.S: Menampilkan jumlah deret ganjil} Kamus: x,akhir:integer jumlah:integer Algoritma: input(akhir) jumlah  0 for x  1 to akhir do if x mod 2 = 1 then jumlah  jumlah + x; endfor output(‘Jumlah deret ganjil dari 1 – ‘,akhir,’ = ‘,jumlah)
  • 13. Example of For in Ascending Way (Pascal) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 program Deret_Bilangan_Ganjil; uses crt; var x,akhir:integer; jumlah:integer; begin write('Masukan batas akhir angka : ');readln(akhir); jumlah:=0; for x:=1 to akhir do begin if x mod 2=1 then jumlah:=jumlah+x; end; writeln('Jumlah Deret ganjil dari 1 - ',akhir,' = ',jumlah); writeln(); write('Tekan sembarang tombol untuk menutup...'); readkey(); end.
  • 14. Format of For Structure (Descending) Algorithm Notation: for variable  end_value downto start_value do statement endfor Pascal Notation I: for variable := end_value downto start_value do statement;
  • 15. Format of For Structure (Ascending) Pascal Notation II: for variable := end_value downto start_value do begin statement; end;
  • 17. Example of For in Descending Way (Algorithm) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Algoritma Deret_Faktorial {I.S: Diinputkan satu nilai oleh user} {F.S: Menampilkan faktorial dari bilangan tersebut} Kamus: i,nilai:integer faktorial:integer Algoritma: input(nilai) faktorial1 for i  nilai downto 1 do faktorialfaktorial*i endfor output(nilai,’! = ‘,faktorial)
  • 18. Example of For in Descending Way (Pascal) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 program Deret_Faktorial; uses crt; var i,nilai:integer; faktorial:integer; begin write('Masukan nilai = ');readln(nilai); faktorial:=1; for i:=nilai downto 1 do faktorial:=faktorial*i; writeln(nilai,'! = ',faktorial); writeln(); write('Tekan sembarang tombol untuk menutup...'); readkey(); end.
  • 19. While Structure Definition and Structures of For Structure
  • 20. WhileStructure • While structure always be executed while its condition value is true. • If the condition value is false, it means stop repetition. • While structure have condition in the beginning of structure.
  • 21. Format of While Structure Algorithm Notation: while kondisi do statement endwhile Pascal Notation I: while kondisi do statement;
  • 22. Format of While Structure Pascal Notation II: while kondisi do begin statement; end;
  • 24. Example of While (Algorithm) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Algoritma Deret_Bilangan {I.S: Diinputkan satu angka oleh user} {F.S: Menampilkan jumlah deret dari 1 sampai angka} Kamus: i,deret:integer angka:integer Algoritma: input(angka) deret0 i1 while i<=angka do deretderet+i ii+1; endwhile output(‘Jumlah deret dari 1 – ‘,angka,’ = ‘,deret)
  • 25. Example of While (Pascal) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 program Deret_Angka; uses crt; var i,deret:integer; angka:integer; begin write('Masukan angka = ');readln(angka); deret:=0; i:=1; while i<=angka do begin deret:=deret+i; i:=i+1; end; writeln('Jumlah deret dari 1 - ',angka,' = ',deret); writeln(); write('Tekan sembarang tombol untuk menutup...'); readkey(); end.
  • 26. Repeat Structure Definition and Structures of For Structure
  • 27. RepeatStructure • Repeat structure always be executed until its condition value is true. • If the condition value is true, it means stop repetition. • Repeat structure have condition in the end of structure.
  • 28. Format of While Structure Algorithm Notation: repeat statement until kondisi Pascal Notation: repeat statement; until kondisi;
  • 30. Example of Repeat (Algorithm) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Algoritma Coba_Password {I.S: Diinputkan password oleh user} {F.S: Menampilkan pesan benar atau salah} Kamus: const password=1234 pass,i,j:integer Algoritma: i1 j3 repeat input(pass) if pass=password then output(‘Password anda benar!’); else ii+1 jj-1 output(‘Password salah (‘,j,’ kali lagi)!’) endif until (pass=password)or(i=4)
  • 31. Example of Repeat (Pascal) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 30 31 32 program Coba_Password; uses crt; const password=1234; var pass,i,j:integer; begin i:=1; j:=3; repeat write('Masukan password (',i,'): ');readln(pass); if pass=password then begin writeln('Password anda benar!'); writeln(); writeln('Tekan sembarang tombol untuk menutup...'); readkey(); end else begin i:=i+1; j:=j-1; writeln('Password salah (',j,' kali lagi)!'); readkey(); end; clrscr(); until (pass=password)or(i=4); end.
  • 33. Exercise 1 Make the algorithm to solve this problem below (Color of stars will be different each row): N=5 * * * * * * * * * * * * * * *
  • 34. Exercise 2 Make the algortihm to solve this problem below (Color of stars will be different each row): N=3 * * * * * * * * *
  • 35. Exercise 3 Make algorithm to count: s = 1 – 2/3 + 3/5 – 4/7+….
  • 36. Exercise 4 Make algorithm to count the maximum value and mean value from n students.
  • 37. Contact Person: Adam Mukharil Bachtiar Informatics Engineering UNIKOM Jalan Dipati Ukur Nomor. 112-114 Bandung 40132 Email: [email protected] Blog: http://adfbipotter.wordpress.com Copyright © Adam Mukharil Bachtiar 2011