SlideShare a Scribd company logo
1 of 8
Download to read offline
Nama : Welman Bramco Munthe
NPM : 15 111 220
Kelas : TIF 15 A Reguler Malam
Algoritma dan Pemrograman I – Looping
1. While - Do Result :
program whileLoop;
var
a: integer;
begin
a := 10;
while a < 20 do
begin
writeln('value of a: ', a);
a := a + 1;
end;
end.
When the above code is compiled and
executed, what is the result? And draw the
flowchart!
Flowchart :
START
Var a : int
a := 10
a < 20 ?
Print
Value of a :
a := a + 1
Yes
No
END
2. For – Do Result :
program forLoop;
var
a: integer;
begin
for a := 10 to 20 do
begin
writeln('value of a: ', a);
end;
end.
When the above code is compiled and
executed, what is the result? And draw
the flowchart!
START
Var a : int
a := 10
a <= 20 ?
Print
Value of a :
a := a + 1
Yes
END
No
3. Repeat Until Result :
program repeatUntilLoop;
var
a: integer;
begin
a := 10;
(* repeat until loop execution *)
repeat
writeln('value of a: ', a);
a := a + 1
until a = 20;
end.
When the above code is compiled and
executed, what is the result? And draw the
flowchart!
Flowchart :
START
a := 10
a := a + 1
a <20 ?
Print
Value of a :
Yes
No
END
Var a : int
4. NestedPrime Result :
program nestedPrime;
var
i, j:integer;
begin
for i := 2 to 50 do
begin
for j := 2 to i do
if (i mod j)=0 then
break; {* if factor found, not prime *}
if(j = i) then
writeln(i , ' is prime' );
end;
end.
When the above code is compiled and
executed, what is the result? And draw the
flowchart!
Flowchart :
Var i, j : int
START
i := 2
i <= 50 ?
j := 2
Yes
j < i ?
Yes
i mod j = 0 ?
Break;
True
j = i ?
False
Print
i ’ is prime’;
True
No
j = j + 1;
i = i + 1;
END
False
No
5. Break Result:
program exBreak;
var
a: integer;
begin
a := 10;
(* while loop execution *)
while a < 20 do
begin
writeln('value of a: ', a);
a:=a +1;
if( a > 15) then
(* terminate the loop using break statement *)
break;
end;
end.
When the above code is compiled and executed, what is the result? And draw the flowchart!
Flowchart :
START
Var a : int
a := 10
a < 20 ?
Print
Value of a :
a := a + 1
a > 15 ?
Yes
Yes
Break;
No
No
END
6. Continue Result :
program exContinue;
var
a: integer;
begin
a := 10;
(* repeat until loop execution *)
repeat
if( a = 15) then
begin
(* skip the iteration *)
a := a + 1;
continue;
end;
writeln('value of a: ', a);
a := a+1;
until ( a = 20 );
end.
When the above code is compiled and executed, what is the result? And draw the flowchart!
Flowchart :
Var a : int
a := 10
START
a = 20 ?
a := a + 1
Continue;
No
Print
Value of a :
Yes
a = 15 ?
END
Yes
No
7. Goto Result:
program exGoto;
label 1;
var
a : integer;
begin
a := 10;
(* repeat until loop execution *)
1: repeat
if( a = 15) then
begin
(* skip the iteration *)
a := a + 1;
goto 1;
end;
writeln('value of a: ', a);
a:= a +1;
until a = 20;
end.
When the above code is compiled and executed, what is the result? And draw the flowchart!
Flowchart :
Var a : int
a := 10
a = 20 ?
a := a + 1
Goto 1;
No
Print
Value of a :
Yes
a = 15 ?
END
Yes
No
START
Label 1

More Related Content

Viewers also liked

Diktat kuliah Algoritma dan Pemograman
Diktat kuliah Algoritma dan PemogramanDiktat kuliah Algoritma dan Pemograman
Diktat kuliah Algoritma dan PemogramanPisca Prasetyo
 
Algoritma dan Pemrograman C++ (Pseudocode & Flowchart)
Algoritma dan Pemrograman C++ (Pseudocode & Flowchart)Algoritma dan Pemrograman C++ (Pseudocode & Flowchart)
Algoritma dan Pemrograman C++ (Pseudocode & Flowchart)Nabil Muhammad Firdaus
 
