SlideShare una empresa de Scribd logo
1 de 37
Descargar para leer sin conexión
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;
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;
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;
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;
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

Más contenido relacionado

La actualidad más candente

Operator Overloading
Operator OverloadingOperator Overloading
Operator OverloadingNilesh Dalvi
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptxAkshayAggarwal79
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in pythonTMARAGATHAM
 
Jumping statements
Jumping statementsJumping statements
Jumping statementsSuneel Dogra
 
Object oriented programming with python
Object oriented programming with pythonObject oriented programming with python
Object oriented programming with pythonArslan Arshad
 
Python If Else | If Else Statement In Python | Edureka
Python If Else | If Else Statement In Python | EdurekaPython If Else | If Else Statement In Python | Edureka
Python If Else | If Else Statement In Python | EdurekaEdureka!
 
Recursive Function
Recursive FunctionRecursive Function
Recursive FunctionHarsh Pathak
 
Switch statements in Java
Switch statements  in JavaSwitch statements  in Java
Switch statements in JavaJin Castor
 
Python: Modules and Packages
Python: Modules and PackagesPython: Modules and Packages
Python: Modules and PackagesDamian T. Gordon
 
Modules in Python Programming
Modules in Python ProgrammingModules in Python Programming
Modules in Python Programmingsambitmandal
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonPriyankaC44
 

La actualidad más candente (20)

Algorithmic Notations
Algorithmic NotationsAlgorithmic Notations
Algorithmic Notations
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
 
C program compiler presentation
C program compiler presentationC program compiler presentation
C program compiler presentation
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Python dictionary
Python   dictionaryPython   dictionary
Python dictionary
 
Dictionary
DictionaryDictionary
Dictionary
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Object oriented programming with python
Object oriented programming with pythonObject oriented programming with python
Object oriented programming with python
 
Python If Else | If Else Statement In Python | Edureka
Python If Else | If Else Statement In Python | EdurekaPython If Else | If Else Statement In Python | Edureka
Python If Else | If Else Statement In Python | Edureka
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
Switch statements in Java
Switch statements  in JavaSwitch statements  in Java
Switch statements in Java
 
Python: Modules and Packages
Python: Modules and PackagesPython: Modules and Packages
Python: Modules and Packages
 
Modules in Python Programming
Modules in Python ProgrammingModules in Python Programming
Modules in Python Programming
 
Python for loop
Python for loopPython for loop
Python for loop
 
Python basic
Python basicPython basic
Python basic
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in Python
 

Destacado

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 syllabusPapitha Velumani
 
Control structures repetition
Control structures   repetitionControl structures   repetition
Control structures repetitionOnline
 
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 casesMeoRamos
 
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 WikaPersia
 

Destacado (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 ...
 
Algorithm and Programming (Sequential Structure)
Algorithm and Programming (Sequential Structure)Algorithm and Programming (Sequential Structure)
Algorithm and Programming (Sequential Structure)
 
Php & mysql course syllabus
Php & mysql course syllabusPhp & mysql course syllabus
Php & mysql course syllabus
 
Control structures repetition
Control structures   repetitionControl structures   repetition
Control structures repetition
 
Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)
 
Fil11 -mga tungkulin ng wika (1)
 Fil11 -mga tungkulin ng wika (1) Fil11 -mga tungkulin ng wika (1)
Fil11 -mga tungkulin ng wika (1)
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
 
Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)
 
Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)
 
Algorithm and Programming (Record)
Algorithm and Programming (Record)Algorithm and Programming (Record)
Algorithm and Programming (Record)
 
Algorithm and Programming (Sorting)
Algorithm and Programming (Sorting)Algorithm and Programming (Sorting)
Algorithm and Programming (Sorting)
 
Algorithm and Programming (Searching)
Algorithm and Programming (Searching)Algorithm and Programming (Searching)
Algorithm and Programming (Searching)
 
Algorithm and Programming (Array)
Algorithm and Programming (Array)Algorithm and Programming (Array)
Algorithm and Programming (Array)
 
Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)
 
