SlideShare a Scribd company logo
Adam Mukharil Bachtiar
English Class
Informatics Engineering 2011
Algorithms and Programming
Branching Structure
Steps of the Day
Let’s Start
Definition Types of
Branching
Case Structure
Definition
Definition of Branching Structure
DefinitionofBranching
Structure
Algorithm structure which allow to execute
the instruction if the condition of this
instruction was met.
UsageofBranchingStructure
• Make menu structure
• Input validation
• Error handling
Types of Branching
Structure
All about Branching Structure
TypesofBranchingStructure
• One Case Branching
• Two Cases Branching
• Three/Many Cases Branching
• Many Conditions Branching
One Case Branching
Algorithm Notation:
if condition then
statement
endif
One Case Branching
Pascal Notation (if there’s only one statement):
if condition then
statement;
One Case Branching
Pascal Notation (if there are many statement):
if condition then
begin
statement 1;
statement 2;
end;
Algorithm and Programming (Branching Structure)
Example of One Case Branching (Algorithm)
1
2
3
4
5
6
7
8
9
10
11
12
Algoritma Bilangan_Ganjil
{I.S: Diinputkan satu bilangan oleh user}
{F.S: Menampilkan statement apabila bilangannya ganjil}
Kamus:
bil:integer
Algoritma:
input(bil)
if bil mod 2 = 1 then
output(‘Bilangan ‘,bil,’ adalah bilangan ganjil’)
endif
Example of One Case Branching (Pascal)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
program Bilangan_Ganjil;
uses crt;
var
bil:integer;
begin
write('Masukan sebuah bilangan bulat: ');
readln(bil);
if bil mod 2 = 1 then
writeln('Bilangan ',bil,' adalah bilangan ganjil');
writeln();
writeln('Ketik sembarang tombol untuk menutup...');
readkey();
end.
Two Cases Branching
Algorithm Notation:
if condition then
statement 1
else
statement 2
endif
Two Cases Branching
Pascal Notation (if there’s only one statement):
if condition then
statement 1
else
statement 2;
Two Cases Branching
Pascal Notation (if there are many statement):
if condition then
begin
statement 1;
statement 2;
end
else
begin
statement 3;
statement 4;
end;
Algorithm and Programming (Branching Structure)
Example of Two Cases Branching (Algorithm)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Algoritma Bilangan_Genap_Ganjil
{I.S: Diinputkan satu bilangan oleh user}
{F.S: Menampilkan statement bilangan ganjil atau genap}
Kamus:
bil:integer
Algoritma:
input(bil)
if bil mod 2 = 1 then
output(‘Bilangan ‘,bil,’ adalah bilangan ganjil’)
else
output(‘Bilangan ‘,bil,’ adalah bilangan genap’)
endif
Example of Two Cases Branching (Pascal)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
program Bilangan_Genap_ganjil;
uses crt;
var
bil:integer;
begin
write('Masukkan sebuah bilangan bulat: ');
readln(bil);
if bil mod 2 = 1 then
writeln('Bilangan ',bil,' adalah bilangan ganjil')
else
writeln('Bilangan ',bil,' adalah bilangan genap');
writeln();
writeln('Tekan sembarang tombol untuk menutup...');
readkey();
end.
Three/Many Cases Branching
Algorithm Notation:
if condition 1 then
statement 1
else
if condition 2 then
statement 2
else
if condition 3 then
statement 3
else
statement 4
endif
endif
endif
Three/Many Cases Branching
Pascal Notation (if there’s only one statement):
if condition 1 then
statement 1
else
if condition 2 then
statement 2
else
if condition 3 then
statement 3
else
statement 4;
Three/Many Cases Branching
Pascal Notation (if there are many statement):
if kondisi 1 then
begin
statement 1;
end
else
if kondisi 2 then
begin
statement 2;
end
else
if kondisi 3 then
begin
statement 3;
end
else
begin
statement 4;
end;
Algorithm and Programming (Branching Structure)
Example of Three/Many Cases Branching (Algorithm)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Algoritma Lampu_Lalu_Lintas
{I.S: Diinputkan satu warna lampu oleh user}
{F.S: Menampilkan statement sesuai warna lampu}
Kamus:
warna:string
Algoritma:
input(warna)
if warna = ‘MERAH’ then
output(‘Berhenti!’)
else
if warna = ‘KUNING’ then
output(‘Hati-Hati!’)
else
if warna = ‘HIJAU’ then
output(‘Jalan!’)
else
output(‘Warna salah!’)
endif
endif
endif
Example of Three/Many Cases Branching (Pascal)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
program Lampu_Lalu_Lintas;
uses crt;
var
warna:string;
begin
write('Masukkan sembarang warna: ');
readln(warna);
warna:=upcase(warna); {membuat uppercase}
if warna='MERAH' then
writeln('Berhenti!')
else
if warna='KUNING' then
writeln('Hati-Hati!')
else
if warna='HIJAU' then
writeln('Jalan!')
else
writeln('Warna salah!');
writeln();
writeln('Tekan sembarang tombol untuk menutup...');
readkey();
end.
Many Conditions Branching
• There are several cases which was requested more
than one conditions.
• Problem solving:
 Use AND : if all condition must be fulfilled
 Use OR : if only one condition must be fulfilled.
