Chapter seven review Monther Aldwairi. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For.

Slides:



Advertisements
Similar presentations
Chapter 9 – One-Dimensional Numeric Arrays. Array u Data structure u Grouping of like-type data u Indicated with brackets containing positive integer.
Advertisements

Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
VB PROJECT “PROJECT SAMPLES”. For Next Loops Design a VB program that displays in a picture box the first N multiples of an input integer Input 3 exam.
Selection and Insertion Sort Mrs. C. Furman October 1, 2008.
Match-and-Stop Search Will find FIRST match Use Boolean variable to denote whether a match has been found or not Found initially False If a match is found,
Chapter 7 - Visual Basic Schneider1 Chapter 7 Arrays.
Arrays-Part 1. Objectives Declare and initialize a one-dimensional array Store data in a one-dimensional array Display the contents of a one-dimensional.
Introduction to Arrays Chapter 7 Why use arrays? To store & represent lists of homogeneous values To simplify program code To eliminate the need to reread.
11-1 Chapter 11 2D Arrays Asserting Java Rick Mercer.
Introduction to Computing Dr. Nadeem A Khan. Lecture 24.
©2004 Brooks/Cole Chapter 8 Arrays. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Sometimes we have lists of data values that all need to be.
Chapter 8 - Visual Basic Schneider1 Chapter 8 Sequential Files.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 11P. 1Winter Quarter Arrays Lecture 11.
Chapter 7 - Visual Basic Schneider1 Chapter 7 Arrays.
Introduction to Computing Dr. Nadeem A Khan. Lecture 28.
Multiple-Subscripted Array
Two-Dimensional Arrays School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 11, Friday 4/04/2003)
Chapter seven review. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For.
Chapter 6 - Visual Basic Schneider1 Chapter 6 Repetition.
Chapter 41 Sub Procedures, Part II (Continue). Chapter 42 Local Variable A variable declared inside a Sub procedure with a Dim statement Space reserved.
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will Learn about arrays One-dimensional arrays Two-dimensional arrays Learn about searching.
C++ for Engineers and Scientists Third Edition
Chapter 6 - Visual Basic Schneider
Chapter 6 - Visual Basic Schneider1 Chapter 6 Repetition.
Chapter 7 - Visual Basic Schneider1 Chapter 7 Arrays.
Searching and Sorting Arrays
Arrays. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For i = 1 To 4 Input.
Chapter 7 - Visual Basic Schneider
Arrays. What is an Array? Similar to a Matrix. Collection of data that needs similar processing. Example: Transpose of a matrix.
1 Chapter 6 Repetition. 2 Outline & Objectives Loop Structure Loop Structure Elements of a Loop Structure Elements of a Loop Structure Processing Lists.
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will –Learn about arrays One-dimensional arrays Two-dimensional arrays –Learn about searching.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic concepts and uses of arrays ❏ To be able to define C.
Advance Data Structure 1 College Of Mathematic & Computer Sciences 1 Computer Sciences Department م. م علي عبد الكريم حبيب.
Chapter 7: Arrays. In this chapter, you will learn about: One-dimensional arrays Array initialization Declaring and processing two-dimensional arrays.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Array Processing: Exercises School of Business Eastern Illinois University © Abdou Illia, Spring 2002 (Week 10, Friday 3/28/2003)
Chapter 8 Arrays and Strings
ARRAYS 1.Basic Ideas 2.The Array Type 3.Processing Arrays 4.Parallel Arrays 5.Two-dimensional Array 6.Arrays as Parameters.
Examples using Arrays. Summing Squares Problem: To compute the sum of the squares of N numbers N is given N values are also given These should be read.
Arrays and 2D Arrays.  A Variable Array stores a set of variables that each have the same name and are all of the same type.  Member/Element – variable.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Programming Test #1 Solutions. Multiple Choice 1. B) the grammar of the coding language 2. C) String 3. A) Single 4. C) 2Burgers4Me 5. B) Design Time.
Chapter 6: Arrays: Lists and Tables
C++ for Engineers and Scientists Second Edition Chapter 11 Arrays.
CHAPTER 7 arrays I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
Introduction to C++ Programming Language Assistant Professor Jeon, Seokhee Assistant Professor Department of Computer Engineering, Kyung Hee University,
Lecture -3 on Data structures Array. Prepared by, Jesmin Akhter, Lecturer, IIT, JU Array Data structures are classified as either linear or nonlinear.
Chapter 8 - Visual Basic Schneider
Count and add list of numbers From user input and from file.
1 Topic: Array Topic: Array. 2 Arrays Arrays In this chapter, we will : Learn about arrays Learn about arrays Explore how to declare and manipulate data.
Week # 2: Arrays.  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently  Types of data.
Computer Programming TCP1224 Chapter 11 Arrays. Objectives Using Arrays Declare and initialize a one-dimensional array Manipulate a one-dimensional array.
Repetition Chapter 6 - Visual Basic Schneider 1  Loop Structure  Elements of a Loop Structure  Processing Lists of Data with Do Loops Chapter 6 -
Searching & Sorting Programming 2. Searching Searching is the process of determining if a target item is present in a list of items, and locating it A.
ALGORITHMS.
CSIT 208, Section Instructor: P eter C hen Introduction to Programming with QBasic to Visual Basic Lecture 8.
Bubble Sort Notes David Beard CIS220. Bubble Sort for Strings Double pass algorithm to sort a single dimensional array. Inner loop “bubbles” largest element.
CHAPTER EIGHT ARRAYS © Prepared By: Razif Razali1.
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will Learn about arrays One-dimensional arrays Two-dimensional arrays Learn about searching.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 11P. 1Winter Quarter Arrays Lecture 11.
An Object-Oriented Approach to Programming Logic and Design Chapter 8 Advanced Array Concepts.
Sorting & Searching Geletaw S (MSC, MCITP). Objectives At the end of this session the students should be able to: – Design and implement the following.
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.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 7A Arrays (Concepts)
 2003 Prentice Hall, Inc. All rights reserved. 1 Arrays Outline 1 Introduction 2 Arrays 3Declaring Arrays 4Processing Array Contents 5 Multiple-Subscripted.