Pengenalan dan definisi flowchart
Pengenalan dan definisi flowchartPengenalan dan definisi flowchart
Pengenalan dan definisi flowchartBarmed Studio
 
Analytical tool for determination of traces of cu (ii)
Analytical tool for determination of traces of cu (ii)Analytical tool for determination of traces of cu (ii)
Analytical tool for determination of traces of cu (ii)Alexander Decker
 
Fractional-number Algorithm
Fractional-number AlgorithmFractional-number Algorithm
Fractional-number Algorithmstaffpengajar
 
Alpro soal kelompok (9 soal) 2
Alpro soal kelompok (9 soal) 2Alpro soal kelompok (9 soal) 2
Alpro soal kelompok (9 soal) 21300018047
 
Pemrograman komputer 1 (algoritma)
Pemrograman komputer  1 (algoritma)Pemrograman komputer  1 (algoritma)
Pemrograman komputer 1 (algoritma)jayamartha
 
Kulum alin-11 jan2014
Kulum alin-11 jan2014Kulum alin-11 jan2014
Kulum alin-11 jan2014rolly purnomo
 
Algoritma pemrograman
Algoritma pemrogramanAlgoritma pemrograman
Algoritma pemrogramandian pw
 
Alpro I-latihan_kasus-r11102015
Alpro I-latihan_kasus-r11102015Alpro I-latihan_kasus-r11102015
Alpro I-latihan_kasus-r11102015staffpengajar
 
Algoritma dan pemrograman 1
Algoritma dan pemrograman 1Algoritma dan pemrograman 1
Algoritma dan pemrograman 1Javra Ketoprak
 
Eliminasi gauss
Eliminasi gaussEliminasi gauss
Eliminasi gaussagung8463
 
Matriks eselon baris dan eselon baris tereduksi
Matriks eselon baris dan eselon baris tereduksiMatriks eselon baris dan eselon baris tereduksi
Matriks eselon baris dan eselon baris tereduksiElemantking Daeva
 
Modul Logika dan algoritma
Modul Logika dan algoritmaModul Logika dan algoritma
Modul Logika dan algoritmalinda_rosalina
 

Viewers also liked (20)

Diktat kuliah Algoritma dan Pemograman
Diktat kuliah Algoritma dan PemogramanDiktat kuliah Algoritma dan Pemograman
Diktat kuliah Algoritma dan Pemograman
 
Algoritma flowchart
Algoritma flowchartAlgoritma flowchart
Algoritma flowchart
 
Algoritma dan Pemrograman C++ (Pseudocode & Flowchart)
Algoritma dan Pemrograman C++ (Pseudocode & Flowchart)Algoritma dan Pemrograman C++ (Pseudocode & Flowchart)
Algoritma dan Pemrograman C++ (Pseudocode & Flowchart)
 
Pengenalan dan definisi flowchart
Pengenalan dan definisi flowchartPengenalan dan definisi flowchart
Pengenalan dan definisi flowchart
 
Minggu_6 TIF305
Minggu_6 TIF305Minggu_6 TIF305
Minggu_6 TIF305
 
Analytical tool for determination of traces of cu (ii)
Analytical tool for determination of traces of cu (ii)Analytical tool for determination of traces of cu (ii)
Analytical tool for determination of traces of cu (ii)
 
About vb script-sns
About vb script-snsAbout vb script-sns
About vb script-sns
 
Tugas perulangan
Tugas perulanganTugas perulangan
Tugas perulangan
 
Fractional-number Algorithm
Fractional-number AlgorithmFractional-number Algorithm
Fractional-number Algorithm
 
Alpro soal kelompok (9 soal) 2
Alpro soal kelompok (9 soal) 2Alpro soal kelompok (9 soal) 2
Alpro soal kelompok (9 soal) 2
 
Pemrograman komputer 1 (algoritma)
Pemrograman komputer  1 (algoritma)Pemrograman komputer  1 (algoritma)
Pemrograman komputer 1 (algoritma)
 
