Lab 4: C Array Review: Array Lab assignments.

Slides:



Advertisements
Similar presentations
2000 Prentice Hall, Inc. All rights reserved. 1 Capitolo 4 - Arrays Outline 4.1Introduction 4.2Arrays 4.3Declaring Arrays 4.4Examples Using Arrays 4.5Passing.
Advertisements

One Dimensional Arrays
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
Chapter 9: Searching, Sorting, and Algorithm Analysis
Chapter 11 Sorting and Searching. Topics Searching –Linear –Binary Sorting –Selection Sort –Bubble Sort.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 6 - Arrays Outline 6.1Introduction 6.2Arrays.
 2003 Prentice Hall, Inc. All rights reserved. 1 Sorting Arrays Sorting data –Important computing application –Virtually every organization must sort.
Chapter 6 C Arrays Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc. Arrays are data structures.
 2007 Pearson Education, Inc. All rights reserved. 1 C Arrays.
 2007 Pearson Education, Inc. All rights reserved C Arrays.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 9 Searching.
Programming Languages -1 (Introduction to C) arrays Instructor: M.Fatih AMASYALI
 2007 Pearson Education, Inc. All rights reserved C Arrays.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 6 - Arrays Outline 6.1Introduction 6.2Arrays.
 2003 Prentice Hall, Inc. All rights reserved. 1 Arrays Outline Examples Using Arrays Passing arrays to functions Class GradeBook: store student grades.
Algorithm and Programming Array Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 15 March 2009.
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.
 2007 Pearson Education, Inc. All rights reserved C Arrays.
3.6 Solving Systems Using Matrices You can use a matrix to represent and solve a system of equations without writing the variables. A matrix is a rectangular.
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
 2003 Prentice Hall, Inc. All rights reserved. Outline 1 fig04_03.cpp (1 of 2) 1 // Fig. 4.3: fig04_03.cpp 2 // Initializing an array. 3 #include 4 5.
Course Code #IDCGRF001-A 5.1: Searching and sorting concepts Programming Techniques.
MULTI-DIMENSIONAL ARRAYS 1. Multi-dimensional Arrays The types of arrays discussed so far are all linear arrays. That is, they all dealt with a single.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Arrays + Functions Outline 6.5Passing Arrays to Functions.
4.1Introduction Arrays –Structures of related data items –Static entity (same size throughout program) A few types –Pointer-based arrays (C-like) –Arrays.
7.1 Introduction Arrays Arrays are data structures consisting of data items of the same type “Static” entities They remain the same size once they are.
Chapter 11 - JavaScript: Arrays
Chapter 6: Using Arrays.
Chapter 4 - Arrays Outline 4.1 Introduction 4.2 Arrays
Microsoft Visual Basic 2005: Reloaded Second Edition
Chapter 7: Array.
Chapter 5: Arrays: Lists and Tables
C Arrays.
Java How to Program, Late Objects Version, 10/e
7.3 Matrices.
Chapter 6 - Arrays Outline 6.1 Introduction 6.2 Arrays
C Arrays.
7 Arrays.
7 Arrays.
Chapter 9 - Arrays Outline 6.1 Introduction 6.2 Arrays
Arrays Kingdom of Saudi Arabia
Arrays as Lists with examples.
Arrays Outline Introduction Arrays Declaring Arrays
CISC181 Introduction to Computer Science Dr
C++ Programming Lecture 16 Arrays – Part III
Chapter 6 - Arrays Outline 6.1 Introduction 6.2 Arrays
Searching and Sorting Arrays
Standard Version of Starting Out with C++, 4th Edition
25 Searching and Sorting Many slides modified by Prof. L. Lilien (even many without an explicit message indicating an update). Slides added or modified.
24 Searching and Sorting.
Data Structures (CS212D) Week # 2: Arrays.
4.1 Introduction Arrays A few types Structures of related data items
6 C Arrays.
Arrays Kingdom of Saudi Arabia
Given value and sorted array, find index.
Chapter 4 - Arrays Outline 4.1 Introduction 4.2 Arrays
Multidimensional array
Arrays Week 2.
Searching and Sorting Arrays
Chapter 4 - Arrays Outline 4.1 Introduction 4.2 Arrays
Capitolo 4 - Arrays Outline 4.1 Introduction 4.2 Arrays
Arrays Arrays A few types Structures of related data items
1-6 Midterm Review.
Multi-Dimensional Arrays
Arrays.
Presented By: Mahmoud Rafeek Alfarra
ICS103: Programming in C Searching, Sorting, 2D Arrays
4.1 Introduction Arrays A few types Structures of related data items
Chapter 6 - Arrays Outline Multiple-Subscripted Arrays.
Presentation transcript:

Lab 4: C Array Review: Array Lab assignments

Review - Array Array rules Array methods Multi-dimensions arrays Defining, initializing an array Passing arrays to functions - Passing by reference - Passing by value Array methods Sorting arrays: ascending, descending, bubble … Searching arrays: linear, binary … Multi-dimensions arrays

Static & automatic local array (fig 6.11) fig06_11.c (1 of 4 )

Outline static array is created only once, when staticArrayInit is first called fig06_11.c (2 of 4 )

Outline automatic array is recreated every time automaticArrayInit is called fig06_11.c (3 of 4 )

Outline fig06_11.c (4 of 4 )

Passing arrays to functions (fig 6.13) fig06_13.c (1 of 3 ) Function prototype indicates function will take an array Array a is passed to modifyArray by passing only its name

Outline fig06_13.c (2 of 3 ) Array element is passed to modifyElement by passing a[ 3 ]

fig06_13.c (3 of 3 )

Sorting , linear search and binary search of a array (fig 6.19) fig06_19.c (1 of 6 )

Outline fig06_19.c (2 of 6 )

Outline If value is found, return its index (3 of 6 ) fig06_19.c (3 of 6 ) If value is too high, search the left half of array If value is too low, search the right half of array

Outline fig06_19.c (4 of 6 )

Outline fig06_19.c (5 of 6 )

Outline fig06_19.c (6 of 6 )

Multiple subscripts arrays (fig 6.21) fig06_21.c (1 of 2 ) array1 is initialized with both rows full array2 and array3 are initialized only partially

fig06_21.c (2 of 2 )

Lab Assignments #1 Write a program that does the followings Define 2 constants N and M (N = 3 and M=3) Declare and initialize 2 matrices of integers (2-dimensional arrays of integers) Print out matrices a and b in a readable format. Calculate and print out matrix c[M][M] = a[M][N]+b[N][M] d[M][M] = a[M][N]-b[N][M] e[M][M] = a[M][N]*b[N][M]

Lab Assignments #2 Problem 6.12 in the text book Use a single-subscripted array to solve the following problem: Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, “display” (print) it only if it is not a duplicate of a number already read. Provide for the “worst case” in which all 20 numbers are different. Use the smallest possible array to solve this problem

See Course Website at 12pm for Homework 4 GOOD LUCK