Overview. Arrays and their properties Creating arrays Accessing array elements Modifying array elements Loops and arrays. Initialization Searching
|
|
- Virgil Hutchinson
- 5 years ago
- Views:
Transcription
1 Arrays
2 Overview Arrays and their properties Creating arrays Accessing array elements Modifying array elements Loops and arrays Initialization Searching
3 Arrays and Their Properties Hold several values of the same type (homogeneous) Based on a slot number (the index number) Instant access Linear (one after the other) Static once their size is set, it s set
4 What arrays look like Things to notice myarray 5 6 There are 7 slots, with index numbers 0 6 The name of the array is myarray Easy to be off by one
5 Creating Arrays <data type>[] <name> = new <data type> [<size>]; new brings complex variables to life in C# Notice that we can create an array of any data type, just by changing the data type!
6 Examples An array of shorts: short[] somearray = new short[50]; An array of floats: float[] myarray = new float[25]; An array of booleans: bool[] list = new bool[65]; An array of chars: char[] characters = new char[255];
7 Initializing Arrays with Values <data type>[] <name> = new <data type> [<size>] {VALUES}; Or <data type>[] <name> = {VALUES};
8 Modifying an Array You must specify which slot you are putting information in Example: int[] myarray = new int[50]; myarray[3] = 12; 49 This won t work: int[] myarray = new int[50]; myarray = 12; Data type on the left of = is an array Data type on right of = is an int 12
9 Accessing Information Copying information out of a particular slot Example: int clientage; clientage = myarray[4]; This copies information from the fifth slot (slot four) into the variable clientage
10 Initializing Arrays (large arrays) For most arrays, you will use a loop to initialize Problem: create an array of 50 bytes and fill each slot with the number 42 Solution: byte[] mylist = new byte[50]; for (int =0; < 50; ++) { } mylist[] = 42;
11 Line by Line (a smaller example) byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
12 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
13 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
14 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
15 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
16 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
17 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
18 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
19 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
20 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
21 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
22 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
23 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
24 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
25 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
26 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
27 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
28 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
29 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
30 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
31 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
32 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
33 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; }
34 Line by Line byte[ ] mylist = new byte[5]; for (int = 0; < 5; ++) { mylist [] = 42; } false
35 Finding the Smallest Element If you were given an array of numbers, how would YOU do it? Computers can only compare two at a time Go through entire list Keep track of smallest so far Let s assume We have an array of 5 integers The array contains random unknown numbers The name of the array is called randomarray
36 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for smallestsofar
37 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for smallestsofar
38 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for smallestsofar
39 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { }//if }//for smallestsofar = randomarray[]; smallestsofar
40 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { }//if }//for smallestsofar = randomarray[]; smallestsofar
41 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for smallestsofar Is 42 > 17?
42 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for 1 smallestsofar
43 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for smallestsofar
44 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for 2 smallestsofar
45 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { }//if }//for smallestsofar = randomarray[]; smallestsofar
46 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { }//if }//for smallestsofar = randomarray[]; 2 Is 17 > 42? smallestsofar
47 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for smallestsofar
48 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for 3 smallestsofar
49 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { }//if }//for smallestsofar = randomarray[]; smallestsofar
50 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { }//if }//for smallestsofar = randomarray[]; smallestsofar Is 17 > -8?
51 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { }//if }//for smallestsofar = randomarray[]; smallestsofar
52 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for smallestsofar
53 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for 4 smallestsofar
54 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for 4 smallestsofar
55 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { }//if }//for smallestsofar = randomarray[]; smallestsofar Is -8 > 4?
56 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for smallestsofar
57 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { }//if }//for smallestsofar = randomarray[]; smallestsofar
58 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { }//if }//for smallestsofar = randomarray[]; smallestsofar
59 Another Trace int smallestsofar; smallestsofar = randomarray[0]; for (int = 1; < 5; ++) { if (smallestsofar > randomarray[]) { smallestsofar = randomarray[]; }//if }//for smallestsofar
60 Summary Arrays hold values that are all the same type Arrays are static in size Creating arrays always follows a format You can create an array of any type To initialize or search arrays, you ll almost always use a loop
1.3b Type Conversion
1.3b Type Conversion Type Conversion When we write expressions involved data that involves two different data types, such as multiplying an integer and floating point number, we need to perform a type
More informationExercise: Using Numbers
Exercise: Using Numbers Problem: You are a spy going into an evil party to find the super-secret code phrase (made up of letters and spaces), which you will immediately send via text message to your team
More informationUnderstand Computer Storage and Data Types
Understand Computer Storage and Data Types Lesson Overview Students will understand computer storage and data types. In this lesson, you will learn: How a computer stores programs and instructions in computer
More informationLooping and Counting. Lecture 3 Hartmut Kaiser hkaiser/fall_2012/csc1254.html
Looping and Counting Lecture 3 Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/ hkaiser/fall_2012/csc1254.html Abstract First we ll discuss types and type safety. Then we will modify the program
More informationLooping and Counting. Lecture 3. Hartmut Kaiser hkaiser/fall_2011/csc1254.html
Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/ hkaiser/fall_2011/csc1254.html 2 Abstract First we ll discuss types and type safety. Then we will modify the program we developed last time (Framing
More informationVariables and Functions. ROBOTC Software
Variables and Functions ROBOTC Software Variables A variable is a space in your robots memory where data can be stored, including whole numbers, decimal numbers, and words Variable names follow the same
More information1st and 3rd September 2015
1st and 3rd September 2015 Agenda for the week 1 2 3 Math functions and corresponding libraries The standard library has the abs(int) function besides that, the cmath library has the following inbuilt
More informationCS1150 Principles of Computer Science Arrays
CS1150 Principles of Computer Science Arrays Yanyan Zhuang Department of Computer Science http://www.cs.uccs.edu/~yzhuang CS1150 UC. Colorado Springs Opening Problem Read one hundred numbers, compute their
More informationCSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11
... 1/16 CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11 Alice E. Fischer February 3, 2016 ... 2/16 Outline Basic Types and Diagrams ... 3/16 Basic Types and Diagrams Types in C C has
More informationBasic data types. Building blocks of computation
Basic data types Building blocks of computation Goals By the end of this lesson you will be able to: Understand the commonly used basic data types of C++ including Characters Integers Floating-point values
More information14. Array Basics. Java. Summer 2008 Instructor: Dr. Masoud Yaghini
14. Array Basics Java Summer 2008 Instructor: Dr. Masoud Yaghini Outline Introduction Declaring an Array Creating Arrays Accessing an Array Simple Processing on Arrays Copying Arrays References Introduction
More informationCSC Java Programming, Fall Java Data Types and Control Constructs
CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference
More informationGeneral Syntax. Operators. Variables. Arithmetic. Comparison. Assignment. Boolean. Types. Syntax int i; float j = 1.35; int k = (int) j;
General Syntax Statements are the basic building block of any C program. They can assign a value to a variable, or make a comparison, or make a function call. They must be terminated by a semicolon. Every
More informationLab # 02. Basic Elements of C++ _ Part1
Lab # 02 Basic Elements of C++ _ Part1 Lab Objectives: After performing this lab, the students should be able to: Become familiar with the basic components of a C++ program, including functions, special
More informationOutline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types
Data Types Declarations and Initializations Larry Caretto Computer Science 16 Computing in Engineering and Science February 7, 25 Outline Review last week Meaning of data types Integer data types have
More informationMain Memory Organization
Main Memory Organization Bit Smallest piece of memory Stands for binary digit Has values 0 (off) or 1 (on) Byte Is 8 consecu>ve bits Word Usually 4 consecu>ve bytes Has an address 8 bits 0 1 1 0 0 1 1
More informationChapter 6 Single-dimensional Arrays
Chapter 6 Single-dimensional s 1. See the section "Declaring and Creating s." 2. You access an array using its index. 3. No memory is allocated when an array is declared. The memory is allocated when creating
More informationReview: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements
Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja
More information2. The object-oriented paradigm
2. The object-oriented paradigm Plan for this section: Look at things we have to be able to do with a programming language Look at Java and how it is done there Note: I will make a lot of use of the fact
More informationLecture 6 Sorting and Searching
Lecture 6 Sorting and Searching Sorting takes an unordered collection and makes it an ordered one. 1 2 3 4 5 6 77 42 35 12 101 5 1 2 3 4 5 6 5 12 35 42 77 101 There are many algorithms for sorting a list
More informationComputational Expression
Computational Expression Variables, Primitive Data Types, Expressions Janyl Jumadinova 28-30 January, 2019 Janyl Jumadinova Computational Expression 28-30 January, 2019 1 / 17 Variables Variable is a name
More informationPIC 20A Number, Autoboxing, and Unboxing
PIC 20A Number, Autoboxing, and Unboxing Ernest Ryu UCLA Mathematics Last edited: October 27, 2017 Illustrative example Consider the function that can take in any object. public static void printclassandobj
More informationThe type of all data used in a C (or C++) program must be specified
The type of all data used in a C (or C++) program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values
More informationCS2141 Software Development using C/C++ C++ Basics
CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short
More informationTopics: Material through example 19 (types, operators, expressions, functions, selection, loops, arrays)
CPSC 122 Study Guide: Examination 1 Topics: Material through example 19 (types, operators, expressions, functions, selection, loops, arrays) 1. What is the output? int x, y; x = y = 0; while(x < 5) y +=
More informationCreating a C++ Program
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer. 1 Creating a C++ Program created using an
More informationBasic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition
Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.
More informationArray. Lecture 12. Based on Slides of Dr. Norazah Yusof
Array Lecture 12 Based on Slides of Dr. Norazah Yusof 1 Introducing Arrays Array is a data structure that represents a collection of the same types of data. In Java, array is an object that can store a
More informationC++ Basics. Lecture 2 COP 3014 Spring January 8, 2018
C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing
More informationChapter 6 Arrays. Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved.
Chapter 6 Arrays 1 Opening Problem Read one hundred numbers, compute their average, and find out how many numbers are above the average. 2 Solution AnalyzeNumbers Run Run with prepared input 3 Objectives
More informationJava Identifiers, Data Types & Variables
Java Identifiers, Data Types & Variables 1. Java Identifiers: Identifiers are name given to a class, variable or a method. public class TestingShastra { //TestingShastra is an identifier for class char
More informationCISC-124. Casting. // this would fail because we can t assign a double value to an int // variable
CISC-124 20180122 Today we looked at casting, conditionals and loops. Casting Casting is a simple method for converting one type of number to another, when the original type cannot be simply assigned to
More informationType Conversion. and. Statements
and Statements Type conversion changing a value from one type to another Void Integral Floating Point Derived Boolean Character Integer Real Imaginary Complex no fractional part fractional part 2 tj Suppose
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationLecture 15. Arrays (and For Loops)
Lecture 15 Arrays (and For Loops) For Loops for (initiating statement; conditional statement; next statement) // usually incremental { body statement(s); The for statement provides a compact way to iterate
More informationESc101 : Fundamental of Computing
ESc101 : Fundamental of Computing I Semester 2008-09 Lecture 9+10 Types Range of numeric types and literals (constants) in JAVA Expressions with values of mixed types 1 I : Range of numeric types and literals
More informationboolean, char, class, const, double, else, final, float, for, if, import, int, long, new, public, return, static, throws, void, while
CSCI 150 Fall 2007 Java Syntax The following notes are meant to be a quick cheat sheet for Java. It is not meant to be a means on its own to learn Java or this course. For that you should look at your
More informationC# MOCK TEST C# MOCK TEST I
http://www.tutorialspoint.com C# MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to C#. You can download these sample mock tests at your local machine
More informationData Abstraction: Status of an Object
Data Abstraction: Status of an Object Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 10, 2009 H.-T. Lin (NTU CSIE) Data Abstraction: Status of an Object OOP(even) 03/10/2009 0 / 50 What We Should
More informationCSc Introduction to Computing
CSc 10200 Introduction to Computing Lecture 2 Edgardo Molina Fall 2011 - City College of New York Thursday, September 1, 2011 Introduction to C++ Modular program: A program consisting of interrelated segments
More informationint n = 10; int sum = 10; while (n > 1) { sum = sum + n; n--; } cout << "The sum of the integers 1 to 10 is " << sum << endl;
Debugging Some have said that any monkey can write a program the hard part is debugging it. While this is somewhat oversimplifying the difficult process of writing a program, it is sometimes more time
More informationPrimitive Types. Four integer types: Two floating-point types: One character type: One boolean type: byte short int (most common) long
Primitive Types Four integer types: byte short int (most common) long Two floating-point types: float double (most common) One character type: char One boolean type: boolean 1 2 Primitive Types, cont.
More informationExam 2. CSC 121 MW Class. Lecturer: Howard Rosenthal. April 26, 2017
Your Name: Exam 2. CSC 121 MW Class Lecturer: Howard Rosenthal April 26, 2017 The following questions (or parts of questions) in numbers 1-7 are all worth 3 points each. 1. Answer the following as true
More informationVARIABLES AND TYPES CITS1001
VARIABLES AND TYPES CITS1001 Scope of this lecture Types in Java the eight primitive types the unlimited number of object types Values and References The Golden Rule Primitive types Every piece of data
More informationData structures and libraries
Data structures and libraries Bjarki Ágúst Guðmundsson Tómas Ken Magnússon Árangursrík forritun og lausn verkefna School of Computer Science Reykjavík University Today we re going to cover Basic data types
More informationCHAPTER 7 ARRAYS: SETS OF SIMILAR DATA ITEMS
CHAPTER 7 ARRAYS: SETS OF SIMILAR DATA ITEMS Computers process information and usually they need to process masses of information. In previous chapters we have studied programs that contain a few variables
More informationCHAPTER 5 VARIABLES AND OTHER BASIC ELEMENTS IN JAVA PROGRAMS
These are sample pages from Kari Laitinen s book "A Natural Introduction to Computer Programming with Java". For more information, please visit http://www.naturalprogramming.com/javabook.html CHAPTER 5
More informationChapter 2: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that
More informationThe type of all data used in a C++ program must be specified
The type of all data used in a C++ program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values There are
More informationCS Programming I: Arrays
CS 200 - Programming I: Arrays Marc Renault Department of Computer Sciences University of Wisconsin Madison Fall 2017 TopHat Sec 3 (PM) Join Code: 719946 TopHat Sec 4 (AM) Join Code: 891624 Array Basics
More informationCOMP Primitive and Class Types. Yi Hong May 14, 2015
COMP 110-001 Primitive and Class Types Yi Hong May 14, 2015 Review What are the two major parts of an object? What is the relationship between class and object? Design a simple class for Student How to
More informationInteger Data Types. Data Type. Data Types. int, short int, long int
Data Types Variables are classified according to their data type. The data type determines the kind of information that may be stored in the variable. A data type is a set of values. Generally two main
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 2 : C# Language Basics Lecture Contents 2 The C# language First program Variables and constants Input/output Expressions and casting
More information5. What is a block statement? A block statement is a segment of code between {}.
COSC 117 Exam 1 Key Fall 2012 Part 1: Definitions & Short Answer (3 Points Each) 1. What does CPU stand for? Central Processing Unit 2. Explain the difference between high-level languages and machine language.
More informationPROGRAMMING FUNDAMENTALS
PROGRAMMING FUNDAMENTALS Q1. Name any two Object Oriented Programming languages? Q2. Why is java called a platform independent language? Q3. Elaborate the java Compilation process. Q4. Why do we write
More informationCS242 COMPUTER PROGRAMMING
CS242 COMPUTER PROGRAMMING I.Safa a Alawneh Variables Outline 2 Data Type C++ Built-in Data Types o o o o bool Data Type char Data Type int Data Type Floating-Point Data Types Variable Declaration Initializing
More informationIntroduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands
Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires
More informationAgenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures
The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF
More informationChapter 2: Using Data
Chapter 2: Using Data Declaring Variables Constant Cannot be changed after a program is compiled Variable A named location in computer memory that can hold different values at different points in time
More informationArrays and Lists CSC 121 Fall 2015 Howard Rosenthal
Arrays and Lists CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand what an array is Understand how to declare arrays Understand what reference variables are Understand how to pass arrays to methods
More informationTest 1. CSC 121 Lecture Lecturer: Howard Rosenthal. March 4, 2014
1 Test 1. CSC 121 Lecture 21199 Lecturer: Howard Rosenthal March 4, 2014 Your Name: KEY The following questions (or parts of questions) in numbers 1-16 are all worth 2 points each. 1. Fill in the following
More informationDAD Lab. 1 Introduc7on to C#
DAD 2017-18 Lab. 1 Introduc7on to C# Summary 1..NET Framework Architecture 2. C# Language Syntax C# vs. Java vs C++ 3. IDE: MS Visual Studio Tools Console and WinForm Applica7ons 1..NET Framework Introduc7on
More informationIntroduction to C Language
Introduction to C Language Instructor: Professor I. Charles Ume ME 6405 Introduction to Mechatronics Fall 2006 Instructor: Professor Charles Ume Introduction to C Language History of C Language In 1972,
More informationRelational Operators and if. Class 10
Relational Operators and if Class 10 Data Type a data type consists of two things: Data Type a data type consists of two things: a set of values Data Type a data type consists of two things: a set of values
More informationJava. Representing Data. Representing data. Primitive data types
Computer Science Representing Data Java 02/23/2010 CPSC 449 161 Unless otherwise noted, all artwork and illustrations by either Rob Kremer or Jörg Denzinger (course instructors) Representing data Manipulating
More informationGetting started with Java
Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving
More informationc) And last but not least, there are javadoc comments. See Weiss.
CSCI 151 Spring 2010 Java Bootcamp The following notes are meant to be a quick refresher on Java. It is not meant to be a means on its own to learn Java. For that you would need a lot more detail (for
More informationLab 3: Defining Data and Symbolic Constants
COE 205 Lab Manual Lab 3: Defining Data and Symbolic Constants - page 25 Lab 3: Defining Data and Symbolic Constants Contents 3.1. MASM Data Types 3.2. Defining Integer Data 3.3. Watching Variables using
More informationObject-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018
Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 1: Types and Control Flow http://courses.cs.cornell.edu/cs2110/2018su Lecture 1 Outline 2 Languages Overview Imperative
More informationArrays and Lists CSC 121 Fall 2016 Howard Rosenthal
Arrays and Lists CSC 121 Fall 2016 Howard Rosenthal Lesson Goals Understand what an array is Understand how to declare arrays Understand what reference variables are Understand how to pass arrays to methods
More informationGetting started with Java
Getting started with Java by Vlad Costel Ungureanu for Learn Stuff Programming Languages A programming language is a formal constructed language designed to communicate instructions to a machine, particularly
More informationData types Expressions Variables Assignment. COMP1400 Week 2
Data types Expressions Variables Assignment COMP1400 Week 2 Data types Data come in different types. The type of a piece of data describes: What the data means. What we can do with it. Primitive types
More informationExam 1. CSC 121 Spring Lecturer: Howard Rosenthal. March 1, 2017
Exam 1. CSC 121 Spring 2017 Lecturer: Howard Rosenthal March 1, 2017 Your Name: Key 1. Fill in the following table for the 8 primitive data types. Spell the types exactly correctly. (16 points total) Data
More informationTypes, Variables, and Constants
, Variables, and Constants What is a Type The space in which a value is defined Space All possible allowed values All defined operations Integer Space whole numbers +, -, x No divide 2 tj Why Types No
More informationArrays and Lists CSC 121 Fall 2014 Howard Rosenthal
Arrays and Lists CSC 121 Fall 2014 Howard Rosenthal Lesson Goals Understand what an array is Understand how to declare arrays Understand what reference variables are Understand how to pass arrays to methods
More informationUnits 0 to 4 Groovy: Introduction upto Arrays Revision Guide
Units 0 to 4 Groovy: Introduction upto Arrays Revision Guide Second Year Edition Name: Tutorial Group: Groovy can be obtained freely by going to http://groovy-lang.org/download Page 1 of 8 Variables Variables
More informationLecture 2 Tao Wang 1
Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors
More informationAPSC 160 Review. CPSC 259: Data Structures and Algorithms for Electrical Engineers. Hassan Khosravi Borrowing many questions from Ed Knorr
CPSC 259: Data Structures and Algorithms for Electrical Engineers APSC 160 Review Hassan Khosravi Borrowing many questions from Ed Knorr CPSC 259 Pointers Page 1 Learning Goal Briefly review some key programming
More informationJava Basic Datatypees
Basic Datatypees Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in the memory. Based on the data type of a variable,
More informationCIS 110: Introduction to Computer Programming
CIS 110: Introduction to Computer Programming Lecture 3 Express Yourself ( 2.1) 9/16/2011 CIS 110 (11fa) - University of Pennsylvania 1 Outline 1. Data representation and types 2. Expressions 9/16/2011
More informationREVIEW. The C++ Programming Language. CS 151 Review #2
REVIEW The C++ Programming Language Computer programming courses generally concentrate on program design that can be applied to any number of programming languages on the market. It is imperative, however,
More informationIssue with Implementing PrimeSieve() in Go
Slices 02-201 Issue with Implementing PrimeSieve() in Go func PrimeSieve(n int) [n+1]bool { var iscomposite [n+1]bool //ERROR! biggestprime := 2 for biggestprime < n for i:=2; i
More informationCAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE
CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE a) Mention any 4 characteristic of the object car. Ans name, colour, model number, engine state, power b) What
More informationData Structures and Algorithms. Chapter 1
Data Structures Dr Ahmed Rafat Abas Computer Science Dept, Faculty of Computer and Information, Zagazig University arabas@zu.edu.eg http://www.arsaliem.faculty.zu.edu.eg/ Data Structures and Algorithms
More informationControl Structures. A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping
Control Structures A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping Conditional Execution if is a reserved word The most basic syntax for
More informationProgramming Basics. Digital Urban Visualization. People as Flows. ia
Programming Basics Digital Urban Visualization. People as Flows. 28.09.2015 ia zuend@arch.ethz.ch treyer@arch.ethz.ch Programming? Programming is the interaction between the programmer and the computer.
More informationBTE2313. Chapter 2: Introduction to C++ Programming
For updated version, please click on http://ocw.ump.edu.my BTE2313 Chapter 2: Introduction to C++ Programming by Sulastri Abdul Manap Faculty of Engineering Technology sulastri@ump.edu.my Objectives In
More informationCSC 204 Lab 12: Intro to ArrayLists
CSC 204 Lab 12: Intro to ArrayLists Goals After doing this lab, you should be able to: declare and trace an ArrayLists work with ArrayLists of objects use the for statement to read in, process, and print
More informationCSSE 220 Day 8. Arrays, ArrayLists, Wrapper Classes, Auto-boxing, Enhanced for loop. Check out ArraysAndLists from SVN
CSSE 220 Day 8 Arrays, ArrayLists, Wrapper Classes, Auto-boxing, Enhanced for loop Check out ArraysAndLists from SVN Questions? Exam 1 is October 1, 7-9 PM! Over chapters 1-7 You'll have a chance to ask
More informationOWEN COMPUTER SCIENCE LESSONS L2RVW4 Pg 1. Lesson 2 Review #4. Matching. Match each description to the correct data type.
OWEN COMPUTER SCIENCE LESSONS 2014-2015 L2RVW4 Pg 1 Lesson 2 Review #4 Name Matching Match each description to the correct data type. a. int e. short b. float f. long c. double g. char d. byte 1. up to
More informationManage Resources. Dictionaries and Dictionary Attributes. System Defined Dictionaries and Dictionary Attributes
Dictionaries and Dictionary Attributes, page 1 RADIUS-Vendor Dictionaries, page 3 Dictionaries and Dictionary Attributes Dictionaries are domain-specific catalogs of attributes and allowed values that
More informationCrash Course in Java. Why Java? Java notes for C++ programmers. Network Programming in Java is very different than in C/C++
Crash Course in Java Netprog: Java Intro 1 Why Java? Network Programming in Java is very different than in C/C++ much more language support error handling no pointers! (garbage collection) Threads are
More informationMotivation was to facilitate development of systems software, especially OS development.
A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.
More informationMidterm Review Topics Java Basics and Structure Variables Branching Loops Methods Arrays. Midterm Review Kage Weiss Lab 001 TA, SPR 17
Midterm Review Topics Java Basics and Structure Variables Branching Loops Methods Arrays Midterm Review Kage Weiss Lab 001 TA, SPR 17 Java Basics and Structure Class{ class variables; methods{ method variables;
More informationDo not start the test until instructed to do so!
Fall 1999 Page 1 of 10 READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties. Failure to adhere to these directions will not constitute an excuse or defense. Print
More informationANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions
Birkbeck (University of London) Software and Programming 1 In-class Test 1.1 9 Feb 2017 Student Name Student Number Answer all questions 1. Consider the following sequence of Java statements: int m = 3;
More informationTutorial 11. Exercise 1: CSC111 Computer Programming I. A. Write a code snippet to define the following arrays:
College of Computer and Information Sciences CSC111 Computer Programming I Exercise 1: Tutorial 11 Arrays: A. Write a code snippet to define the following arrays: 1. An int array named nums of size 10.
More informationComputer Department. Question (1): State whether each of the following is true or false. Question (2): Select the correct answer from the following:
Computer Department Program: Computer Midterm Exam Date : 19/11/2016 Major: Information & communication technology 1 st Semester Time : 1 hr (10:00 11:00) Course: Introduction to Programming 2016/2017
More informationFull file at
Java Programming, Fifth Edition 2-1 Chapter 2 Using Data within a Program At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional
More informationOct. 3 fixup - Here are notes and codes in the proper order that they should be.
Oct. 3 fixup - Here are notes and codes in the proper order that they should be. The boolean Data Type The boolean data type allows you to create variables that may hold one of two possible values: true
More information