The University of Texas – Pan American

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Arrays.
CSCI 3328 Object Oriented Programming in C# Chapter 9: Classes and Objects: A Deeper Look 1 Xiang Lian The University of Texas – Pan American Edinburg,
1 Arrays  Arrays are objects that help us organize large amounts of information  Chapter 8 focuses on: array declaration and use passing arrays and array.
 2006 Pearson Education, Inc. All rights reserved Arrays.
C++ for Engineers and Scientists Third Edition
Chapter 8 Arrays and Strings
CSCI/CMPE 4341 Topic: Programming in Python Chapter 3: Control Structures (Part 1) – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
1 CSCE 1030 Computer Science 1 Arrays Chapter 7 in Small Java.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 6: Lists, Tuples, and Dictionaries – Exercises Xiang Lian The University of Texas – Pan American Edinburg,
 Pearson Education, Inc. All rights reserved Arrays.
03/16/ What is an Array?... An array is an object that stores list of items. Each slot of an array holds an individual element. Characteristics.
Chapter 7: Arrays. In this chapter, you will learn about: One-dimensional arrays Array initialization Declaring and processing two-dimensional arrays.
 2006 Pearson Education, Inc. All rights reserved Arrays.
CHAPTER 07 Arrays and Vectors (part I). OBJECTIVES 2 In this part you will learn:  To use the array data structure to represent a set of related data.
Chapter 8 Arrays and Strings
Arrays Chapter 7. 2 "All students to receive arrays!" reports Dr. Austin. Declaring arrays scores : Inspecting.
EGR 2261 Unit 8 One-dimensional Arrays  Read Malik, pages in Chapter 8.  Homework #8 and Lab #8 due next week.  Quiz next week.
 Pearson Education, Inc. All rights reserved Arrays.
 Pearson Education, Inc. All rights reserved Arrays.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
C++ for Engineers and Scientists Second Edition Chapter 11 Arrays.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.
1 Arrays and Vectors Chapter 7 Arrays and Vectors Chapter 7.
CSCI 3328 Object Oriented Programming in C# Chapter 7: Arrays 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
Arrays Chapter 7. 2 Declaring and Creating Arrays Recall that an array is a collection of elements all of the _____________ Array objects in Java must.
Arrays Chapter 7. MIS Object Oriented Systems Arrays UTD, SOM 2 Objectives Nature and purpose of an array Using arrays in Java programs Methods.
Arrays Declaring arrays Passing arrays to functions Searching arrays with linear search Sorting arrays with insertion sort Multidimensional arrays Programming.
SEQUENTIAL AND OBJECT ORIENTED PROGRAMMING Arrays.
CSCI 3328 Object Oriented Programming in C# Chapter 6: Methods – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.
 2005 Pearson Education, Inc. All rights reserved Arrays.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 7: Introduction to Object- Oriented Programming in Python – Exercises Xiang Lian The University of.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 5: Functions – Exercises Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
Arrays Chapter 7.
Chapter 6: Using Arrays.
Computer Programming BCT 1113
CSCI 3328 Object Oriented Programming in C# Review: Final Exam
The University of Texas – Pan American
Advanced Programming Chapter 8: Arrays
Java How to Program, Late Objects Version, 10/e
CSCI 3328 Object Oriented Programming in C# Chapter 7: Arrays
The University of Texas Rio Grande Valley
The University of Texas – Pan American
7 Arrays.
The University of Texas – Pan American
CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections
The University of Texas – Pan American
The University of Texas – Pan American
The University of Texas Rio Grande Valley
CSCI 3328 Object Oriented Programming in C# Review: Exam II
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II – Exercises UTPA – Fall 2012 This set of slides is revised from.
The University of Texas – Pan American
CSCI 3328 Object Oriented Programming in C# Chapter 3: Introduction to Classes and Objects – Exercises UTPA – Fall 2012 This set of slides is revised.
CSCI 6307 Foundation of Systems – Exercise (1)
CSCI 3328 Object Oriented Programming in C# Review: Exam II
CSCI 3328 Object Oriented Programming in C# Review: Final Exam
The University of Texas – Pan American
CS2011 Introduction to Programming I Arrays (I)
MSIS 655 Advanced Business Applications Programming
CSCI 3328 Object Oriented Programming in C# Chapter 7: Arrays
Arrays Chapter 7.
CSCI 3328 Object Oriented Programming in C# Review: Final Exam
7 Arrays.
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections – Exercises UTPA – Fall 2012 This set of slides is revised from lecture.
CSCI 3328 Object Oriented Programming in C# Review: Exam II
CSCI 6307 Foundation of Systems – Exercise (5)
CSCI 3328 Object Oriented Programming in C# Chapter 7: Arrays – Exercises UTPA – Fall 2012 This set of slides is revised from lecture slides of Prof.
Presentation transcript:

