ARRAYS COMPUTER PROGRAMMING. By Zerihun Alemayehu
|
|
- Arline Terry
- 6 years ago
- Views:
Transcription
1 ARRAYS COMPUTER PROGRAMMING By Zerihun Alemayehu AAiT.CED Rm. E119B
2 BASIC RULES AND NOTATION An array is a group of variables or constants, all of the same type, that are referred to by a single name. Array elements are indexed or subscripted, just like x 1, x 2,..., x n in mathematics. Array Elements Array subscript
3 BASIC RULES AND NOTATION Array Declaration REAL, DlMENSION (10):: X Declares X to be an array (or list) with 10 real elements, denoted by X(1), X(2),...,X(10). The number of elements in an array is called its size (10 in this case). Each element of an array is a scalar (singlevalued).
4 BASIC RULES AND NOTATION REAL, DIMENSION (0:100): : A declares A to have 101 elements, from A(0) to A(100). The upper bound must be specified; if the lower bound is missing it defaults to 1. REAL, DIMENSION (2, 3) : : A A is a two-dimensional array. The number of elements along a dimension is called the extent in that dimension. A has an extent of 2 in the first dimension, and an extent of 3 in the second dimension(and a size of 6).
5 ONE AND TWO DIMENSIONAL ARRAY Array1 (row) Array2 (row, col)
6 BASIC RULES AND NOTATION Fortran allows up to seven dimensions The number of dimensions of an array is its rank, and the sequence of extents is its shape. The shape of A is (2, 3), or (2 x 3) in matrix notation. A scalar is regarded as having a rank of zero. An array with a rank of one is called a vector An array with a rank of 2 or greater is called a matrix
7 BASIC RULES AND NOTATION REAL, DIMENSION (5): : A, B(2,3), C(10)! Only A is (1:5) INTEGER :: I (10), K (4, 4), L (5)! All different DIMNESION key word can be omitted Array constants (/ 1, 2, 5, 6, 9 /)! In FORTRAN 95 [ 1, 2, 5, 6, 9 ]! In FORTRAN 2003
8 BASIC RULES AND NOTATION An array subscript can be used as the control variable in a DO loop to generate array elements. DO I = 1, 5 X(I) = 2 * I END DO Integer, dimension(5), parameter:: i=6! Assigns a constant value of 6 to all the five elements of i READ*, X! An entire array may be read X = 1! An entire array assigned a scalar value
9 BASIC RULES AND NOTATION a = i = 100 y i i= 1 This expression represents the sum of all the elements stored in the subscripted variable y and the statement stores the result in a. REAL,DIMENSION(100):: Y READ*, Y A=0.0 DO I = 1,100 A = A + Y(I) END DO
10 ARRAY STORAGE The array element ordering: conceptualise a linear sequence of the array elements with the first index changing first. REAL, DIMENSION(3, 5) :: a
11 ARRAY ASSIGNMENT Whole array assignment REAL, DIMENSION(100) :: a, b, c REAL :: d(10,10) = 0.0 b = 2*a+4 a = c = b*a c = d! Illegal, the two arrays are not conformable
12 ARRAY ASSIGNMENT Array section assignment alpha beta alpha REAL, DIMENSION(10) :: alpha, beta alpha = beta = alpha + alpha(1:10:2) = beta(1:5) *
13 INITIALIZING ARRAY Constructors array = (/ list /) INTEGER :: a(6)=(/ 1, 2, 3, 6, 7, 8 /) variable expression(s) REAL :: b(2)=(/ SIN(x), COS(x) /) array expression(s) INTEGER :: c(5)=(/ 0, a(1:3), 4 /)
14 INITIALIZING ARRAY Implied DO loops (value list, variable = start, end [, step]) REAL :: d(100)=(/ REAL(i), i=1,100 /)!1 up to 100 INTEGER :: A (6) = (/ (I, I = 1, 2), J = 1, 3) /) the same as (/ 1, 2, 1, 2, 1, 2 /)
15 INITIALIZING ARRAY RESHAPE used for the initialization or assignment of multidimensional arrays RESHAPE (list, shape [,PAD] [,ORDER]) INTEGER, DIMENSION(2,3) :: a a=reshape((/i,i=0,5/),(/3,2/)) RESHAPE (SOURCE = (/1, 2, 3, 4, 5, 6/), SHAPE = (/2, 3/)) forms the (2 x 3) matrix
16 INITIALIZING ARRAY DATA statement DATA variable / list /... INTEGER :: a(4), b(2,2), c(3,3) DATA a/4,3,2,1/ DATA a/4*0/ DATA b(1,:)/0,0/ DATA b(2,:)/1,1/ DATA ((C(I,J), J= 1, 3), I=1, 3) /3*0, 3*1, 3*2/
17 WHERE STATEMENT used when the value of an element depends on the outcome of some condition. The WHERE statement allows a single array assignment only if a logical condition is true. WHERE (condition) statement INTEGER :: a(2,3,4) WHERE(a< 0) a=0 WHERE(a*3>10) a=999
18 WHERE STATEMENT The WHERE construct allows array assignment(s) only if a logical condition is true, and alternative array assignement(s) if false. WHERE (condition) block1 [ELSEWHERE block2] ENDWHERE INTEGER :: b(8,8) READ*, b WHERE (b<=0) b=0 ELSEWHERE b=1/b ENDWHERE
19 WHERE EXAMPLE Write a WHERE statement which replicates every nonzero element of an array beta by its reciprocal and every zero element by 1. INTEGER :: beta(8,8) READ*, b WHERE (beta == 0) beta=1 ELSEWHERE beta=1/beta ENDWHERE
20 ARRAYS: EXPERIMENTAL WORK Write a program that calculates dot product of two vectors a and b which is defined by. z = a b i = = = i Give values of a and b at the beginning of the program. And the result onto screen. 3 1 a i b i
21 ARRAYS: EXPERIMENTAL WORK Real, Dimension (3) :: a,b Real:: z=0.0 Read*, a Read*, b Do I =1,3 z=z+a(i)*(b(i) End do Print*, The dot product =, z
22 ALLOCATABLE (DYNAMIC) ARRAYS REAL, DIMENSION(:), ALLOCATABLE: : X Although its rank is specified, it has no size until it appears in an ALLOCATE statement, such as: ALLOCATE(X (N)) DEALLOCATE(X)!freeing up the memory used.
23 ARRAY EXAMPLE Write a program which first reads the number of people sitting an exam. It should then read their marks (or scores) in to an array and print the highest and lowest marks, followed by the average mark for the class.
24 SOLUTION Declare a dynamic array Read the no. of students, n Allocate the size of the array n Read all the marks Use do loop to find the max and min Calculate the sum Calculate the average Print the result
25 SOLUTION REAL, DIMENSION (:) :: mark INTEGER :: n PRINT*, Give me the no. of students READ*, n ALLOCATE (mark (n)) PRINT*, Give me the marks READ*, mark max_grade = MAXVAL (mark) min_grade = MINVAL (mark) avg = SUM(mark)/n DEALLOCATE (mark) PRINT *, Maximum =, max, Minimum =, min, average=, avg
Goals for This Lecture:
Goals for This Lecture: Learn about multi-dimensional (rank > 1) arrays Learn about multi-dimensional array storage Learn about the RESHAPE function Learn about allocatable arrays & the ALLOCATE and DEALLOCATE
More informationChapter 4. Fortran Arrays
Chapter 4. Fortran Arrays Fortran arrays are any object with the dimension attribute. In Fortran 90/95, and in HPF, arrays may be very different from arrays in older versions of Fortran. Arrays can have
More informationVector: A series of scalars contained in a column or row. Dimensions: How many rows and columns a vector or matrix has.
ASSIGNMENT 0 Introduction to Linear Algebra (Basics of vectors and matrices) Due 3:30 PM, Tuesday, October 10 th. Assignments should be submitted via e-mail to: matlabfun.ucsd@gmail.com You can also submit
More informationFORTRAN - ARRAYS. For example, to declare a one-dimensional array named number, of real numbers containing 5 elements, you write,
http://www.tutorialspoint.com/fortran/fortran_arrays.htm FORTRAN - ARRAYS Copyright tutorialspoint.com Arrays can store a fixed-size sequential collection of elements of the same type. An array is used
More informationINTRODUCTION TO FORTRAN PART II
INTRODUCTION TO FORTRAN PART II Prasenjit Ghosh An example: The Fibonacci Sequence The Fibonacci sequence consists of an infinite set of integer nos. which satisfy the following recurrence relation x n
More informationReview More Arrays Modules Final Review
OUTLINE 1 REVIEW 2 MORE ARRAYS Using Arrays Why do we need dynamic arrays? Using Dynamic Arrays 3 MODULES Global Variables Interface Blocks Modular Programming 4 FINAL REVIEW THE STORY SO FAR... Create
More informationBits, Bytes, and Precision
Bits, Bytes, and Precision Bit: Smallest amount of information in a computer. Binary: A bit holds either a 0 or 1. Series of bits make up a number. Byte: 8 bits. Single precision variable: 4 bytes (32
More informationChapter 6. A Brief Introduction to Fortran David A. Padua
Chapter 6. A Brief Introduction to Fortran 90 1998 David A. Padua 1 of 15 6.1 Data Types and Kinds Data types Intrisic data types (INTEGER, REAL,LOGICAL) derived data types ( structures or records in other
More informationDeclaration and Initialization
6. Arrays Declaration and Initialization a1 = sqrt(a1) a2 = sqrt(a2) a100 = sqrt(a100) real :: a(100) do i = 1, 100 a(i) = sqrt(a(i)) Declaring arrays real, dimension(100) :: a real :: a(100) real :: a(1:100)!
More informationA Brief Introduction to Fortran of 15
A Brief Introduction to Fortran 90 1 of 15 Data Types and Kinds Data types Intrisic data types (INTEGER, REAL,LOGICAL) derived data types ( structures or records in other languages) kind parameter (or
More informationAllocating Storage for 1-Dimensional Arrays
Allocating Storage for 1-Dimensional Arrays Recall that if we know beforehand what size we want an array to be, then we allocate storage in the declaration statement, e.g., real, dimension (100 ) :: temperatures
More information2 3. Syllabus Time Event 9:00{10:00 morning lecture 10:00{10:30 morning break 10:30{12:30 morning practical session 12:30{1:30 lunch break 1:30{2:00 a
1 Syllabus for the Advanced 3 Day Fortran 90 Course AC Marshall cuniversity of Liverpool, 1997 Abstract The course is scheduled for 3 days. The timetable allows for two sessions a day each with a one hour
More informationSHAPE Returns the number of elements in each direction in an integer vector.
Chapter 5: Arrays An advantage fortran has over other programming languages is the ease with which it handles arrays. Because arrays are so easy to handle, fortran is an ideal choice when writing code
More informationMaltepe University Computer Engineering Department. BİL 133 Algorithms and Programming. Chapter 8: Arrays
Maltepe University Computer Engineering Department BİL 133 Algorithms and Programming Chapter 8: Arrays What is an Array? Scalar data types use a single memory cell to store a single value. For many problems
More informationAn array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type.
Data Structures Introduction An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type. Representation of a large number of homogeneous
More informationIntroduction to Programming with Fortran 90
Introduction to Programming with Fortran 90 p. 1/?? Introduction to Programming with Fortran 90 Array Concepts Nick Maclaren Computing Service nmm1@cam.ac.uk, ext. 34761 November 2007 Introduction to Programming
More information6.1 Expression Evaluation. 1 of 21
6.1 Expression Evaluation 1 of 21 The world of expressions In the absence of side effects, expressions are relatively simple and nice objects. Functional programming languages rely on expressions as their
More informationPractical Exercise 1 Question 1: The Hello World Program Write a Fortran 95 program to write out Hello World on the screen.
Practical Exercise Question : The Hello World Program Write a Fortran 95 program to write out Hello World on the screen. Question : Some Division One Results A particular number can be expressed as the
More informationV2 3/5/2012. Programming in C. Introduction to Arrays. 111 Ch 07 A 1. Introduction to Arrays
Programming in C 1 Introduction to Arrays A collection of variable data Same name Same type Contiguous block of memory Can manipulate or use Individual variables or List as one entity 2 Celsius temperatures:
More informationAMath 483/583 Lecture 8
AMath 483/583 Lecture 8 This lecture: Fortran subroutines and functions Arrays Dynamic memory Reading: class notes: Fortran Arrays class notes: Fortran Subroutines and Functions class notes: gfortran flags
More informationC for Engineers and Scientists: An Interpretive Approach. Chapter 10: Arrays
Chapter 10: Arrays 10.1 Declaration of Arrays 10.2 How arrays are stored in memory One dimensional (1D) array type name[expr]; type is a data type, e.g. int, char, float name is a valid identifier (cannot
More informationIntroduction to Arrays. Midterm Comments. Midterm Results. Midterm Comments II. Function Basics (Problem 2) Introduction to Arrays April 11, 2017
Introduction to Arrays Larry Caretto Mechanical Engineering 209 Computer Programming for Mechanical Engineers 11, 2017 Outline Review midterm Array notation and declaration Minimum subscript for arrays
More informationHow to declare an array in C?
Introduction An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type. Representation of a large number of homogeneous values.
More informationMATLAB NOTES. Matlab designed for numerical computing. Strongly oriented towards use of arrays, one and two dimensional.
MATLAB NOTES Matlab designed for numerical computing. Strongly oriented towards use of arrays, one and two dimensional. Excellent graphics that are easy to use. Powerful interactive facilities; and programs
More informationChapter 7: Programming in MATLAB
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming (ECIV 2302) Chapter 7: Programming in MATLAB 1 7.1 Relational and Logical Operators == Equal to ~=
More informationMore Coarray Features. SC10 Tutorial, November 15 th 2010 Parallel Programming with Coarray Fortran
More Coarray Features SC10 Tutorial, November 15 th 2010 Parallel Programming with Coarray Fortran Overview Multiple Dimensions and Codimensions Allocatable Coarrays and Components of Coarray Structures
More informationSize, Alignment, and Value Ranges of Data Types. Type Synonym Size Alignment Value Range. BYTE INTEGER*1 8 bits Byte
Chapter 2 2. Storage Mapping This chapter contains two sections: Alignment, Size, and Value Ranges describes how the Fortran compiler implements size and value ranges for various data types as well as
More informationArray Accessing and Strings ENGR 1181 MATLAB 3
Array Accessing and Strings ENGR 1181 MATLAB 3 Array Accessing In The Real World Recall from the previously class that seismic data is important in structural design for civil engineers. Accessing data
More informationMatrix Multiplication
Matrix Multiplication CPS343 Parallel and High Performance Computing Spring 2013 CPS343 (Parallel and HPC) Matrix Multiplication Spring 2013 1 / 32 Outline 1 Matrix operations Importance Dense and sparse
More informationModule 25.2: nag correl Correlation Analysis. Contents
Correlation and Regression Analysis Module Contents Module 25.2: nag correl Correlation Analysis nag correl contains procedures that calculate the correlation coefficients for a set of data values. Contents
More informationData Types (cont.) Subset. subtype in Ada. Powerset. set of in Pascal. implementations. CSE 3302 Programming Languages 10/1/2007
CSE 3302 Programming Languages Data Types (cont.) Chengkai Li Fall 2007 Subset U = { v v satisfies certain conditions and v V} Ada subtype Example 1 type Digit_Type is range 0..9; subtype IntDigit_Type
More informationMatrix Multiplication
Matrix Multiplication CPS343 Parallel and High Performance Computing Spring 2018 CPS343 (Parallel and HPC) Matrix Multiplication Spring 2018 1 / 32 Outline 1 Matrix operations Importance Dense and sparse
More informationChapter 3. Fortran Statements
Chapter 3 Fortran Statements This chapter describes each of the Fortran statements supported by the PGI Fortran compilers Each description includes a brief summary of the statement, a syntax description,
More informationModule 7.2: nag sym fft Symmetric Discrete Fourier Transforms. Contents
Transforms Module Contents Module 7.2: nag sym fft Symmetric Discrete Fourier Transforms nag sym fft provides procedures for computations involving one-dimensional real symmetric discrete Fourier transforms.
More informationCSI33 Data Structures
Outline Department of Mathematics and Computer Science Bronx Community College September 6, 2017 Outline Outline 1 Chapter 2: Data Abstraction Outline Chapter 2: Data Abstraction 1 Chapter 2: Data Abstraction
More informationArrays. CSE 142 Programming I. Chapter 8. Another Motivation - Averaging Grades. Motivation: Sorting. Data Structures. Arrays
CSE 142 Programming I Chapter 8 8.1 Declaration and Referencing 8.2 Subscripts 8.3 Loop through arrays Arrays 8.4 & 8.5 Arrays arguments and parameters 8.6 Example 8.7 Multi-Dimensional Arrays 2000 UW
More informationArrays. CS10001: Programming & Data Structures. Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur
Arrays CS10001: Programming & Data Structures Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Array Many applications require multiple data items that have common
More informationArrays. CS10001: Programming & Data Structures. Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur
Arrays CS10001: Programming & Data Structures Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur 1 Array Many applications require multiple data items that have common
More informationCS 1313 Spring 2000 Lecture Outline
1. What is a Computer? 2. Components of a Computer System Overview of Computing, Part 1 (a) Hardware Components i. Central Processing Unit ii. Main Memory iii. The Bus iv. Loading Data from Main Memory
More informationLecture 2 Arrays, Searching and Sorting (Arrays, multi-dimensional Arrays)
Lecture 2 Arrays, Searching and Sorting (Arrays, multi-dimensional Arrays) In this lecture, you will: Learn about arrays Explore how to declare and manipulate data into arrays Understand the meaning of
More information(8-1) Arrays I H&K Chapter 7. Instructor - Andrew S. O Fallon CptS 121 (October 8, 2018) Washington State University
(8-1) Arrays I H&K Chapter 7 Instructor - Andrew S. O Fallon CptS 121 (October 8, 2018) Washington State University What is an array? A sequence of items that are contiguously allocated in memory All items
More informationArray Processing { Part II. Multi-Dimensional Arrays. 1. What is a multi-dimensional array?
Array Processing { Part II Multi-Dimensional Arrays 1. What is a multi-dimensional array? A multi-dimensional array is simply a table (2-dimensional) or a group of tables. The following is a 2-dimensional
More informationArrays. CSE / ENGR 142 Programming I. Chapter 8. Another Motivation - Averaging Grades. Motivation: Sorting. Data Structures.
CSE / ENGR 142 Programming I Arrays Chapter 8 8.1 Declaration and Referencing 8.2 Subscripts 8.3 Loop through arrays 8.4 & 8.5 Arrays arguments and parameters 8.6 Example 8.7 Multi-Dimensional Arrays 1998
More informationIntroduction to Computer Science Midterm 3 Fall, Points
Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do
More informationModule 28.3: nag mv rotation Rotations. Contents
Multivariate Analysis Module Contents Module 28.3: nag mv rotation Rotations nag mv rotation contains a procedure to compute rotations for sets of data values. Contents Introduction..............................................................
More informationLecture V: Introduction to parallel programming with Fortran coarrays
Lecture V: Introduction to parallel programming with Fortran coarrays What is parallel computing? Serial computing Single processing unit (core) is used for solving a problem One task processed at a time
More informationOUTLINES. Variable names in MATLAB. Matrices, Vectors and Scalar. Entering a vector Colon operator ( : ) Mathematical operations on vectors.
1 LECTURE 3 OUTLINES Variable names in MATLAB Examples Matrices, Vectors and Scalar Scalar Vectors Entering a vector Colon operator ( : ) Mathematical operations on vectors examples 2 VARIABLE NAMES IN
More informationChapter 6: Arrays. Starting Out with Games and Graphics in C++ Second Edition. by Tony Gaddis
Chapter 6: Arrays Starting Out with Games and Graphics in C++ Second Edition by Tony Gaddis 6.1 Array Basics An array allows you to store a group of items of the same data type together in memory Why?
More informationfunction [s p] = sumprod (f, g)
Outline of the Lecture Introduction to M-function programming Matlab Programming Example Relational operators Logical Operators Matlab Flow control structures Introduction to M-function programming M-files:
More informationIntroduction to Fortran95 Programming Part II. By Deniz Savas, CiCS, Shef. Univ., 2018
Introduction to Fortran95 Programming Part II By Deniz Savas, CiCS, Shef. Univ., 2018 Summary of topics covered Logical Expressions, IF and CASE statements Data Declarations and Specifications ARRAYS and
More informationSlide 1 CS 170 Java Programming 1 Multidimensional Arrays Duration: 00:00:39 Advance mode: Auto
CS 170 Java Programming 1 Working with Rows and Columns Slide 1 CS 170 Java Programming 1 Duration: 00:00:39 Create a multidimensional array with multiple brackets int[ ] d1 = new int[5]; int[ ][ ] d2;
More informationVectors and Matrices. Chapter 2. Linguaggio Programmazione Matlab-Simulink (2017/2018)
Vectors and Matrices Chapter 2 Linguaggio Programmazione Matlab-Simulink (2017/2018) Matrices A matrix is used to store a set of values of the same type; every value is stored in an element MATLAB stands
More informationCSE 262 Spring Scott B. Baden. Lecture 4 Data parallel programming
CSE 262 Spring 2007 Scott B. Baden Lecture 4 Data parallel programming Announcements Projects Project proposal - Weds 4/25 - extra class 4/17/07 Scott B. Baden/CSE 262/Spring 2007 2 Data Parallel Programming
More informationIntroduction to Programming for Engineers Spring Final Examination. May 10, Questions, 170 minutes
Final Examination May 10, 2011 75 Questions, 170 minutes Notes: 1. Before you begin, please check that your exam has 28 pages (including this one). 2. Write your name and student ID number clearly on your
More informationPersonal SE. Functions & Arrays
Personal SE Functions & Arrays Functions in C Syntax like Java methods but w/o public, abstract, etc. As in Java, all arguments (well, most arguments) are passed by value. Example: void try_swap( int x,
More informationModule 6: Array in C
1 Table of Content 1. Introduction 2. Basics of array 3. Types of Array 4. Declaring Arrays 5. Initializing an array 6. Processing an array 7. Summary Learning objectives 1. To understand the concept of
More informationLecture 2: Variables, Vectors and Matrices in MATLAB
Lecture 2: Variables, Vectors and Matrices in MATLAB Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 1 and Chapter 2. Variables
More informationAppendix D. Fortran quick reference
Appendix D Fortran quick reference D.1 Fortran syntax... 315 D.2 Coarrays... 318 D.3 Fortran intrisic functions... D.4 History... 322 323 D.5 Further information... 324 Fortran 1 is the oldest high-level
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
9/5/6 CS Introduction to Computing II Wayne Snyder Department Boston University Today: Arrays (D and D) Methods Program structure Fields vs local variables Next time: Program structure continued: Classes
More informationCHAPTER 5 SYSTEMS OF EQUATIONS. x y
page 1 of Section 5.1 CHAPTER 5 SYSTEMS OF EQUATIONS SECTION 5.1 GAUSSIAN ELIMINATION matrix form of a system of equations The system 2x + 3y + 4z 1 5x + y + 7z 2 can be written as Ax where b 2 3 4 A [
More informationChapter 9 Introduction to Arrays. Fundamentals of Java
Chapter 9 Introduction to Arrays Objectives Write programs that handle collections of similar items. Declare array variables and instantiate array objects. Manipulate arrays with loops, including the enhanced
More informationThe G3 F2PY for connecting Python to Fortran 90 programs
The G3 F2PY for connecting Python to Fortran 90 programs Pearu Peterson pearu@simula.no F2PY What is it? Example. What more it can do? What it cannot do? G3 F2PY The 3rd generation of F2PY. Aims and status.
More informationPROGRAMS. EXCELLENT ACADEMY OF ENGINEERING. Telephone: / NORMAL PROGRAM
PROGRAMS NORMAL PROGRAM 1. Wap to display months in words where month in number is input. 2. Wap to print Fibonacci series till n elements. 3. Wap to reverse 4 digit numbers. 4. Wap to accept a number
More informationHigh Performance Fortran http://www-jics.cs.utk.edu jics@cs.utk.edu Kwai Lam Wong 1 Overview HPF : High Performance FORTRAN A language specification standard by High Performance FORTRAN Forum (HPFF), a
More informationMIDTERM EXAM (Solutions)
MIDTERM EXAM (Solutions) Total Score: 100, Max. Score: 83, Min. Score: 26, Avg. Score: 57.3 1. (10 pts.) List all major categories of programming languages, outline their definitive characteristics and
More informationCSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Functions
1 CSCE 314: Programming Languages Dr. Flemming Andersen Haskell Functions 2 Outline Defining Functions List Comprehensions Recursion 3 Conditional Expressions As in most programming languages, functions
More informationQ1: Functions / 33 Q2: Arrays / 47 Q3: Multiple choice / 20 TOTAL SCORE / 100 Q4: EXTRA CREDIT / 10
EECE.2160: ECE Application Programming Spring 2018 Exam 2 March 30, 2018 Name: Lecture time (circle 1): 8-8:50 (Sec. 201) 12-12:50 (Sec. 202) For this exam, you may use only one 8.5 x 11 double-sided page
More informationCS 2505 Computer Organization I
Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other computing devices may
More informationIntroduction to MatLab. Introduction to MatLab K. Craig 1
Introduction to MatLab Introduction to MatLab K. Craig 1 MatLab Introduction MatLab and the MatLab Environment Numerical Calculations Basic Plotting and Graphics Matrix Computations and Solving Equations
More informationC++ Programming. Arrays and Vectors. Chapter 6. Objectives. Chiou. This chapter introduces the important topic of data structures collections
C++ Programming Chapter 6 Arrays and Vectors Yih-Peng Chiou Room 617, BL Building (02) 3366-3603 3603 ypchiou@cc.ee.ntu.edu.tw Photonic Modeling and Design Lab. Graduate Institute of Photonics and Optoelectronics
More informationModule 19.1: nag ip Integer Programming. Contents
Operations Research Module Contents Module 19.1: nag ip Integer Programming nag ip contains a procedure for solving zero-one, general, mixed or all integer linear programming problems. Contents Introduction..............................................................
More informationPointers and Arrays 1
Pointers and Arrays 1 Pointers and Arrays When an array is declared, The compiler allocates sufficient amount of storage to contain all the elements of the array in contiguous memory locations The base
More informationArrays. Arizona State University 1
Arrays CSE100 Principles of Programming with C++, Fall 2018 (based off Chapter 8 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationFortran 2003 Part 1. École normale supérieure L3 geosciences 2018/2019. Lionel GUEZ Laboratoire de météorologie dynamique Office E324
Fortran 2003 Part 1 École normale supérieure L3 geosciences 2018/2019 Lionel GUEZ guez@lmd.ens.fr Laboratoire de météorologie dynamique Office E324 Modification date: Apr 1, 2019 Contents (1/2) Introduction
More information1 Lexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler
More informationCSC Advanced Scientific Computing, Fall Numpy
CSC 223 - Advanced Scientific Computing, Fall 2017 Numpy Numpy Numpy (Numerical Python) provides an interface, called an array, to operate on dense data buffers. Numpy arrays are at the core of most Python
More informationNAGWare f95 Recent and Future Developments
NAGWare f95 Recent and Future Developments Malcolm Cohen The Numerical Algorithms Group Ltd., Oxford Nihon Numerical Algorithms Group KK, Tokyo Contents 1. Standard Fortran 2. High Performance 3. NAGWare
More informationModule 25.1: nag lin reg Regression Analysis. Contents
Correlation and Regression Analysis Module Contents Module 25.1: nag lin reg Regression Analysis nag lin reg contains procedures that perform a simple or multiple linear regression analysis. Contents Introduction...
More informationDr Richard Greenaway
SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 3 Creating, Organising & Processing Data Dr Richard Greenaway 3 Creating, Organising & Processing Data In this Workshop the matrix type is introduced
More informationIntroduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays
Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #43 Multidimensional Arrays In this video will look at multi-dimensional arrays. (Refer Slide Time: 00:03) In
More informationHPF commands specify which processor gets which part of the data. Concurrency is defined by HPF commands based on Fortran90
149 Fortran and HPF 6.2 Concept High Performance Fortran 6.2 Concept Fortran90 extension SPMD (Single Program Multiple Data) model each process operates with its own part of data HPF commands specify which
More informationWhy Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation
Lecture 2 Bits and Bytes Topics! Why bits?! Representing information as bits " Binary/Hexadecimal " Byte representations» numbers» characters and strings» Instructions! Bit-level manipulations " Boolean
More informationA First Book of ANSI C Fourth Edition. Chapter 8 Arrays
A First Book of ANSI C Fourth Edition Chapter 8 Arrays One-Dimensional Arrays Array Initialization Objectives Arrays as Function Arguments Case Study: Computing Averages and Standard Deviations Two-Dimensional
More informationFORM 2 (Please put your name and form # on the scantron!!!!)
CS 161 Exam 2: FORM 2 (Please put your name and form # on the scantron!!!!) True (A)/False(B) (2 pts each): 1. Recursive algorithms tend to be less efficient than iterative algorithms. 2. A recursive function
More informationFortran 90 - A thumbnail sketch
Fortran 90 - A thumbnail sketch Michael Metcalf CERN, Geneva, Switzerland. Abstract The main new features of Fortran 90 are presented. Keywords Fortran 1 New features In this brief paper, we describe in
More informationProgramming for Engineers Arrays
Programming for Engineers Arrays ICEN 200 Spring 2018 Prof. Dola Saha 1 Array Ø Arrays are data structures consisting of related data items of the same type. Ø A group of contiguous memory locations that
More informationActivity 7: Arrays. Content Learning Objectives. Process Skill Goals
Activity 7: Arrays Programs often need to store multiple values of the same type, such as a list of phone numbers, or the names of your top 20 favorite songs. Rather than create a separate variable for
More informationIntroduction to Matrix Operations in Matlab
Introduction to Matrix Operations in Matlab Gerald W. Recktenwald Department of Mechanical Engineering Portland State University gerry@pdx.edu ME 350: Introduction to Matrix Operations in Matlab Overview
More informationCS , Fall 2001 Exam 2
Andrew login ID: Full Name: CS 15-213, Fall 2001 Exam 2 November 13, 2001 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front. Write
More informationChapter 7 Multidimensional Arrays
Chapter 7 Multidimensional Arrays 1 Motivations You can use a two-dimensional array to represent a matrix or a table. Distance Table (in miles) Chicago Boston New York Atlanta Miami Dallas Houston Chicago
More informationThere are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals:
Numeric Types There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals: 1-123 +456 2. Long integers, of unlimited
More informationWhy Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation
Lecture 2 Bits and Bytes Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bit-level manipulations Boolean algebra
More informationBITG 1113: Array (Part 1) LECTURE 8
BITG 1113: Array (Part 1) LECTURE 8 1 1 LEARNING OUTCOMES At the end of this lecture, you should be able to: 1. Describe the fundamentals of arrays 2. Describe the types of array: One Dimensional (1 D)
More informationChapter 7 Multidimensional Arrays. Liang, Introduction to Java Programming, Tenth Edition, (c) 2013 Pearson Education, Inc. All rights reserved.
Chapter 7 Multidimensional Arrays rights reserved. 1 Motivations Thus far, you have used one-dimensional arrays to model linear collections of elements. You can use a two-dimensional array to represent
More informationPage 1 of 7. Date: 1998/05/31 To: WG5 From: J3/interop Subject: Interoperability syntax (Part 1) References: J3/98-132r1, J3/98-139
(J3/98-165r1) Date: 1998/05/31 To: WG5 From: J3/interop Subject: Interoperability syntax (Part 1) References: J3/98-132r1, J3/98-139 ISO/IEC JTC1/SC22/WG5 N1321 Page 1 of 7 Describing pre-defined C data
More informationNAGWare f95 and reliable, portable programming.
NAGWare f95 and reliable, portable programming. Malcolm Cohen The Numerical Algorithms Group Ltd., Oxford How to detect errors using NAGWare f95, and how to write portable, reliable programs. Support for
More informationMATLAB COURSE FALL 2004 SESSION 1 GETTING STARTED. Christian Daude 1
MATLAB COURSE FALL 2004 SESSION 1 GETTING STARTED Christian Daude 1 Introduction MATLAB is a software package designed to handle a broad range of mathematical needs one may encounter when doing scientific
More informationUNIVERSITY OF CALIFORNIA, COLLEGE OF ENGINEERING E77N: INTRODUCTION TO COMPUTER PROGRAMMING FOR SCIENTISTS AND ENGINEERS
Page 1 of 14 UNIVERSITY OF CALIFORNIA, COLLEGE OF ENGINEERING E77N: INTRODUCTION TO COMPUTER PROGRAMMING FOR SCIENTISTS AND ENGINEERS Final Exam May 18, 2002 12:30 3:30 pm TOTAL 100 POINTS Notes: 1. Write
More informationArray programming languages
Array programming languages Alexander Harms Institute for software engineering and programming languages January 18, 2016 1 Table of Contents I. Introduction II. MATLAB III. APL IV. QUBE V. Conclusion
More informationClass Notes, 3/21/07, Operating Systems
Class Notes, 3/21/07, Operating Systems Hi, Jane. Thanks again for covering the class. One of the main techniques the students need to how to recognize when there is a cycle in a directed graph. (Not all
More information