CISC181 Introduction to Computer Science Dr

Slides:



Advertisements
Similar presentations
Etter/Ingber Arrays and Matrices. Etter/Ingber One-Dimensional Arrays 4 An array is an indexed data structure 4 All variables stored in an array are of.
Advertisements

Chapter 9 Pointers and Dynamic Arrays. Overview 9.1 Pointers 9.2 Dynamic Arrays.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Introduction to Arrays.
Topic 9 – Introduction To Arrays. CISC105 – Topic 9 Introduction to Data Structures Thus far, we have seen “simple” data types. These refers to a single.
1 11/8/06CS150 Introduction to Computer Science 1 Arrays Chapter 8 page 477 November 13, 2006.
Slides prepared by Rose Williams, Binghamton University Chapter 6 Arrays.
Arrays. Objectives Learn about arrays Explore how to declare and manipulate data into arrays Learn about “array index out of bounds” Become familiar with.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 19 Clicker Questions November 3, 2009.
A First Book of ANSI C Fourth Edition
Array (continue).
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 7 Clicker Questions September 22, 2009.
CS 139-Programming Fundamentals Lecture 11B - Arrays Adapted from a presentation by Dr. Rahman Fall 2014.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter Array Basics.
1 2/2/05CS250 Introduction to Computer Science II Pointers.
1 CSC103: Introduction to Computer and Programming Lecture No 16.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 26 Clicker Questions December 3, 2009.
© Janice Regan, CMPT 128, January CMPT 128: Introduction to Computing Science for Engineering Students Introduction to Arrays.
SEQUENTIAL AND OBJECT ORIENTED PROGRAMMING Arrays.
Arrays. Example Write a program to keep track of all students’ scores on quiz 1. Need a list of everyone’s score Declare 14 double variables? What about.
Computer Programming Arrays 1. Question #1 2 Question Choose the correct answer..
Introduction to programming in java Lecture 21 Arrays – Part 1.
C++ for Engineers and Scientists Second Edition Chapter 12 Pointers.
Data Structures & Algorithms CHAPTER 2 Arrays Ms. Manal Al-Asmari.
C LANGUAGE UNIT 3. UNIT 3 Arrays Arrays – The concept of array – Defining arrays – Initializing arrays.
ARRAYS (Extra slides) Arrays are objects that help us organize large amounts of information.
Chapter 11 - JavaScript: Arrays
Sections 10.1 – 10.4 Introduction to Arrays
An Introduction to Programming with C++ Sixth Edition
Computer Programming BCT 1113
Arrays 2/4 By Pius Nyaanga.
Arrays Declarations CSCI N305
CISC181 Introduction to Computer Science Dr
New Structure Recall “average.cpp” program
C Passing arrays to a Function
CISC181 Introduction to Computer Science Dr
Chapter 6 - Arrays Outline 6.1 Introduction 6.2 Arrays
7 Arrays.
Lists in Python.
Chapter 9 - Arrays Outline 6.1 Introduction 6.2 Arrays
EKT150 : Computer Programming
Variables Numbers can be stored and retrieved while a program is running if they are given a home. The way that integers and decimal numbers are stored.
Lecture 18 Arrays and Pointer Arithmetic
CISC181 Introduction to Computer Science Dr
Lecture 12 Oct 16, 02.
Arrays .
Functions with arrays.
Chapter 7 The Java Array Object © Rick Mercer.
Topics discussed in this section:
CS150 Introduction to Computer Science 1
Chapter 9: Value-Returning Functions
CS150 Introduction to Computer Science 1
7 Arrays.
CS150 Introduction to Computer Science 1
To refer to an element, specify
Dr. Sampath Jayarathna Cal Poly Pomona
CS149D Elements of Computer Science
CS150 Introduction to Computer Science 1
Programming Logic and Design Fifth Edition, Comprehensive
C Programming Pointers
CS150 Introduction to Computer Science 1
CS150 Introduction to Computer Science 1
CS149D Elements of Computer Science
Lecture 14: Problems with Lots of Similar Data
C++ Array 1.
CISC181 Introduction to Computer Science Dr
Programming Fundamental
CSCE 206 Lab Structured Programming in C
Arrays Introduction to Arrays Reading for this Lecture:
Presentation transcript:

CISC181 Introduction to Computer Science Dr CISC181 Introduction to Computer Science Dr. McCoy Lecture 13 Clicker Questions October 13, 2009

Assuming that int a has a value of 3 and that integer array b has 7 elements, what is the correct way to assign the value of the sum of 3 and the third element, to the fifth element of the array? (a) b[ a + 1 ] = b[ a ] + 3; (b) b[ a + 1 ] = b[ a - 1 ] + 3; (c) b[ a ] + 1 = b[ a + 3]; (d) b[ a + 2 ] = b[ a ] + 3;

Which statement would be used to declare a 10 element integer array c Which statement would be used to declare a 10 element integer array c? (a) Array c = int[ 10 ]; (b) c = int[ 10 ]; (c) int Array c[ 10 ]; (d) int c[ 10 ];

Which of the following is not a correct way to initialize an array Which of the following is not a correct way to initialize an array? (a) int n[ 5 ] = { 0, 7, 0, 3, 8, 2 }; (b) int n[] = { 0, 7, 0, 3, 8, 2 }; (c) int n[ 5 ] = { 7 }; (d) int n[ 5 ] = { 9, 1, 9 }; ANS: (a)

Referencing elements outside the array bounds (a) can result in changes to the value of an unrelated variable (b) is impossible because C++ checks to make sure it does not happen (c) is a syntax error (d) enlarges the size of the array

Unless otherwise specified, entire arrays are passed __________ and individual array elements are passed __________. (a) call-by-value, call-by-reference (b) call-by-reference, call-by-value (c) call-by-value, call-by-value (d) call-by-reference, call-by-reference

Which of the following is false about a function being passed an array Which of the following is false about a function being passed an array? (a) it knows the size of the array it was passed (b) it is passed the address of the first element in the array (c) it is able to modify the values stored in the array (d) the array name is passed as an argument

A double subscripted array element declared as a[3][5]has how many elements? (a) 15 (b) 14 (c) 16 (d) 8

Given the following declaration, what is the value of b[ 1 ][ 0 ] Given the following declaration, what is the value of b[ 1 ][ 0 ]? int b[ 2 ][ 2 ] = { { 1 }, { 3 , 4 } }; (a) 0 (b) 1 (c) 3 (d) this is not a valid declaration

Which of the following does not initialize all of its elements to 0 Which of the following does not initialize all of its elements to 0? (a) int b[ 2 ][ 2 ]; b[ 0 ][ 0 ] = b[ 0 ][ 1 ] = b[ 1 ][ 0 ] = b[ 1 ][ 1 ] = 0; (b) int b[ 2 ][ 2 ] = { 0 }; (c) int b[ 2 ][ 2 ]; for ( int i = 0; i < 2; i++ ) for (int j = 0; j < 2; j++ ) b[ i ][ j ] = 0; (d) all of the above initialize all of their elements to 0.