Nested Loops. For i = 1 To 5 For j = 1 To 6 picOutput.Print "*"; Next j picOutput.Print Next i.

Slides:



Advertisements
Similar presentations
Selection Feature of C: Decision making statements: It allow us to take decisions as to which code is to be executed next. Since these statements control.
Advertisements

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.
Chapter 4 - Control Statements
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Control Structures Nested ifs, switch statements.
Example – calculating interest until the amount doubles using a for loop: will calculate up to 1000 years, if necessary if condition decides when to terminate.
Nested Loops. Problem Print The only printfs you can use are: –printf(“*”); –printf(“\n”); *****
MATLAB Loops and Branching.
Control Flow C and Data Structures Baojian Hua
Selection Statements choice of one among several blocks of code Java supports 3 kinds of selection statements: if statement – selects one block or leaves.
Types of LOOP Structures Do While ……. Loop Do Until …… Loop For …… Next loop.
CHAPTER 2 ANALYSIS OF ALGORITHMS Part 2. 2 Running time of Basic operations Basic operations do not depend on the size of input, their running time is.
Chapter 5 - Visual Basic Schneider1 Chapter 5 Decisions.
Chapter 6 - Visual Basic Schneider
Chapter 6 - Visual Basic Schneider1 Chapter 6 Repetition.
Programming with MATLAB. Relational Operators The arithmetic operators has precedence over relational operators.
1 Chapter 6 Repetition. 2 Outline & Objectives Loop Structure Loop Structure Elements of a Loop Structure Elements of a Loop Structure Processing Lists.
Week 7 - Programming II Today – more features: – Loop control – Extending if/else – Nesting of loops Debugging tools Textbook chapter 7, pages
HTML Elements. HTML documents are defined by HTML elements.
Do it now activity Correct the 8 syntax errors: Age = input(“How old are you?” If age = 10 Print(You are 10”) else: print(“You are not 10”)
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Control Structures, Operators, and Functions.
Presented by Lee Zenke 2015 Java Programming PT. 2.
Review for Exam 2 School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 10, Friday 3/21/2003) - IF Blocks - Do Loops - Select.
Chapter five selected exercises with solutions. Exercises 5.1.
Slide 1 PHP Operators and Control Structures ITWA 133.
Repetition Statements.  Often it is necessary to repeat statements many times  Java has two ways of doing this  while statements  for statements.
Review for Exam2 Key Ideas 1. Key Ideas: Boolean Operators (2 > 3) || (3 < 29.3) A.True B.False C.Impossible to determine (22 > 3) && (3 > 29.3) A.True.
Conditionals CS 103 February 16, Blast from the Past: C14 Dating Problem Statement: Calculate the age of a fossil from its C-14 radioactivity Problem.
PHP-language, conditional statements Teppo Räisänen Principal Lecturer Oulu University of Applied Sciences School of Business and Information Management.
Repetition Structures
CHAPTER 3 Decisions and Repetition. A few new constants Constants so far:  Strings  Numbers  integer  float Boolean constants: [On board]
Review for Final (Part 2) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 15, Friday 5/2/2003)
Chapter six exercises
Working with Loops, Conditional Statements, and Arrays.
Which student’s work is correct? Describe the error the other student made.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(7) JavaScript: Control Statements I.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
Control Flow Statements
CSI 3125, Preliminaries, page 1 Control Statements.
Two-Dimensional Arrays. Two-dimensional arrays variables store the contents of tables or matrices. Example: Dim arrTable(1 to 5, 1 to 5) As Integer first.
情報基礎 A Lecture 12 Takeshi Tokuyama Tohoku University Graduate School of Information Sciences System Information Sciences Design and Analysis of Information.
Select Case Blocks School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 8, Monday 3/03/2003)
Kondisi dan Perulangan
PHP-language, conditional statements
Kondisi dan Perulangan
IE 8580 Module 4: DIY Monte Carlo Simulation
ITEC 2600 Introduction to Analytical Programming
© 2016, Mike Murach & Associates, Inc.
Intro to Programming Week # 6 Repetition Structure Lecture # 10
Control Structures in VB
Control Structures: Part 1
تصمیم‌گیری و کنترل روند، استفاده از حلقه‌ها و دستورات شرطی در متلب
آشنايی با اصول و پايه های يک آزمايش
الكلية الجامعية للعلوم التطبيقية
More Nested Loops and Lab 5
Alice in Action with Java
EGR 141 Computer Problem Solving in Engineering and Computer Science
Chapter 5 - Visual Basic Schneider
Visual Basic – Decision Statements
Control Structures in VB
Chapter 5: Selection Statement
Program Flow.
Chapter 5 Decisions.
PROGRAM FLOWCHART Selection Statements.
Print the following triangle, using nested loops
Quiz – Lives of Stars.
Repetition (While Loop) LAB 9
Do it now activity Log onto the computer.
For...Next Statements.
Types of Errors And Error Analysis.
ME 123 Computer Applications I Lecture 11: More on For loop 3/27/03
Presentation transcript:

Nested Loops

For i = 1 To 5 For j = 1 To 6 picOutput.Print "*"; Next j picOutput.Print Next i

******

For i = 1 To 5 For j = 1 To 6 picOutput.Print "*" Next j picOutput.Print Next i

************************************************************

For i = 1 To 5 For j = 1 To 6 picOutput.Print "*"; Next j picOutput.Print; Next i

******************************

For i = 1 To 5 For j = 1 To 6 picOutput.Print tab(j);"*"; Next j picOutput.Print Next i

******

For i = 1 To 5 For j = 1 To 6 picOutput.Print tab(j);"*" Next j picOutput.Print Next i

*

For i = 1 To 5 For j = 1 To 6 picOutput.Print tab(2*j);“*”; Next j picOutput.Print Next i

* * * * * *

For i = 1 To 5 For j = 1 To 6 picOutput.Print tab(2*j);“*”; Next j picOutput.Print; Next i

* * * * * *

For i = 1 To 5 For j = 1 To 6 picOutput.Print tab(i);“*”; Next j picOutput.Print Next i

*

For i = 1 To 5 For j = 1 To 6 picOutput.Print tab(i*j);“*”; Next j picOutput.Print; Next i

******

For i = 1 To 5 For j = 1 To 6 If(i<j) Then picOutput.Print “*”; End If Next j picOutput.Print Next i

***** **** *** ** *

For i = 1 To 5 For j = 1 To 6 If(i<=j) Then picOutput.Print “*”; End If Next j picOutput.Print Next i

****** ***** **** *** **

For i = 1 To 5 For j = 1 To 6 If(i>=j) Then picOutput.Print “*”; End If Next j picOutput.Print; Next i

* ** *** **** *****

star = "*" For i = 1 To 5 picOutput.Print star star = star & "*" Next i

* ** *** **** *****

For i = 1 To 5 For j = 1 To 6 If(i=j) Then picOutput.Print “*”; Else picOutput.Print “#”; End If Next j picOutput.Print Next i

*##### #*#### ##*### ###*## ####*#

For i = 1 To 5 For j = 1 To 6 picOutput.Print "*"; Next j For k = 1 To 3 picOutput.Print "#"; Next k picOutput.Print Next i

******###

For i = 1 To 5 For j = 1 To 6 picOutput.Print "*"; For k = 1 To 3 picOutput.Print "#"; Next k Next j picOutput.Print Next i

*###*###*###*###*###*###

size=6 For i = 1 To size picOutput.Print "*"; Next i picOutput.Print For i = 1 To size - 2 picOutput.Print "*"; For j = 1 To size - 2 picOutput.Print " "; Next j picOutput.Print "*" Next i For i = 1 To size picOutput.Print "*"; Next i

****** * ******

Size = 6 For i = 1 To Size For j = 1 To Size If (i = 1 Or i = Size) Then picOutput.Print "*"; ElseIf (j > 1 And j < Size) Then picOutput.Print " "; Else picOutput.Print "*"; End If Next j picOutput.Print Next i

Syntax error For i = 1 To 5 For j = 1 To 6 picOutput.Print "*"; Next i picOutput.Print Next j

Correct!, but hard to read! For i = 1 To 5 For j = 1 To 6 picOutput.Print "*"; Next j picOutput.Print Next i