ITEC 320 Lecture 3 In-class coding / Arrays. Arrays Review Strings –Advantages / Disadvantages Input –What two methods are used? Conditionals Looping.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 3 More Syntax; Working with Objects.
Advertisements

Introduction to Java 2 Programming Lecture 5 Array and Collections.
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
Modules Program is built out of components. Each component defines a set of logically related entities (strong internal coupling) A component has a public.
1 Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 13.
ITEC 320 Lecture 12 Records. Intro to records Review Look_ahead(char,EOL); –What is this? –What does it allow us to do?
ITEC 320 Lecture 11 Pointers(1). Pointers Review Packages –Generic –Child Homework 3 is posted.
ITEC 320 Lecture 4 Sub-Types Functions. Functions / Procedures Review Types Homework Questions?
COEN Expressions and Assignment
Nov 10, Fall 2006IAT 8001 Debugging. Nov 10, Fall 2006IAT 8002 How do I know my program is broken?  Compiler Errors –easy to fix!  Runtime Exceptions.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 5 Types Types are the leaven of computer programming;
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
Lecture 27 Exam outline Boxing of primitive types in Java 1.5 Generic types in Java 1.5.
1) Pointers 2) Type declarations 3) Access/reference values 4) Type renaming/aliasing 5) Subtypes 6) Macro substitution COMP205 IMPERATIVE LANGUAGES 4.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
 2003 Prentice Hall, Inc. All rights reserved. 1 Arrays –Structures of related data items –Static entity (same size throughout program) A few types –Pointer-based.
JAVA 1.5 New Features Dr V. The syntax of the enhanced for loop (for each) for (type variableName : arrayName) { statements } arrayName could be any.
Guide To UNIX Using Linux Third Edition
1 Agenda Variables (Review) Example Input / Output Arithmetic Operations Casting Char as a Number (if time allow)
‘C’ LANGUAGE PRESENTATION.  C language was introduced by Dennis Ritchie..  It is a programming language, which can make a interaction between user and.
Agenda Review User input Scanner Strong type checking Other flow-control structures switch break & continue Strings Arrays 2.
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
ITEC 320 Procedural Programming Dr. Ray Lecture 1.
March 12, ICE 1341 – Programming Languages (Lecture #6) In-Young Ko Programming Languages (ICE 1341) Lecture #6 Programming Languages (ICE 1341)
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
ITEC 320 Lecture 5 Scope Exceptions. Scope / Exceptions Review Functions Procedures.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
ITEC 320 Lecture 10 Packages (2). Review Packages –What parts do they have? –Syntax?
Chapter 2: Java Fundamentals
CSE 425: Data Types I Data and Data Types Data may be more abstract than their representation –E.g., integer (unbounded) vs. 64-bit int (bounded) A language.
CHAPTER 7 arrays I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
Arithmetic Expressions
ITEC 320 Lecture 10 Examples. Review Strings –What types are there? –What are the differences? –What should you use where? Homework –Hardest part –Easiest.
ISBN Chapter 6 Data Types Introduction Primitive Data Types User-Defined Ordinal Types.
ITEC 320 Lecture 11 Application Part Deux Look Ahead.
Chapter 3 w Variables, constants, and calculations DIM statements - declaration temporary memory locations identifier, data type, scope data types - values.
COMP Primitive and Class Types Yi Hong May 14, 2015.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Concepts of programming languages Chapter 5 Names, Bindings, and Scopes Lec. 12 Lecturer: Dr. Emad Nabil 1-1.
1 CSC103: Introduction to Computer and Programming Lecture No 24.
ITEC 320 Lecture 9 Nested records / Packages. Review Project ?’s Records Exam 1 next Friday.
CMPSC 121- Spring 2015 Lecture 6 January 23, 2015.
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
Programming Fundamentals. Today’s Lecture Array Fundamentals Arrays as Class Member Data Arrays of Objects C-Strings The Standard C++ string Class.
C is a high level language (HLL)
1 Lecture 4: Part1 Arrays Introduction Arrays  Structures of related data items  Static entity (same size throughout program)
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
 2005 Pearson Education, Inc. All rights reserved Arrays.
1 A more complex example Write a program that sums a sequence of integers and displays the result. Assume that the first integer read specifies the number.
ITEC 320 Lecture 6 More on arrays / Strings. Arrays Review Scope Exceptions Arrays –Dynamic arrays How? Typed and anonymous.
Basic Data Types & Memory & Representation. Basic data types Primitive data types are similar to JAVA: char int short long float double Unlike in JAVA,
Introduction to programming in java Lecture 21 Arrays – Part 1.
Arrays An array is a sequence of objects all of which have the same type. The objects are called the elements of the array and are numbered consecutively.
Egyptian Language School Computer Department
Test 2 Review Outline.
Chapter 2 Variables.
Introduction to programming in java
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
Type Checking, and Scopes
Lecture Note Set 1 Thursday 12-May-05
Arithmetic Expressions
C Preprocessor(CPP).
Chapter 2 Variables.
Chapter 2: Java Fundamentals
Unit 6 - Variables - Fundamental Data Types
Lecture 14: Problems with Lots of Similar Data
Type Conversion It is a procedure of converting one data type values into another data type In C programming language we are having two types of type conversion.
Chapter 2 Variables.
COMPUTING.
Presentation transcript:

ITEC 320 Lecture 3 In-class coding / Arrays

Arrays Review Strings –Advantages / Disadvantages Input –What two methods are used? Conditionals Looping

Arrays Outline Exercise Arrays

In-class coding 3 characters then a number Output first, X number of middle, and the last. If last character is U make uppercase Format –First NumMiddle Middle Last

Arrays First –Determine how big your array will be Second –Create a specific type for your array Third –Declare the array Size: constant Natural :=10; type Int_Array is array (1.. Size) of Integer; numbers: Int_Array;

Arrays Basic ideas arrayName(position) := value; Looping –for i in arrayName'range loop

Arrays Program Array usage

Arrays Types What makes up a type?

Arrays Types Possible set of values Operations on those values Integers –Numbers in a particular range (based on memory) –Operations (+,-,*,/,mod,rem, :=…)

Arrays Java How do types work in java? What compilation errors happen? What happens at run-time when things go wrong?

Arrays Sub-types What do you think of when you hear the word subtype? What are some ADA subtypes that we have seen before? What do you think happens when the rules of a subtype are broken? –Constraint Error

Arrays Definition Subset of the values of a type with the same operations (usually) Natural –Ignores everything < 0 in the Integer type Syntax What would you do to create the subtype NaturallyTenOrLess? subtype Natural is Integer range 1.. Integer’last

Arrays Example with ada.integer_text_io; use ada.integer_text_io; procedure foo is i: Integer; n1, n2: Natural begin get(i); n1 := i; -- fails if... get(n2); -- fails if... n1 := n1 - n2; -- fails if... i := n2; -- fails if... end foo;

Arrays Conversio n with ada.integer_text_io; use ada.integer_text_io; procedure foo is i: Integer; n1: Natural; p1: Positive; begin get(p1); -- fails if... n1 := p1; -- fails if... get(n1); -- fails if... p1 := n1; -- fails if... i := p1; n1 := i; end foo;

Arrays Java byte, short, int, long What are their relationships? Widening, is it implicit? Narrowing, is it implicit?

Arrays Review In-class coding Arrays Types