Arrays Syntax: type variableName[size];

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick Strings #include using namespace std; int main () { string word; cout
Advertisements

1 CS 105 Lecture 11 Arrays Version of Wed, Apr 6, 2011, 6:20 pm.
True or false A variable of type char can hold the value 301. ( F )
C++ Data Type String A string is a sequence of characters enclosed in double quotes. Examples of strings: “Hello” “CIS 260” “Students” The empty string.
What Data Do We Have? Sections 2.2, 2.5 August 29, 2008.
Conditional Operator (?:) Conditional operator (?:) takes three arguments (ternary) Syntax for using the conditional operator:
1 CS 105 Lecture 8 Strings; Input Failure Mon, Mar 7, 2011, 3:39 pm.
Programming Switch command. COMP102 Prog. Fundamentals: Switch command / Slide 2 Multiple Selection: The switch Statement value1 action 1 value2 action.
Announcements Final Exam: Project Due on Wednesday at noon Central Time.
1 Pre-Exam Class CSIT121 Fall 2000 Exam-II (Final Examination) TUESDAY DECEMBER 19th 8:30AM.
What If? Write a program that prompts for the names and locations of 1000 employees. Store the information in the program for later use.
Chapter 8. 2 Objectives You should be able to describe: One-Dimensional Arrays Array Initialization Arrays as Arguments Two-Dimensional Arrays Common.
1 CS 105 Lecture 5 Logical Operators; Switch Statement Wed, Feb 16, 2011, 5:11 pm.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
More on Input Output Input Stream : A sequence of characters from an input device (like the keyboard) to the computer (the program running). Output Stream.
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
ITEC 320 C++ Examples.
Announcements Exam 1 Tuesday July minutes 10 % of Total Grade Covers Everything through Lecture 05. –Includes Quiz 1 Topics (terminology, variables,
CSC1201: Programming Language 2 Lecture 1 Level 2 Course Nouf Aljaffan (C) CSC 1201 Course at KSU1.
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: One-Dimensional Arrays Array Initialization Arrays.
Review for Final Exam. Contents 5 questions (20 points each) + 1 bonus question (20 points) – Basic concepts in Chapters 1-4 – Chapters 5-9 – Bonus: Chapter.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
Lecture 15: Course Review BJ Furman ME 30 16MAY2011.
LESSON 4 Decision Control Structure. Decision Control Structures 1. if statement 2. if-else statement 3. If-else-if statement 4. nested if statement 5.
Announcements Final Exam: TBD. Static Variables and Methods static means “in class” methods and variables static variable: one per class (not one per.
Exam 2 EXAM 2 Thursday!!! 25% of Final Grade Know: loops, switch/case Files Input failure (e.g. scan.hasNextInt())
C++ Programming: CS102 LOOP. Not everything that can be counted counts, and not every thing that counts can be counted. −Albert Einstein Who can control.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
A FIRST BOOK OF C++ CHAPTER 7 ARRAYS. OBJECTIVES In this chapter, you will learn about: One-Dimensional Arrays Array Initialization Arrays as Arguments.
Pointers What is the data type of pointer variables?
LESSON 06.
Test 2 Review Outline.
LESSON 4 Decision Control Structure
Command Line Arguments
Exam 3 Review.
Introduction to C++ October 2, 2017.
Programming Fundamentals
What If? Write a program that prompts for the names and locations of 1000 employees. Store the information in the program for later use.
Initializing Arrays char [] cArray3 = {'a', 'b', 'c'};
Variables with Memory Diagram
Peer Instruction 6 Java Arrays.
CS 1430: Programming in C++ Turn in your Quiz1-2 No time to cover HiC.
CS 2308 Exam I Review.
Data type List Definition:
Arrays November 8, 2017.
Review for Final Exam.
Counting Loops.
Arrays An array is a collection of variables that all have the same name and the same data type. Each member of the array is known as an element of the.
Know for Quiz Everything through Last Week and Lab 7
CS 1428 Final Exam Review.
Announcements Exam 1 Thursday 50 minutes 10 % of Total Grade
File Review Declare the File Stream Object Name
Announcements Exam 1 Thursday Everything through Lab 5 50 minutes
Arrays of Objects // The following does NOT create memory for
Summary Two basic concepts: variables and assignments Basic types:
CS 1428 Final Exam Review.
Announcements Final Exam: Project Due on Monday at noon Central Time.
Review for Final Exam.
Arrays of Two-Dimensions
Final Review Bina Ramamurthy 4/5/2019 BR.
Summary of what we learned yesterday
Fundamental Programming
CS150 Introduction to Computer Science 1
Peer Instruction 4 Control Loops.
CS149D Elements of Computer Science
Pointers and dynamic objects
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
What If? Write a program that prompts for the names and locations of 1000 employees. Store the information in the program for later use.
Announcements Exam 2 Lecture Grades Posted on blackboard
Presentation transcript:

Arrays Syntax: type variableName[size]; Memory Is Set Aside for size Items of type Each Variable Location in Array Is Accessed by Offsetting into the Array with an Integer Expression Legitimate Offsets Are 0 to size-1 Example: lastname[0] = ‘H’;

Array Example int values[15]; values[0] = 150; values[1] = 78; cout << values[0]; values[3] = values[0] + 6;

Initializing Arrays int main() { char cArray3[5] = {'a', 'b', 'c'}; int iArray[] = {1, 2, 3, 4}; int iArray2[10] = {10, 13, 15, 17}; double dArray[] = {3.4, 5.67e4}; double dArray1[5] = {6.7, 7.8, 9.5}; }

Initializing string Arrays #include <string> using namespace std; int main() { string sArray[] = {"one", "two", "three"}; cout << sArray[0]; }

Two Dimensional Arrays char cArray[10][20]; int iArray[100][50]; cArray[0][0] = ‘a’; cArray[0][1] = ‘b’; cArray[9][19] = ‘x’; iArray[0][0] = 99; iArray[1][5] = 135; iArray[99][49] = 0;

Final Exam 2 Hours 200 Points 35% of Grade Must Take to Pass Course

Need to Know for Final Everything Through Exam 2 Terminology Loops Switch/Case Files Functions Arrays

Final Exam 200 Points Total – 35% of Final Grade 60 points Matching or Short Answer or Multiple Choice (Terminology, Operators, C++ Basics) 30 Points Program Output 80 Points Programming (Full Programs) 30 Points Essay