Algorithm and Programming (Branching Structure)
Example of Many Conditions Branching (Algorithm)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Algoritma Huruf_Konsonan
{I.S: Diinputkan satu huruf oleh user}
{F.S: Menampilkan pesan huruf konsonan jika konsonan}
Kamus:
k:char
Algoritma:
input(k)
if (k≠’a’)and(k≠’i’)and(k≠’u’)and(k≠’e’)and(k≠’o’) then
output(‘Huruf ‘,k,’ adalah huruf konsonan’)
else
output(‘Huruf ‘,k,’ adalah huruf vokal’)
endif
Example of Many Conditions Branching (Pascal)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
program Huruf_Konsonan;
uses crt;
var
k:char;
begin
write('Masukkan satu huruf: ');
readln(k);
k:=lowercase(k);
if (k<>'a')and(k<>'i')and(k<>'u')and(k<>'e')and(k<>'o') then
writeln('Huruf ',k,' adalah huruf konsonan')
else
writeln('Huruf ',k,' adalah huruf vokal');
writeln();
writeln('Tekan sembarang tombol untuk menutup...');
readkey();
end.
Case Structure
All About Case Structure
Case Structure
• Expression could be arithmetics or boolean.
• Expression was produce a constant.
• Value must be ordinal type (char, boolean, and
integer)
• Statement in otherwise will be executed if the other
value aren’t fulfilled.
Case Structure
Algorithm Notation:
case ekspresi
nilai 1 : statement 1
nilai 2 : statement 2
nilai 3 : statement 3
.
.
.
nilai n : statement n
otherwise : statement x
endcase
Case Structure
Pascal Notation:
case ekspresi of
nilai 1 : statement 1;
nilai 2 : statement 2;
nilai 3 : statement 3;
.
.
.
nilai n : statement n;
else statement x;
end;
Algorithm and Programming (Branching Structure)
Example of Case Structure (Algorithm)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Algoritma Ukuran_Baju
{I.S: Diinputkan satu huruf untuk ukuran baju oleh user}
{F.S: Menampilkan arti ukuran baju}
Kamus:
size:char
Algoritma:
input(size)
case size
‘S’:output(‘Kecil’);
‘M’:output(‘Sedang’);
‘L’:output(‘Besar’);
otherwise : output(‘Ukuran salah!’)
endcase
Example of Case Structure (Pascal)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
program Ukuran_Baju;
uses crt;
var
size:char;
begin
write('Masukkan ukuran baju [S/M/L]: ');
readln(size);
size:=upcase(size);
case size of
'S':writeln('Kecil');
'M':writeln('Sedang');
'L':writeln('Besar');
else writeln('Ukuran salah!');
end;
writeln();
writeln('Tekan sembarang tombol untuk menutup...');
readkey();
end.
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 (17)