Ang Tungkulin Ng Wika
Ang Tungkulin Ng WikaAng Tungkulin Ng Wika
Ang Tungkulin Ng Wika
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Writing algorithms
Writing algorithmsWriting algorithms
Writing algorithms
 

Similar a Algorithm and Programming (Looping Structure)

Similar a Algorithm and Programming (Looping Structure) (20)

C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)
 
Looping
LoopingLooping
Looping
 
Loops in Python.pptx
Loops in Python.pptxLoops in Python.pptx
Loops in Python.pptx
 
12 lec 12 loop
12 lec 12 loop 12 lec 12 loop
12 lec 12 loop
 
Loops
LoopsLoops
Loops
 
C++ Course - Lesson 1
C++ Course - Lesson 1C++ Course - Lesson 1
C++ Course - Lesson 1
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
 
C++ control structure
C++ control structureC++ control structure
C++ control structure
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java Programming
 
While loop
While loopWhile loop
While loop
 
Python programming workshop session 2
Python programming workshop session 2Python programming workshop session 2
Python programming workshop session 2
 
Session 3
Session 3Session 3
Session 3
 
Python ppt
Python pptPython ppt
Python ppt
 
Matlab Script - Loop Control
Matlab Script - Loop ControlMatlab Script - Loop Control
Matlab Script - Loop Control
 
Dart workshop
Dart workshopDart workshop
Dart workshop
 
06 Loops
06 Loops06 Loops
06 Loops
 
SPL 8 | Loop Statements in C
SPL 8 | Loop Statements in CSPL 8 | Loop Statements in C
SPL 8 | Loop Statements in C
 
COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
C++ loop
C++ loop C++ loop
C++ loop
 

Más de 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.pdfAdam 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 NamesAdam 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 ProgrammingAdam 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 ConquerAdam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma GreedyAnalisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma GreedyAdam 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 ForceAdam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute ForceAnalisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute ForceAdam 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 AlgoritmaAdam Mukharil Bachtiar
 
Analisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi AsimptotikAnalisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi AsimptotikAdam Mukharil Bachtiar
 
Analisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi AsimptotikAnalisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi AsimptotikAdam Mukharil Bachtiar
 

Más de 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
 
Clean Code - Formatting Code
Clean Code - Formatting CodeClean Code - Formatting Code
Clean Code - Formatting Code
 
Clean Code - Clean Comments
Clean Code - Clean CommentsClean Code - Clean Comments
Clean Code - Clean Comments
 
Clean Method
Clean MethodClean Method
Clean Method
 
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
 
Model Driven Software Development
Model Driven Software DevelopmentModel Driven Software Development
Model Driven Software Development
 
Scrum: How to Implement
Scrum: How to ImplementScrum: How to Implement
Scrum: How to Implement
 
Pengujian Perangkat Lunak
Pengujian Perangkat LunakPengujian Perangkat Lunak
Pengujian Perangkat Lunak
 
Data Mining Clustering
Data Mining ClusteringData Mining Clustering
Data Mining Clustering
 
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)
 
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic ProgrammingAnalisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic Programming
 
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
 
Analisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma GreedyAnalisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma Greedy
 
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
 
Analisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute ForceAnalisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute Force
 
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
 
Analisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi AsimptotikAnalisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi Asimptotik
 
Analisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi AsimptotikAnalisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi Asimptotik
 
Activity Diagram
Activity DiagramActivity Diagram
Activity Diagram
 
UML dan Use Case View
UML dan Use Case ViewUML dan Use Case View
UML dan Use Case View
 

Último

A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 

Último (20)

A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 

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;
  • 11.
  • 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;
  • 16.
  • 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;
  • 23.
  • 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;
  • 29.
  • 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: adfbipotter@gmail.com Blog: http://adfbipotter.wordpress.com Copyright © Adam Mukharil Bachtiar 2011