SlideShare a Scribd company logo
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

What's hot (20)

Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
Gaditek
 
Python datetime
Python datetimePython datetime
Python datetime
sureshraj43
 
C++ programming
C++ programmingC++ programming
C++ programming
Emertxe Information Technologies Pvt Ltd
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
eShikshak
 
File handling in c
File handling in cFile handling in c
File handling in c
aakanksha s
 
c++ lab manual
c++ lab manualc++ lab manual
c++ lab manual
Shrunkhala Wankhede
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
PANKAJKUMAR2519
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
Temesgen Molla
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
COMPUTER PROGRAMMING
COMPUTER PROGRAMMINGCOMPUTER PROGRAMMING
COMPUTER PROGRAMMING
imtiazalijoono
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
Mahantesh Devoor
 
History of Programming Language
History of Programming LanguageHistory of Programming Language
History of Programming Language
tahria123
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
Viji B
 
Python Loop
Python LoopPython Loop
Python Loop
Soba Arjun
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
Sumit Satam
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Dr. Jaydeep Patil
 
Constructor overloading & method overloading
Constructor overloading & method overloadingConstructor overloading & method overloading
Constructor overloading & method overloading
garishma bhatia
 
C++ Returning Objects
C++ Returning ObjectsC++ Returning Objects
C++ Returning Objects
Jay Patel
 
History of c
History of cHistory of c
History of c
Shipat Bhuiya
 
Unit 11. Graphics
Unit 11. GraphicsUnit 11. Graphics
Unit 11. Graphics
Ashim Lamichhane
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
Gaditek
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
eShikshak
 
File handling in c
File handling in cFile handling in c
File handling in c
aakanksha s
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
Mahantesh Devoor
 
History of Programming Language
History of Programming LanguageHistory of Programming Language
History of Programming Language
tahria123
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
Viji B
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
Sumit Satam
 
Constructor overloading & method overloading
Constructor overloading & method overloadingConstructor overloading & method overloading
Constructor overloading & method overloading
garishma bhatia
 
C++ Returning Objects
C++ Returning ObjectsC++ Returning Objects
C++ Returning Objects
Jay Patel
 

Viewers also liked (17)

Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Adam Mukharil Bachtiar
 
Algorithm and Programming (Sequential Structure)
Algorithm and Programming (Sequential Structure)Algorithm and Programming (Sequential Structure)
Algorithm and Programming (Sequential Structure)
Adam Mukharil Bachtiar
 
Php & mysql course syllabus
Php & mysql course syllabusPhp & mysql course syllabus
Php & mysql course syllabus
Papitha Velumani
 
Control structures repetition
Control structures   repetitionControl structures   repetition
Control structures repetition
Online
 
Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)
Adam Mukharil Bachtiar
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
MeoRamos
 
Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Record)
Algorithm and Programming (Record)Algorithm and Programming (Record)
Algorithm and Programming (Record)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Sorting)
Algorithm and Programming (Sorting)Algorithm and Programming (Sorting)
Algorithm and Programming (Sorting)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Searching)
Algorithm and Programming (Searching)Algorithm and Programming (Searching)
Algorithm and Programming (Searching)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Array)
Algorithm and Programming (Array)Algorithm and Programming (Array)
Algorithm and Programming (Array)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)
Adam Mukharil Bachtiar
 
Ang Tungkulin Ng Wika
Ang Tungkulin Ng WikaAng Tungkulin Ng Wika
Ang Tungkulin Ng Wika
Persia
 
C++ programming
C++ programmingC++ programming
C++ programming
viancagerone
 
Writing algorithms
Writing algorithmsWriting algorithms
Writing algorithms
Krishna Chaytaniah
 
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Adam Mukharil Bachtiar
 
Algorithm and Programming (Sequential Structure)
Algorithm and Programming (Sequential Structure)Algorithm and Programming (Sequential Structure)
Algorithm and Programming (Sequential Structure)
Adam Mukharil Bachtiar
 
Php & mysql course syllabus
Php & mysql course syllabusPhp & mysql course syllabus
Php & mysql course syllabus
Papitha Velumani
 
Control structures repetition
Control structures   repetitionControl structures   repetition
Control structures repetition
Online
 
Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)
Adam Mukharil Bachtiar
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
MeoRamos
 
Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)
Adam Mukharil Bachtiar
 
Ang Tungkulin Ng Wika
Ang Tungkulin Ng WikaAng Tungkulin Ng Wika
Ang Tungkulin Ng Wika
Persia
 
Ad

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

Control structures c2 c3
Control structures c2 c3Control structures c2 c3
Control structures c2 c3
Omar Al-Sabek
 
Algoritma 1 pertemuan 6
Algoritma 1 pertemuan 6Algoritma 1 pertemuan 6
Algoritma 1 pertemuan 6
adekurnia solihin
 