C++ decision making
C++ decision makingC++ decision making
C++ decision making
Zohaib Ahmed
 
C# Loops
C# LoopsC# Loops
C# Loops
Hock Leng PUAH
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
Haard Shah
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
tanmaymodi4
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c language
tanmaymodi4
 
Pl sql programme
Pl sql programmePl sql programme
Pl sql programme
Dhilip Prakash
 
Loop control in c++
Loop control in c++Loop control in c++
Loop control in c++
Debre Tabor University
 
C++ control structure
C++ control structureC++ control structure
C++ control structure
bluejayjunior
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
Saurav Kumar
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
Gagan Deep
 
Storage classes in C
Storage classes in CStorage classes in C
Storage classes in C
Nitesh Bichwani
 
Iteration
IterationIteration
Iteration
Liam Dunphy
 
Control Statements, Array, Pointer, Structures
Control Statements, Array, Pointer, StructuresControl Statements, Array, Pointer, Structures
Control Statements, Array, Pointer, Structures
indra Kishor
 
C++ programming
C++ programmingC++ programming
C++ programming
viancagerone
 
Loops in java script
Loops in java scriptLoops in java script
Loops in java script
Ravi Bhadauria
 
Storage class in C Language
Storage class in C LanguageStorage class in C Language
Storage class in C Language
Nitesh Kumar Pandey
 
11 lec 11 storage class
11 lec 11 storage class11 lec 11 storage class
11 lec 11 storage class
kapil078
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
Zohaib Ahmed
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
Haard Shah
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
tanmaymodi4
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c language
tanmaymodi4
 
C++ control structure
C++ control structureC++ control structure
C++ control structure
bluejayjunior
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
Saurav Kumar
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
Gagan Deep
 
Control Statements, Array, Pointer, Structures
Control Statements, Array, Pointer, StructuresControl Statements, Array, Pointer, Structures
Control Statements, Array, Pointer, Structures
indra Kishor
 
11 lec 11 storage class
11 lec 11 storage class11 lec 11 storage class
11 lec 11 storage class
kapil078
 

Viewers also liked (9)

Algoritma dan flowchart
Algoritma dan flowchartAlgoritma dan flowchart
Algoritma dan flowchart
ismailtelkom
 
Pencarian Rute Terpendek Dengan Menggunakan Algoritma Djikstrak
Pencarian Rute Terpendek Dengan Menggunakan Algoritma DjikstrakPencarian Rute Terpendek Dengan Menggunakan Algoritma Djikstrak
Pencarian Rute Terpendek Dengan Menggunakan Algoritma Djikstrak
Arinten Hidayat
 
Project Studi Kasus Toko Langganan Sistem Informasi Akuntansi
Project Studi Kasus Toko Langganan Sistem Informasi AkuntansiProject Studi Kasus Toko Langganan Sistem Informasi Akuntansi
Project Studi Kasus Toko Langganan Sistem Informasi Akuntansi
Raysha md
 
Shortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma DijkstraShortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma Dijkstra
Onggo Wiryawan
 
Algoritma pencarian lintasan jalur terpendek
Algoritma pencarian lintasan jalur terpendekAlgoritma pencarian lintasan jalur terpendek
Algoritma pencarian lintasan jalur terpendek
Laili Wahyunita
 
Jurnal - Muhamad Imam - Aplikasi Pencarian Rute Terpendek Dengan Menggunakan ...
Jurnal - Muhamad Imam - Aplikasi Pencarian Rute Terpendek Dengan Menggunakan ...Jurnal - Muhamad Imam - Aplikasi Pencarian Rute Terpendek Dengan Menggunakan ...
Jurnal - Muhamad Imam - Aplikasi Pencarian Rute Terpendek Dengan Menggunakan ...
Muhamad Imam
 
Pengulangan for Algoritma
Pengulangan for AlgoritmaPengulangan for Algoritma
Pengulangan for Algoritma
casnadi
 