Kulum alin-11 jan2014
Kulum alin-11 jan2014Kulum alin-11 jan2014
Kulum alin-11 jan2014
 
Algoritma pemrograman
Algoritma pemrogramanAlgoritma pemrograman
Algoritma pemrograman
 
Alpro I-latihan_kasus-r11102015
Alpro I-latihan_kasus-r11102015Alpro I-latihan_kasus-r11102015
Alpro I-latihan_kasus-r11102015
 
Algoritma dan pemrograman 1
Algoritma dan pemrograman 1Algoritma dan pemrograman 1
Algoritma dan pemrograman 1
 
Eliminasi gauss
Eliminasi gaussEliminasi gauss
Eliminasi gauss
 
03 pseudocode
03 pseudocode03 pseudocode
03 pseudocode
 
Matriks eselon baris dan eselon baris tereduksi
Matriks eselon baris dan eselon baris tereduksiMatriks eselon baris dan eselon baris tereduksi
Matriks eselon baris dan eselon baris tereduksi
 
Modul Logika dan algoritma
Modul Logika dan algoritmaModul Logika dan algoritma
Modul Logika dan algoritma
 
Latihan latihan logika algoritma
Latihan latihan logika algoritmaLatihan latihan logika algoritma
Latihan latihan logika algoritma
 

Similar to Tugas alpro

Lecture#5 Operators in C++
Lecture#5 Operators in C++Lecture#5 Operators in C++
Lecture#5 Operators in C++NUST Stuff
 
C code This program will calculate the sum of 10 positive .docx
 C code This program will calculate the sum of 10 positive .docx C code This program will calculate the sum of 10 positive .docx
C code This program will calculate the sum of 10 positive .docxaryan532920
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans incnayakq
 
PL /SQL program UNIT 5 DMS 22319
PL /SQL program UNIT 5 DMS 22319PL /SQL program UNIT 5 DMS 22319
PL /SQL program UNIT 5 DMS 22319ARVIND SARDAR
 
Bti1022 lab sheet 7
Bti1022 lab sheet 7Bti1022 lab sheet 7
Bti1022 lab sheet 7alish sha
 
Dti2143 lab sheet 8
Dti2143 lab sheet 8Dti2143 lab sheet 8
Dti2143 lab sheet 8alish sha
 
Dti2143 lab sheet 6
Dti2143 lab sheet 6Dti2143 lab sheet 6
Dti2143 lab sheet 6alish sha
 
E1 – FundamentalsPlease refer to announcements for details about.docx
E1 – FundamentalsPlease refer to announcements for details about.docxE1 – FundamentalsPlease refer to announcements for details about.docx
E1 – FundamentalsPlease refer to announcements for details about.docxjacksnathalie
 
12 lec 12 loop
12 lec 12 loop 12 lec 12 loop
12 lec 12 loop kapil078
 

Similar to Tugas alpro (20)

Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020
 
Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020
 
Lecture#5 Operators in C++
Lecture#5 Operators in C++Lecture#5 Operators in C++
Lecture#5 Operators in C++
 
Looping statements
Looping statementsLooping statements
Looping statements
 
C code This program will calculate the sum of 10 positive .docx
 C code This program will calculate the sum of 10 positive .docx C code This program will calculate the sum of 10 positive .docx
C code This program will calculate the sum of 10 positive .docx
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Loops
LoopsLoops
Loops
 
PL /SQL program UNIT 5 DMS 22319
PL /SQL program UNIT 5 DMS 22319PL /SQL program UNIT 5 DMS 22319
PL /SQL program UNIT 5 DMS 22319
 
3.2 looping statement
3.2 looping statement3.2 looping statement
3.2 looping statement
 
C-LOOP-Session-2.pptx
C-LOOP-Session-2.pptxC-LOOP-Session-2.pptx
C-LOOP-Session-2.pptx
 
Bti1022 lab sheet 7
Bti1022 lab sheet 7Bti1022 lab sheet 7
Bti1022 lab sheet 7
 
Dti2143 lab sheet 8
Dti2143 lab sheet 8Dti2143 lab sheet 8
Dti2143 lab sheet 8
 