Control structures ii
Control structures ii Control structures ii
Control structures ii
Ahmad Idrees
 
Tugas3
Tugas3Tugas3
Tugas3
Av Ri
 
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHIBCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
Sowmya Jyothi
 
Programming paradigms c1
Programming paradigms c1Programming paradigms c1
Programming paradigms c1
Omar Al-Sabek
 
04 control structures 1
04 control structures 104 control structures 1
04 control structures 1
Jomel Penalba
 
02 ds and algorithm session_02
02 ds and algorithm session_0202 ds and algorithm session_02
02 ds and algorithm session_02
yogeshjoshi362
 
02 ds and algorithm session_02
02 ds and algorithm session_0202 ds and algorithm session_02
02 ds and algorithm session_02
Niit Care
 
Tugas alpro
Tugas alproTugas alpro
Tugas alpro
Welman Munthe
 
Algoritma pemrograman 12
Algoritma pemrograman 12Algoritma pemrograman 12
Algoritma pemrograman 12
ZainalAbidin909479
 
Repetition Structure
Repetition StructureRepetition Structure
Repetition Structure
PRN USM
 
Conditional Loops Python
Conditional Loops PythonConditional Loops Python
Conditional Loops Python
primeteacher32
 
ch8.ppt
ch8.pptch8.ppt
ch8.ppt
FakhriAlamKhan1
 
Control structures c2 c3
Control structures c2 c3Control structures c2 c3
Control structures c2 c3
Omar Al-Sabek
 
Control structures ii
Control structures ii Control structures ii
Control structures ii
Ahmad Idrees
 
Tugas3
Tugas3Tugas3
Tugas3
Av Ri
 
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHIBCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
Sowmya Jyothi
 
Programming paradigms c1
Programming paradigms c1Programming paradigms c1
Programming paradigms c1
Omar Al-Sabek
 
04 control structures 1
04 control structures 104 control structures 1
04 control structures 1
Jomel Penalba
 
02 ds and algorithm session_02
02 ds and algorithm session_0202 ds and algorithm session_02
02 ds and algorithm session_02
yogeshjoshi362
 
02 ds and algorithm session_02
02 ds and algorithm session_0202 ds and algorithm session_02
02 ds and algorithm session_02
Niit Care
 
Repetition Structure
Repetition StructureRepetition Structure
Repetition Structure
PRN USM
 
Conditional Loops Python
Conditional Loops PythonConditional Loops Python
Conditional Loops Python
primeteacher32
 
Ad

More from Adam Mukharil Bachtiar (20)

Materi 8 - Data Mining Association Rule.pdf
Materi 8 - Data Mining Association Rule.pdfMateri 8 - Data Mining Association Rule.pdf
Materi 8 - Data Mining Association Rule.pdf
Adam Mukharil Bachtiar
 
Clean Code - Formatting Code
Clean Code - Formatting CodeClean Code - Formatting Code
Clean Code - Formatting Code
Adam Mukharil Bachtiar
 
Clean Code - Clean Comments
Clean Code - Clean CommentsClean Code - Clean Comments
Clean Code - Clean Comments
Adam Mukharil Bachtiar
 
Clean Method
Clean MethodClean Method
Clean Method
Adam Mukharil Bachtiar
 
Clean Code and Design Pattern - Meaningful Names
Clean Code and Design Pattern - Meaningful NamesClean Code and Design Pattern - Meaningful Names
Clean Code and Design Pattern - Meaningful Names
Adam Mukharil Bachtiar
 
Model Driven Software Development
Model Driven Software DevelopmentModel Driven Software Development
Model Driven Software Development
Adam Mukharil Bachtiar
 
Scrum: How to Implement
Scrum: How to ImplementScrum: How to Implement
Scrum: How to Implement
Adam Mukharil Bachtiar
 
Pengujian Perangkat Lunak
Pengujian Perangkat LunakPengujian Perangkat Lunak
Pengujian Perangkat Lunak
Adam Mukharil Bachtiar
 
Data Mining Clustering
Data Mining ClusteringData Mining Clustering
Data Mining Clustering
Adam Mukharil Bachtiar
 
Data Mining Klasifikasi (Updated 30 Desember 2020)
Data Mining Klasifikasi (Updated 30 Desember 2020)Data Mining Klasifikasi (Updated 30 Desember 2020)
Data Mining Klasifikasi (Updated 30 Desember 2020)
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic ProgrammingAnalisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Divide and ConquerAnalisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma GreedyAnalisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma Greedy
Adam Mukharil Bachtiar
 
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Penerapan Strategi Algoritma Brute ForceAnalisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute ForceAnalisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
 
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Kelas-kelas Dasar Efisiensi AlgoritmaAnalisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Adam Mukharil Bachtiar
 
Analisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi AsimptotikAnalisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi Asimptotik
Adam Mukharil Bachtiar
 
Analisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi AsimptotikAnalisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi Asimptotik
Adam Mukharil Bachtiar
 
Activity Diagram
Activity DiagramActivity Diagram
Activity Diagram
Adam Mukharil Bachtiar
 
UML dan Use Case View
UML dan Use Case ViewUML dan Use Case View
UML dan Use Case View
Adam Mukharil Bachtiar
 
Materi 8 - Data Mining Association Rule.pdf
Materi 8 - Data Mining Association Rule.pdfMateri 8 - Data Mining Association Rule.pdf
Materi 8 - Data Mining Association Rule.pdf
Adam Mukharil Bachtiar
 
Clean Code and Design Pattern - Meaningful Names
Clean Code and Design Pattern - Meaningful NamesClean Code and Design Pattern - Meaningful Names
Clean Code and Design Pattern - Meaningful Names
Adam Mukharil Bachtiar
 
Data Mining Klasifikasi (Updated 30 Desember 2020)
Data Mining Klasifikasi (Updated 30 Desember 2020)Data Mining Klasifikasi (Updated 30 Desember 2020)
Data Mining Klasifikasi (Updated 30 Desember 2020)
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic ProgrammingAnalisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Divide and ConquerAnalisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma GreedyAnalisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma Greedy
Adam Mukharil Bachtiar
 
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Penerapan Strategi Algoritma Brute ForceAnalisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute ForceAnalisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
 
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Kelas-kelas Dasar Efisiensi AlgoritmaAnalisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Adam Mukharil Bachtiar
 
Analisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi AsimptotikAnalisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi Asimptotik
Adam Mukharil Bachtiar
 
Analisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi AsimptotikAnalisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi Asimptotik
Adam Mukharil Bachtiar
 

Recently uploaded (20)

Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FMEIntegrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
Agile Software Engineering Methodologies
Agile Software Engineering MethodologiesAgile Software Engineering Methodologies
Agile Software Engineering Methodologies
Gaurav Sharma
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
Leveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer IntentsLeveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer Intents
Keheliya Gallaba
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Essentials of Resource Planning in a Downturn
Essentials of Resource Planning in a DownturnEssentials of Resource Planning in a Downturn
Essentials of Resource Planning in a Downturn
OnePlan Solutions
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
Maximizing Business Value with AWS Consulting Services.pdf
Maximizing Business Value with AWS Consulting Services.pdfMaximizing Business Value with AWS Consulting Services.pdf
Maximizing Business Value with AWS Consulting Services.pdf
Elena Mia
 
Revolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management SoftwareRevolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management Software
Insurance Tech Services
 
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
COBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM CertificateCOBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM Certificate
VICTOR MAESTRE RAMIREZ
 
14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework
Angelo Theodorou
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your wayPlooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptxwAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink TemplateeeeeeeeeeeeeeeeeeeeeeeeeeNeuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlowDevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
Aarno Aukia
 
dp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdfdp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdf
pravkumarbiz
 
Providing Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better DataProviding Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better Data
Safe Software
 
Top 5 Task Management Software to Boost Productivity in 2025
Top 5 Task Management Software to Boost Productivity in 2025Top 5 Task Management Software to Boost Productivity in 2025
Top 5 Task Management Software to Boost Productivity in 2025
Orangescrum
 
Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FMEIntegrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
Agile Software Engineering Methodologies
Agile Software Engineering MethodologiesAgile Software Engineering Methodologies
Agile Software Engineering Methodologies
Gaurav Sharma
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
Leveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer IntentsLeveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer Intents
Keheliya Gallaba
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Essentials of Resource Planning in a Downturn
Essentials of Resource Planning in a DownturnEssentials of Resource Planning in a Downturn
Essentials of Resource Planning in a Downturn
OnePlan Solutions
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
Maximizing Business Value with AWS Consulting Services.pdf
Maximizing Business Value with AWS Consulting Services.pdfMaximizing Business Value with AWS Consulting Services.pdf
Maximizing Business Value with AWS Consulting Services.pdf
Elena Mia
 
Revolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management SoftwareRevolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management Software
Insurance Tech Services
 
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
COBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM CertificateCOBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM Certificate
VICTOR MAESTRE RAMIREZ
 
14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework
Angelo Theodorou
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your wayPlooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptxwAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink TemplateeeeeeeeeeeeeeeeeeeeeeeeeeNeuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlowDevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
Aarno Aukia
 
dp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdfdp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdf
pravkumarbiz
 
Providing Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better DataProviding Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better Data
Safe Software
 
Top 5 Task Management Software to Boost Productivity in 2025
Top 5 Task Management Software to Boost Productivity in 2025Top 5 Task Management Software to Boost Productivity in 2025
Top 5 Task Management Software to Boost Productivity in 2025
Orangescrum
 

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