Algoritma Pemrograman (Flowchart) - Logika dan Algoritma
Algoritma Pemrograman (Flowchart) - Logika dan AlgoritmaAlgoritma Pemrograman (Flowchart) - Logika dan Algoritma
Algoritma Pemrograman (Flowchart) - Logika dan Algoritma
Ari Septiawan
 
Pertemuan 1 algoritma pemrograman dan flowchart
Pertemuan 1   algoritma pemrograman dan flowchartPertemuan 1   algoritma pemrograman dan flowchart
Pertemuan 1 algoritma pemrograman dan flowchart
iphientcomp
 
Algoritma dan flowchart
Algoritma dan flowchartAlgoritma dan flowchart
Algoritma dan flowchart
ismailtelkom
 
Pencarian Rute Terpendek Dengan Menggunakan Algoritma Djikstrak
Pencarian Rute Terpendek Dengan Menggunakan Algoritma DjikstrakPencarian Rute Terpendek Dengan Menggunakan Algoritma Djikstrak
Pencarian Rute Terpendek Dengan Menggunakan Algoritma Djikstrak
Arinten Hidayat
 
Project Studi Kasus Toko Langganan Sistem Informasi Akuntansi
Project Studi Kasus Toko Langganan Sistem Informasi AkuntansiProject Studi Kasus Toko Langganan Sistem Informasi Akuntansi
Project Studi Kasus Toko Langganan Sistem Informasi Akuntansi
Raysha md
 
Shortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma DijkstraShortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma Dijkstra
Onggo Wiryawan
 
Algoritma pencarian lintasan jalur terpendek
Algoritma pencarian lintasan jalur terpendekAlgoritma pencarian lintasan jalur terpendek
Algoritma pencarian lintasan jalur terpendek
Laili Wahyunita
 
Jurnal - Muhamad Imam - Aplikasi Pencarian Rute Terpendek Dengan Menggunakan ...
Jurnal - Muhamad Imam - Aplikasi Pencarian Rute Terpendek Dengan Menggunakan ...Jurnal - Muhamad Imam - Aplikasi Pencarian Rute Terpendek Dengan Menggunakan ...
Jurnal - Muhamad Imam - Aplikasi Pencarian Rute Terpendek Dengan Menggunakan ...
Muhamad Imam
 
Pengulangan for Algoritma
Pengulangan for AlgoritmaPengulangan for Algoritma
Pengulangan for Algoritma
casnadi
 
Algoritma Pemrograman (Flowchart) - Logika dan Algoritma
Algoritma Pemrograman (Flowchart) - Logika dan AlgoritmaAlgoritma Pemrograman (Flowchart) - Logika dan Algoritma
Algoritma Pemrograman (Flowchart) - Logika dan Algoritma
Ari Septiawan
 
Pertemuan 1 algoritma pemrograman dan flowchart
Pertemuan 1   algoritma pemrograman dan flowchartPertemuan 1   algoritma pemrograman dan flowchart
Pertemuan 1 algoritma pemrograman dan flowchart
iphientcomp
 
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
 
Ad

Recently uploaded (20)

AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA TechnologiesAI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
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
 
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
 
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
 
Software Testing & it’s types (DevOps)
Software  Testing & it’s  types (DevOps)Software  Testing & it’s  types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
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
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across IndustriesArtificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
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
 
Who will create the languages of the future?
Who will create the languages of the future?Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentricIntegration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Natan Silnitsky
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 WebinarPorting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
FME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable InsightsFME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable Insights
Safe Software
 
Key AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence CompaniesKey AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence Companies
Mypcot Infotech
 
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
BradBedford3
 
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
WSO2
 
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
 
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdfTop 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Trackobit
 
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
 
AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA TechnologiesAI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
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
 
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
 
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
 
Software Testing & it’s types (DevOps)
Software  Testing & it’s  types (DevOps)Software  Testing & it’s  types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
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
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across IndustriesArtificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
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
 
