Lecture 3 : January 2001 Dr. Andrew Paul Myers

Slides:



Advertisements
Similar presentations
Chapter 9 – One-Dimensional Numeric Arrays. Array u Data structure u Grouping of like-type data u Indicated with brackets containing positive integer.
Advertisements

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.
Introduction to arrays
An Array A sequence of elements of a particular type Each element in the array has an index which gives its position in the sequence An array is declared.
Chapter 8 Introduction to Arrays Part II Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul.
COMP102 – Programming Fundamentals I LA2B (Mon 5-7pm) LA2E (Fri 3-5pm) LA2F (Fri 5-7pm) TA: Jackie Lo.
Chapter 7 Introduction to Arrays Part I Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul.
Loops – While, Do, For Repetition Statements Introduction to Arrays
13 April, 2000 CS1001 Lecture 17 One-Dimensional Arrays Using 1-D arrays in Project.
Lecture 1 : January 2001 Dr. Andrew Paul Myers
Structured Data Types. Date Types We have seen various data types –Integer, Real, Character, Logical All these types define data values of different kinds.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
Arrays in C++ Numeric Character. Structured Data Type A structured data type is a type that stores a collection of individual components with one variable.
COMP102 Lab 081 COMP 102 Programming Fundamentals I Presented by : Timture Choi.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 8 Arrays.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
CPS120: Introduction to Computer Science Lecture 15A Structures.
Lecture III Start programming in Fortran Yi Lin Jan 11, 2007.
A (VERY) SHORT INTRODUCTION TO MATLAB J.A. MARR George Mason University School of Physics, Astronomy and Computational Sciences.
Introduction to Computer Sciences References: [1] Fortran 95/2003 for Scientists and Engineers (3e) by Stephen J. Chapman. [2] Using Fortran 90 by Chester.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
1 CSC103: Introduction to Computer and Programming Lecture No 17.
Arrays. C++ Style Data Structures: Arrays(1) An ordered set (sequence) with a fixed number of elements, all of the same type, where the basic operation.
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Fundamentals of Programming Most.
CSC Programming for Science Lecture 5: Actual Programming.
Data Types Chapter 6: Data Types Lectures # 11. Topics Introduction Primitive Data Types Character String Types Array Types Associative Arrays Record.
Unit 2 Technology Systems
Sections 10.1 – 10.4 Introduction to Arrays
Algorithm & Flowchart.
Chapter 6: Using Arrays.
CSC 201 Computer Programming- FORTRAN
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Pointers, Enum, and Structures
Chapter 6: Data Types Lectures # 10.
Welcome to Computer Science Jeopardy
Today’s Material Arrays Definition Declaration Initialization
September 8th.
Programming For Nuclear Engineers Lecture 6 Arrays
Complex data types Complex data types: a data type made of a complex of smaller pieces. Pascal has four very commonly used complex data types: strings,
Programming Languages and Paradigms
Lecture-5 Arrays.
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Programming Paradigms
2. Understanding VB Variables
Prepared By: G.UshaRani B.Pranalini A.S.Lalitha
C-Programming, continued
Computational Methods of Scientific Programming
Arrays, For loop While loop Do while loop
Pointers and Arrays S.Bhuvaneshwari Assistant Professor/CSE
Visual Basic .NET BASICS
Visual Basic 6 Programming.
CSCI 3327 Visual Basic Chapter 7: Arrays
Java - Data Types, Variables, and Arrays
Visual Basic 6 Programming.
EKT150 : Computer Programming
More On Enumeration Types
Arrays under SystemVerilog
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
Arrays under SystemVerilog
Lecture 4 : January 2001 Dr. Andrew Paul Myers
CISC181 Introduction to Computer Science Dr
Arrays ICS2O.
INC 161 , CPE 100 Computer Programming
Arrays in Java.
C Programming Pointers
Beginning C Lecture 5 Lecturer: Dr. Zhao Qinpei
And now for something completely different . . .
Programming Languages and Paradigms
C++ Array 1.
Arrays Introduction to Arrays Reading for this Lecture:
Presentation transcript:

Lecture 3 : January 2001 Dr. Andrew Paul Myers FORTRAN 77 Programming. Lecture 3 : January 2001 Dr. Andrew Paul Myers 24/02/2019

Array Variables. An array is a simple structure, capable of storing many variables of the same type in a single data structure. Declare arrays with other variables. Arrays can be of any data type. Declaration : REAL array(100) INTEGER loop(20),data(500) CHARACTER names(10)*20 24/02/2019

More on Arrays. Each array member is addressable by an array subscript. e.g for REAL x(10), subscripts range from 1 to 10. i.e. array(1), … array(10) The subscript may be a constant, variable or expression : array(1)=SIN(x) array(loop)=4.0*array(loop-1) 24/02/2019

And There’s More… Consider : REAL array(10) As mentioned before, array subscripts range from 1 to 10. We can over ride this default: REAL array(-10:10) INTEGER data(0:200) 24/02/2019

Still more… Arrays can be multi-dimensional REAL array(5,2) i.e. array(1,1), array(1,2), array(2,1)… Taking things to an extreme!!! REAL array(5,0:12,20,-10:100) 24/02/2019

Iterations. Loops allow blocks of command to be repeated. Simplest is the DO loop. DO <index> = <start>,<stop> [,<step>] <statement(s)> END DO 24/02/2019

Example DO Loop. INTEGER loop REAL array(100) DO loop=1,100,1 array(loop)=0.0 END DO 24/02/2019

DO WHILE Loop. Another type of loop : DO WHILE <condition> <statement(s)> END DO Not in all versions of FORTRAN 77. 24/02/2019

Example. INTEGER test test=15 DO WHILE ( test .GT. 12 ) test=test-1 END DO Useful for repeating a program? 24/02/2019

The Horrible Past… DO loop with numeric label. DO 1000 loop=0,10,2 <statement(s)> 1000 CONTINUE Implied DO loop! READ*,(value(loop),loop=1,10,1) 24/02/2019

The DATA statement. Another method of assigning values to variables and arrays. REAL a,b,c INTEGER d(5),lots(100) CHARACTER single(5)*1 DATA a /1.5/ DATA b,c /2.5,5.6/ DATA d /1,2,3,4,5/ DATA lots /100*0.0/ DATA single /5*’Y’/ 24/02/2019

Advanced Data Types. Structures. Not in all versions of F77. Structures can hold many variables of different types. Structures are declared with all other variables at the beginning of a program. With structures you can build powerful, custom data types. 24/02/2019

Declaring A Structure. STRUCTURE / book_type / CHARACTER title*80 CHARACTER author*40 INTEGER stock_level REAL price END STRUCTURE 24/02/2019

The Next Step… Now we must declare a record of the type defined in the structure. RECORD / book_type / science RECORD / book_type / rubbish(10) 24/02/2019

Value Assignments. Each part of the record is identified thus : science.title = ‘2001’ science.author = ‘A.C.Clarke’ science.stock = 25 science.price = 9.99 24/02/2019

For the More Brave… Remember? RECORD / book_type / rubbish(10) DO loop=1,10 READ’(A80)’,rubbish.title(loop) READ*,rubbish.price(loop) END DO 24/02/2019