Chapter 9: Sorting and Searching Arrays
Chapter 7 Arrays.
ㅎㅎ Fourth step for Learning C++ Programming Two functions
For...Next Statements.
Presentation transcript:

Chapter seven review Monther Aldwairi

What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For i = 1 To 4 Input #1, a(i) Next i For i = 4 To 1 Step -2 picBox.Print a(i); Next i End Sub Contents of DATA.TXT: 1,3,5,7

Output: 7 3

What is the output of: Dim a(2 To 9) As Integer, i As Integer, _ k As Integer, sum As Integer For i = 2 To 9 a(i) = i Next i sum = 0 For k = 4 To 6 sum = sum + 10 ^ a(k-2) Next k picBox.Print sum

Output: 11100

What is the output of: Dim a(-1 to 5) As Single, x As Single Open "DATA.TXT" For Input As #1 Do While Not EOF(1) Input #1, x a(x) = a(x) + 3 Loop Close #1 picBox.Cls picBox.Print a(0); a(2) Contents of DATA.TXT: 0, 1, 5, 2, 0

Output: 6 3

Dim a(-2 To 5), b As Integer Dim i As Integer, j As Integer Open "DATA.TXT" For Input As #1 num = 0 For i = 3 To 5 Input #1, a(i) Next i For j = -1 To 1 Input #1, k b = b + a(k) Next j picBox.Print b Contents of DATA.TXT: 2, 1, 0, -1, 3, 3

Output: 4

How many comparisons will be made in the first pass of a bubble sort of n items? Answer: n-1 How many comparisons will be made in the second pass of a bubble sort of n items? Answer: n-2 How many comparisons will be made in all the passes of a bubble sort of n items? Answer: (n-1)+(n-2)+(n-3) + … +2+1 = n(n-1)/2

Given the following array items: 3, 1, 8, 9, 2, 10 a) What is the contents of the array after the first pass of using bubble sort? b) What is the contents of the array after the first comparison in the second pass? c) How many comparisons will be made to find 2 using sequential search on the original array? d) How many comparisons will be made to find 2 using sequential search if the array was sorted?

How many elements are in the array declared by Dim myArray(1 To 5, 1 To 5) As Single How many elements are in the array declared by Dim myArray(0 To 3, 1 To 3) As Single

7.1

3. Stuhldreher Crowley

4. 11

13. river(1) river(2) river(3) river(4) river(5) Thames Ohio Amazon Volga Nile river(1) river(2) river(3) river(4) river(5) Ohio Amazon Volga Nile Thames

14. cat(1) cat(2) cat(3) cat(4) Felix Garfield Morris Socks

7.2

3. Michigan

4. The sum of the first 4 elements is 30

6. South Pacific

7. The total rainfall for the first quarter is 10

12.hue will be unknown in the Sub procedure. Also, in the Print statement in the Sub procedure, tone needs a subscript.

7.3

2. Oliver Stan

Numbers interchanged.

comparisons 11.(n - 1) + (n - 2) A shorter version of this formula is n*(n- 1)/2

7.5

Bogart

13. Private Sub Exchange(a() As Single) Dim col As Integer, temp As Single 'Interchange values of 2nd and 3rd row For col = 1 To 10 temp = a(2, col) a(2, col) = a(3, col) a(3, col) = temp Next col End Sub

14. Private Sub FindGreatestValue(a() As Single) Dim row As Integer, col As Integer Dim greatest As Single 'Find greatest value in array and the locations where it occurs greatest = a(1, 1) For row = 1 To 3 For col = 1 To 45 If a(row, col) > greatest Then greatest = a(row, col) End If Next col Next row picOutput.Print "The greatest value is"; greatest picOutput.Print "It occurs at (row, col): " For row = 1 To 3 For col = 1 To 45 If a(row, col) = greatest Then picOutput.Print row, col End If Next col Next row End Sub