Who will create the languages of the future?
Who will create the languages of the future?Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentricIntegration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Natan Silnitsky
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 WebinarPorting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
FME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable InsightsFME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable Insights
Safe Software
 
Key AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence CompaniesKey AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence Companies
Mypcot Infotech
 
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
BradBedford3
 
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
WSO2
 
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
 
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdfTop 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Trackobit
 
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
 

Algorithm and Programming (Branching Structure)

  • 1. Adam Mukharil Bachtiar English Class Informatics Engineering 2011 Algorithms and Programming Branching Structure
  • 2. Steps of the Day Let’s Start Definition Types of Branching Case Structure
  • 4. DefinitionofBranching Structure Algorithm structure which allow to execute the instruction if the condition of this instruction was met.
  • 5. UsageofBranchingStructure • Make menu structure • Input validation • Error handling
  • 6. Types of Branching Structure All about Branching Structure
  • 7. TypesofBranchingStructure • One Case Branching • Two Cases Branching • Three/Many Cases Branching • Many Conditions Branching
  • 8. One Case Branching Algorithm Notation: if condition then statement endif
  • 9. One Case Branching Pascal Notation (if there’s only one statement): if condition then statement;
  • 10. One Case Branching Pascal Notation (if there are many statement): if condition then begin statement 1; statement 2; end;
  • 12. Example of One Case Branching (Algorithm) 1 2 3 4 5 6 7 8 9 10 11 12 Algoritma Bilangan_Ganjil {I.S: Diinputkan satu bilangan oleh user} {F.S: Menampilkan statement apabila bilangannya ganjil} Kamus: bil:integer Algoritma: input(bil) if bil mod 2 = 1 then output(‘Bilangan ‘,bil,’ adalah bilangan ganjil’) endif
  • 13. Example of One Case Branching (Pascal) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 program Bilangan_Ganjil; uses crt; var bil:integer; begin write('Masukan sebuah bilangan bulat: '); readln(bil); if bil mod 2 = 1 then writeln('Bilangan ',bil,' adalah bilangan ganjil'); writeln(); writeln('Ketik sembarang tombol untuk menutup...'); readkey(); end.
  • 14. Two Cases Branching Algorithm Notation: if condition then statement 1 else statement 2 endif
  • 15. Two Cases Branching Pascal Notation (if there’s only one statement): if condition then statement 1 else statement 2;
  • 16. Two Cases Branching Pascal Notation (if there are many statement): if condition then begin statement 1; statement 2; end else begin statement 3; statement 4; end;
  • 18. Example of Two Cases Branching (Algorithm) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Algoritma Bilangan_Genap_Ganjil {I.S: Diinputkan satu bilangan oleh user} {F.S: Menampilkan statement bilangan ganjil atau genap} Kamus: bil:integer Algoritma: input(bil) if bil mod 2 = 1 then output(‘Bilangan ‘,bil,’ adalah bilangan ganjil’) else output(‘Bilangan ‘,bil,’ adalah bilangan genap’) endif
  • 19. Example of Two Cases Branching (Pascal) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 program Bilangan_Genap_ganjil; uses crt; var bil:integer; begin write('Masukkan sebuah bilangan bulat: '); readln(bil); if bil mod 2 = 1 then writeln('Bilangan ',bil,' adalah bilangan ganjil') else writeln('Bilangan ',bil,' adalah bilangan genap'); writeln(); writeln('Tekan sembarang tombol untuk menutup...'); readkey(); end.
  • 20. Three/Many Cases Branching Algorithm Notation: if condition 1 then statement 1 else if condition 2 then statement 2 else if condition 3 then statement 3 else statement 4 endif endif endif
  • 21. Three/Many Cases Branching Pascal Notation (if there’s only one statement): if condition 1 then statement 1 else if condition 2 then statement 2 else if condition 3 then statement 3 else statement 4;
  • 22. Three/Many Cases Branching Pascal Notation (if there are many statement): if kondisi 1 then begin statement 1; end else if kondisi 2 then begin statement 2; end else if kondisi 3 then begin statement 3; end else begin statement 4; end;
  • 24. Example of Three/Many Cases Branching (Algorithm) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 Algoritma Lampu_Lalu_Lintas {I.S: Diinputkan satu warna lampu oleh user} {F.S: Menampilkan statement sesuai warna lampu} Kamus: warna:string Algoritma: input(warna) if warna = ‘MERAH’ then output(‘Berhenti!’) else if warna = ‘KUNING’ then output(‘Hati-Hati!’) else if warna = ‘HIJAU’ then output(‘Jalan!’) else output(‘Warna salah!’) endif endif endif
  • 25. Example of Three/Many Cases Branching (Pascal) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 program Lampu_Lalu_Lintas; uses crt; var warna:string; begin write('Masukkan sembarang warna: '); readln(warna); warna:=upcase(warna); {membuat uppercase} if warna='MERAH' then writeln('Berhenti!') else if warna='KUNING' then writeln('Hati-Hati!') else if warna='HIJAU' then writeln('Jalan!') else writeln('Warna salah!'); writeln(); writeln('Tekan sembarang tombol untuk menutup...'); readkey(); end.
  • 26. Many Conditions Branching • There are several cases which was requested more than one conditions. • Problem solving:  Use AND : if all condition must be fulfilled  Use OR : if only one condition must be fulfilled.
  • 28. Example of Many Conditions Branching (Algorithm) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Algoritma Huruf_Konsonan {I.S: Diinputkan satu huruf oleh user} {F.S: Menampilkan pesan huruf konsonan jika konsonan} Kamus: k:char Algoritma: input(k) if (k≠’a’)and(k≠’i’)and(k≠’u’)and(k≠’e’)and(k≠’o’) then output(‘Huruf ‘,k,’ adalah huruf konsonan’) else output(‘Huruf ‘,k,’ adalah huruf vokal’) endif
  • 29. Example of Many Conditions Branching (Pascal) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 program Huruf_Konsonan; uses crt; var k:char; begin write('Masukkan satu huruf: '); readln(k); k:=lowercase(k); if (k<>'a')and(k<>'i')and(k<>'u')and(k<>'e')and(k<>'o') then writeln('Huruf ',k,' adalah huruf konsonan') else writeln('Huruf ',k,' adalah huruf vokal'); writeln(); writeln('Tekan sembarang tombol untuk menutup...'); readkey(); end.
  • 30. Case Structure All About Case Structure
  • 31. Case Structure • Expression could be arithmetics or boolean. • Expression was produce a constant. • Value must be ordinal type (char, boolean, and integer) • Statement in otherwise will be executed if the other value aren’t fulfilled.
  • 32. Case Structure Algorithm Notation: case ekspresi nilai 1 : statement 1 nilai 2 : statement 2 nilai 3 : statement 3 . . . nilai n : statement n otherwise : statement x endcase
  • 33. Case Structure Pascal Notation: case ekspresi of nilai 1 : statement 1; nilai 2 : statement 2; nilai 3 : statement 3; . . . nilai n : statement n; else statement x; end;
  • 35. Example of Case Structure (Algorithm) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Algoritma Ukuran_Baju {I.S: Diinputkan satu huruf untuk ukuran baju oleh user} {F.S: Menampilkan arti ukuran baju} Kamus: size:char Algoritma: input(size) case size ‘S’:output(‘Kecil’); ‘M’:output(‘Sedang’); ‘L’:output(‘Besar’); otherwise : output(‘Ukuran salah!’) endcase
  • 36. Example of Case Structure (Pascal) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 program Ukuran_Baju; uses crt; var size:char; begin write('Masukkan ukuran baju [S/M/L]: '); readln(size); size:=upcase(size); case size of 'S':writeln('Kecil'); 'M':writeln('Sedang'); 'L':writeln('Besar'); else writeln('Ukuran salah!'); end; writeln(); writeln('Tekan sembarang tombol untuk menutup...'); readkey(); end.
  • 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