The University of Texas – Pan American CSCI 3328 Object Oriented Programming in C# Chapter 7: Arrays – Exercises Xiang Lian The University of Texas – Pan American Edinburg, TX 78539 lianx@utpa.edu This set of slides is revised from lecture slides of Prof. John Abraham. -- Xiang Lian

Objectives In this chapter, you will do some exercises about: 1-dimenionsal or multidimensional arrays Data manipulations in arrays

Multiple Choices Lists and tables of values with the same data type can be stored in _____. A. variables B. arrays C. indexes D. keywords The _________ statement allows you to iterate through the elements in an array without using a counter. A. for B. each C. for each D. foreach The number that refers to a particular array element is called the element's _______. A. number B. data type C. index D. class An array that uses two indices is referred to as a(n) _____ array. A. 1-dimensional B. 2-dimensional C. matrix D. list Which of the following statements is true to iterate all elements in the array? A. for (int i = 0; i < array.Length; i++) B. for (int i = 1; i < array.Length; i++) C. for (int i = 1; i <= array.Length; i++) D. for (int i = 0; i <= array.Length; i++)

Multiple Choices (cont'd) Use the foreach header _____ to iterate through double array numbers. A. for each (double d=1; d<numbers.Length; d++) B. foreach (double d = 1 in numbers) C. foreach (double d in numbers) D. for each (double d = numbers[]) Command-line arguments are stored in _____. A. string [] args B. string args C. char args D. char [] args Use the expression _____ to receive the total number of arguments in a command line. A. args.length B. args.Length() C. args.GetLength() D. args.Length The indexed array name of one-dimensional array units's element 2 is _______. A. units{1} B. units(2) C. units[0, 2] D. units [1]

Multiple Choices (cont'd) Which of the following sorts array averageRainfall? A. Array(averageRainfall).Sort() B. Sort.Array(averageRainfall) C. Sort(averageRainfall) D. Array.Sort(averageRainfall)

True/False Statements A single array can store values of different types. An array index should normally be of type float. An individual array element that is passed to a method and modified in that method will contain the modified value when the called method completes execution. Command-line arguments are separated by commas.

True/False Statements (cont'd) The declaration of an array of size 11 is as follows: int arr = new int [10]; The modification of an array element is as follows: 10 = arr[0]; The declaration of a 2-dimensional array is as follows: int [ ] arr = new int [20][10]; The declaration of a 10*10 array is as follows: int [,] arr = new int [11, 11]; The linear search in arrays requires elements in a sorted order. The binary search works well for unsorted arrays

Debugging Errors const int array_size = 5; array_size = 10; int [] b = new int [5]; For (int i =0; i<=b.Length; i++) b[i]=1; int [] a = {1, 2, , 4, 5}; b=a; int [,] c={{1,2}, {3, 4}}; c[1][1] = 5;

Debugging Errors (cont'd) int [, ] array = new int [3, 3]; for (int i = 0; i<=3; i++) for (int j=0; j<=3; j++) array [i, j] = i+j;

Write a Program Write a complete program to generate random number between 1 and 99, and output the resulting number to a resultTextBox.

Write a Program (cont'd) Declare an array, numArray, to hold 100 integer numbers Assign random numbers within [1, 100] into this array Sort this array Check whether a number 50 exists in this array using the linear search and foreach statement Output the multiplication of all even integers in this array; if no even numbers exist, then output 1