Praktikum C Programming Perulangan / Loop. Bentuk Loop 1.Perintah for 2.Perintah while 3.Perintah do-while.

Slides:



Advertisements
Similar presentations
Java Control Statements
Advertisements

Chapter 11 Lists and iteration. This chapter discusses n Managing collections of objects. n The fundamental container object is called a list. n Fundamental.
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Introduction to Java 2 Programming Lecture 5 Array and Collections.
Repetition Statements Perform the same task repeatedly Allow the computer to do the tedious, boring things.
Dependency Test in Loops By Amala Gandhi. Data Dependence Three types of data dependence: 1. Flow (True) dependence : read-after-write int a, b, c; a.
Chapter 4 Ch 1 – Introduction to Computers and Java Flow of Control Loops 1.
For(int i = 1; i
Copyright 2008 by Pearson Education 1 Nested loops reading: 2.3 self-check: exercises: videos: Ch. 2 #4.
February 12, 2013 COMP Introduction to Programming For Statement and More Loops Haohan Li TR 11:00 – 12:15, SN 011 Spring 2013.
+ Pemrograman Javascript Teknik Informatika Universitas Bunda Mulia Jakarta Chandra Hermawan H., M.Kom., MM.
Selected Advanced Topics Chapter 7 and 8
Do-while Loops Programming. COMP102 Prog Fundamentals I: do-while Loops /Slide 2 The do-while Statement l Syntax do action while (condition) l How it.
Loops –Do while Do While Reading for this Lecture, L&L, 5.7.
Two-Dimensional Arrays Chapter What is a two-dimensional array? A two-dimensional array has “rows” and “columns,” and can be thought of as a series.
Counting Andreas Klappenecker. Counting k = 0; for(int i=1; i
OPTIMIZING C CODE FOR THE ARM PROCESSOR Optimizing code takes time and reduces source code readability Usually done for functions that are critical for.
§3 Dynamic Programming Use a table instead of recursion 1. Fibonacci Numbers: F(N) = F(N – 1) + F(N – 2) int Fib( int N ) { if ( N
Introduction to Assembly language
Case study 1: Calculate the approximation of Pi
Repeating Structures For Loops. Repeating Structures Tasks we need to complete are often very repetitive. Once a task has been mastered, repeating it.
Stored Procedure Arfansyah, M.Kom. Mengenal Stored Procedure Stored Procedure adalah kumpulan perintah SQL yang diberi nama dan disimpan di server Stored.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
A loop is a repetition control structure. it causes a single statement or block to be executed repeatedly What is a loop?
CS Data Structures Appendix 1 How to transfer a simple loop- expression to a recursive function (factorial calculation)
1 MATERI PENDUKUNG JUMP Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
S: Application of quicksort on an array of ints: partitioning.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Part 1 Conditionals and Loops.
Recursion Examples Fundamentals of CS Case 1: Code /* Recursion: Case 1 */ #include void count (int index); main () { count (0); getchar(); } void count.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Intro to Java Day 3 / Loops 1. DAY 3 Java Language Specifications Conditional Loops while do for References: JavaNotes7 pdf bookJavaNotes7 pdf book.
FOR LOOP WALK THROUGH public class NestedFor { public static void main(String [] args) { for (int i = 1; i
Repetition loops Is a condition true? START END OF LOOP EXIT.
CS 162 Intro to Programming II Insertion Sort 1. Assume the initial sequence a[0] a[1] … a[k] is already sorted k = 0 when the algorithm starts Insert.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
LOOPING IN C. What would be the output of the following program main( ) { int j ; while ( j
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Sorting Arrays ANSI-C. Selection Sort Assume want to sort a table of integers, of size length, in increasing order. Sketch of algorithm: –Find position.
C syntax (simplified) BNF. Program ::= [ ] Directives ::= [ ] ::= | |… ::=#include > ::=#define.
Kondisi dan Perulangan
Kondisi dan Perulangan
Oracle Developer/2000.
Chapter 9 Repetition.
Subroutine / Function Guna : Bentuk : FORTRAN
STRUKTUR KONTROL.
Greatest Common Divisor
Greatest Common Divisor
using System; namespace Demo01 { class Program
Two Dimensional Arrays
Control structures Chapter 3.
الحلقات التكرارية وجمل الدوران (loops)
Decision statements. - They can use logic to arrive at desired results
For Loops October 12, 2017.
Selection Sort Find the smallest value in the array. Put it in location zero. Find the second smallest value in the array and put it in location 1. Find.
Chapter 9 Control Structures.
Lecture 6 2d Arrays Richard Gesick.
LOOPS BY: LAUREN & ROMEO.
Announcements & review
class PrintOnetoTen { public static void main(String args[]) {
2D Arrays Just another data structure Typically use a nested loop
Print the following triangle, using nested loops
Sieve of Eratosthenes short demonstration
Main() { int fact; fact = Factorial(4); } main fact.
Learning Plan 5 Arrays.
Unit-2 Objects and Classes
int [] scores = new int [10];
Types of loops definite loop: A loop that executes a known number of times. Examples: Repeat these statements 10 times. Repeat these statements k times.
Common pattern/tool: Accumulator loops
break & continue Statements

Presentation transcript:

Praktikum C Programming Perulangan / Loop

Bentuk Loop 1.Perintah for 2.Perintah while 3.Perintah do-while

Perintah for #include main() { int i; for (i=0; i<5; i++) { printf(“%d“, i); } getch(); } for (inisialisasi, batas_akhir, counter) { statement; }

Perintah while #include main() { int i=0; while (i<5) { printf(“%d“, i); i++; } getch(); } inisialisasi; while (kondisi) { statement; counter; }

Perintah do-while #include main() { int i=0; do { printf(“%d“, i); i++; } while (i<5); getch(); } inisialisasi; do { statement; counter; } while (kondisi);

Nested Loop... 1 • Loop di dalam loop for (inisialisasi_1, batas_akhir_1, counter_1) { statement_loop1; for (inisialisasi_2, batas_akhir_2, counter_2) { statement_loop2; }

Nested Loop... 2 inisialisasi_1; while (kondisi_1) { statement_1; counter_1; inisialisasi_2; while (kondisi_2) { statement_2; counter_2; }

Nested Loop... 3 for (inisialisasi_1, batas_akhir_1, counter_1) { statement_loop1; inisialisasi_2; while (kondisi_2) { statement_2; counter_2; }

Bintang #include main() { int baris, kolom; for (baris=0; baris<5; baris++) { for (kolom=0; kolom<5; kolom++) { printf(“*”); } printf(“\n”); } getch(); }

Latihan