While, do while, break, continue Dr. Anto Satriyo Nugroho, M.Eng Web: Mata Kuliah: Dasar.

Slides:



Advertisements
Similar presentations
Java Control Statements
Advertisements

Soal-3 Susun program untuk menginput tiga (3) buah bilangan bulat (misal A, B dan C dimana ABCA), kemudian mencetak ketiga nilai tersebut urut dari.
Program Looping EE2372 Software Design I Dr. Gerardo Rosiles.
For(int i = 1; i
BNF <digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
Control Flow Statements: Repetition/Looping
Pemrograman Dasar Control Flow Statements: Decision Making or Selection PTIIK - UB 1.
+ Pemrograman Javascript Teknik Informatika Universitas Bunda Mulia Jakarta Chandra Hermawan H., M.Kom., MM.
Programming In C++ Spring Semester 2013 Lecture 3 Programming In C++, Lecture 3 By Umer Rana.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 10P. 1Winter Quarter Repetition Structures.
CS 101 Introductory Programming - Lecture 7: Loops In C & Good Coding Practices Presenter: Ankur Chattopadhyay.
DS:Lab-1 Prepared by: Shipra Shukla Assistant Professor Kaziranga University.
Programming In C++ Spring Semester 2013 Lecture 4 Programming In C++, Lecture 3 By Umer Rana.
void count_down (int count) { for(i=count; i>1; i--) printf(" %d\t", count); } printf("A%d\n", count); if(count>1) count_down(count-1); printf("B%d\n",
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
Sort the given string, without using string handling functions.
Case study 1: Calculate the approximation of Pi
1 Conditional Statement. 2 Conditional Statements Allow different sets of instructions to be executed depending on truth or falsity of a logical condition.
Understanding the Idealized Intended Curriculum and the Realized Enacted Curriculum Dr. Heather Driscoll.
By Senem Kumova Metin 1 POINTERS + ARRAYS + STRINGS REVIEW.
COMP1180 Review Date: 4 March, 2009 Time: 10:30am - 12:20pm Venue: –CS students -- FSC801C and FSC801D –IS and other students -- OEE1017 Remarks: – 1)
CS Data Structures Appendix 1 How to transfer a simple loop- expression to a recursive function (factorial calculation)
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 8P. 1Winter Quarter Control Statements Lecture.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
1. a) What is Program design? Describe the program development cycle? b) What is Flow Chart? Explain the different symbols available in Flowchart? 2.
Lecture-2 Operators and Conditionals. Variables(again???) Type: Representation of “bits” in memory Variables: Name for a memory object. Starts with letters,
Real World Applications: Generating Prime Numbers  Problem Write a program that prints all positive prime integers less than or equal to n. A positive.
Simple Control Structures IF, IF-ELSE statements in C.
The switch Statement.  Occasionally, an algorithm will contain a series of decisions in which a variable or expression is tested separately for each.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
CSCI 171 Presentation 3. Operators Instructs C to perform some operation Assignment = Mathematical Relational Logical.
Repetition Repetition allows you to repeat an operation or a series of operations many times. This is called looping and is one of the basic structured.
LOOPING IN C. What would be the output of the following program main( ) { int j ; while ( j
CS 161 Introduction to Programming and Problem Solving Chapter 17 Nested Loops Herbert G. Mayer, PSU Status 9/8/2014 Initial content copied verbatim from.
Department of Electronic & Electrical Engineering Lecture 3 IO reading and writing variables scanf printf format strings "%d %c %f" Expressions operators.
CS113 Introduction to C Instructor: Ioannis A. Vetsikas Lecture 2 : August 28 webpage:
1 CSC103: Introduction to Computer and Programming Lecture No 9.
管 理 心 理 学管 理 心 理 学 主讲教师 张国民. 个人简介 张国民, 山西闻喜人, 先 后毕业于山西农 业大学、首都师 范大学、中国人 民大学,获农学 和法学第二学士 学位、法学硕士 学位。 现为全国大学心理学专业委员会 委员 山西省伦理学会 常务理事 山西农业大学学报(社科版) 编委 山西农业大学硕士研究生导师.
Week-11 (Lecture-1) Introduction to HTML programming: A web based markup language for web. Ex.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 10P. 1Winter Quarter Repetition Structures Lecture 10.
Decision making If.. else statement.
Pemrograman WEB I Pertemuan 4.
STRUKTUR KONTROL.
ECE Application Programming
ECE Application Programming
Pemrograman Database Delphi & MySQL
Dasar-Dasar Pemrograman
Struktur Control : Decision
Get Help-Gmail help number
Flow of Control.
Flow of Control.
More C expressions ANSI-C.
Pemrograman WEB I Pertemuan 5.
Flow of Control.
Decision making If statement.
CSC215 Homework Homework 02 Due date: Sep 30, 2016.
Distributed Production
Relational, Logical, and Equality Operators
EECE.2160 ECE Application Programming
ECE 103 Engineering Programming Chapter 19 Nested Loops
EECE.2160 ECE Application Programming
Character Arrays char string1[] = “first”;
Unit 4. Day 6..
EECE.2160 ECE Application Programming
Iteration Statement for
開始我的第一封伊妹兒 課程名稱:開始我的第一封伊妹兒 上課對象:國中一年級 上課地點:一人一機電腦教室 上課時數:一堂課(50mins)
Range check 範圍檢查: int age; int score; int month; 1-12
Pemrograman Bilangan Bulat (Integer Programming) Sebuah program linear dengan persyaratan tambahan bahwa semua variabelnya merupakan bilangan bulat Algoritma.
Presentation transcript:

while, do while, break, continue Dr. Anto Satriyo Nugroho, M.Eng Web: Mata Kuliah: Dasar Pemrograman

Instruksi while Cara penulisan while (expression)statement; Contoh: #include main() { int no; printf(“tuliskan sebarang bilangan bulat positif: “); scanf(“%d”, &no); while( no >= 0) { printf(“%d “,no); no--; } printf(“\n”); } expr Ya Tidak statement

Instruksi do while Cara penulisan do statement while (expression); expr Ya Tidak statement

Break & Continue Continue #include main() { int i; for(i=0;i<10;i++) { if(i==5) continue; printf(“%d\n”,i); } Hasil:

Break & Continue Break #include main() { int i; for(i=0;i<10;i++) { if(i==5) break; printf(“%d\n”,i); } Hasil:

Contoh Pemakaian Soal: Buatlah program untuk mencari semua bilangan prima di bawah 1000 Jawab #include { int i,no; for(no=2;no<1000;no++) { for(i=2;i<no;i++) if (no%i == 0) break; if(no==i) printf(“%d\n”,no); }