Plsql programs(encrypted)
Plsql programs(encrypted)Plsql programs(encrypted)
Plsql programs(encrypted)
 
Dti2143 lab sheet 6
Dti2143 lab sheet 6Dti2143 lab sheet 6
Dti2143 lab sheet 6
 
E1 – FundamentalsPlease refer to announcements for details about.docx
E1 – FundamentalsPlease refer to announcements for details about.docxE1 – FundamentalsPlease refer to announcements for details about.docx
E1 – FundamentalsPlease refer to announcements for details about.docx
 
PSP LAB MANUAL.pdf
PSP LAB MANUAL.pdfPSP LAB MANUAL.pdf
PSP LAB MANUAL.pdf
 
ICP - Lecture 9
ICP - Lecture 9ICP - Lecture 9
ICP - Lecture 9
 
12 lec 12 loop
12 lec 12 loop 12 lec 12 loop
12 lec 12 loop
 

Recently uploaded

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 

Tugas alpro

  • 1. Nama : Welman Bramco Munthe NPM : 15 111 220 Kelas : TIF 15 A Reguler Malam Algoritma dan Pemrograman I – Looping 1. While - Do Result : program whileLoop; var a: integer; begin a := 10; while a < 20 do begin writeln('value of a: ', a); a := a + 1; end; end. When the above code is compiled and executed, what is the result? And draw the flowchart! Flowchart : START Var a : int a := 10 a < 20 ? Print Value of a : a := a + 1 Yes No END
  • 2. 2. For – Do Result : program forLoop; var a: integer; begin for a := 10 to 20 do begin writeln('value of a: ', a); end; end. When the above code is compiled and executed, what is the result? And draw the flowchart! START Var a : int a := 10 a <= 20 ? Print Value of a : a := a + 1 Yes END No
  • 3. 3. Repeat Until Result : program repeatUntilLoop; var a: integer; begin a := 10; (* repeat until loop execution *) repeat writeln('value of a: ', a); a := a + 1 until a = 20; end. When the above code is compiled and executed, what is the result? And draw the flowchart! Flowchart : START a := 10 a := a + 1 a <20 ? Print Value of a : Yes No END Var a : int
  • 4. 4. NestedPrime Result : program nestedPrime; var i, j:integer; begin for i := 2 to 50 do begin for j := 2 to i do if (i mod j)=0 then break; {* if factor found, not prime *} if(j = i) then writeln(i , ' is prime' ); end; end. When the above code is compiled and executed, what is the result? And draw the flowchart!
  • 5. Flowchart : Var i, j : int START i := 2 i <= 50 ? j := 2 Yes j < i ? Yes i mod j = 0 ? Break; True j = i ? False Print i ’ is prime’; True No j = j + 1; i = i + 1; END False No
  • 6. 5. Break Result: program exBreak; var a: integer; begin a := 10; (* while loop execution *) while a < 20 do begin writeln('value of a: ', a); a:=a +1; if( a > 15) then (* terminate the loop using break statement *) break; end; end. When the above code is compiled and executed, what is the result? And draw the flowchart! Flowchart : START Var a : int a := 10 a < 20 ? Print Value of a : a := a + 1 a > 15 ? Yes Yes Break; No No END
  • 7. 6. Continue Result : program exContinue; var a: integer; begin a := 10; (* repeat until loop execution *) repeat if( a = 15) then begin (* skip the iteration *) a := a + 1; continue; end; writeln('value of a: ', a); a := a+1; until ( a = 20 ); end. When the above code is compiled and executed, what is the result? And draw the flowchart! Flowchart : Var a : int a := 10 START a = 20 ? a := a + 1 Continue; No Print Value of a : Yes a = 15 ? END Yes No
  • 8. 7. Goto Result: program exGoto; label 1; var a : integer; begin a := 10; (* repeat until loop execution *) 1: repeat if( a = 15) then begin (* skip the iteration *) a := a + 1; goto 1; end; writeln('value of a: ', a); a:= a +1; until a = 20; end. When the above code is compiled and executed, what is the result? And draw the flowchart! Flowchart : Var a : int a := 10 a = 20 ? a := a + 1 Goto 1; No Print Value of a : Yes a = 15 ? END Yes No START Label 1