Tables1 TABLES (chp. 12) group of storage locations (i.e. elements) with the same name accessed by name and subscript ex. var-name (sub) similar to arrays.

Slides:



Advertisements
Similar presentations
Topic Reviews For Unit ET156 – Introduction to C Programming Topic Reviews For Unit
Advertisements

Arithmetic Calculations
M The University Of Michigan Andrew M. Morgan EECS Lecture 01 Savitch Ch. 2 C++ Basics Flow Of Control.
Chapter 4 Computation Bjarne Stroustrup
1 Arrays, Strings and Collections [1] Rajkumar Buyya Grid Computing and Distributed Systems (GRIDS) Laboratory Dept. of Computer Science and Software Engineering.
Copyright © 2003 Pearson Education, Inc. Slide 1.
Copyright © 2003 Pearson Education, Inc. Slide 1.
Chapter 9 – One-Dimensional Numeric Arrays. Array u Data structure u Grouping of like-type data u Indicated with brackets containing positive integer.
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 C Programming
Problem Solving & Program Design in C
Credit hours: 4 Contact hours: 50 (30 Theory, 20 Lab) Prerequisite: TB143 Introduction to Personal Computers.
DT266/2 Information Systems COBOL Revision. Chapters 1 & 2 Hutty & Spence Divisions of a Cobol Program Identification Division Program-ID. Environment.
1.
Chapter 7: Arrays In this chapter, you will learn about
© 2004 Goodrich, Tamassia Hash Tables
DT266/2 COBOL Basics – Declaring Data Basic Operations.
Structured COBOL Programming
Chapter 8: Arrays.
Do Now: You may not use a calculator!
CS 141 Computer Programming 1 1 Arrays. Outline  Introduction  Arrays  Declaring Arrays  Examples Using Arrays  Sorting Arrays  Multiple-Subscripted.
What Does This Program Do?
Chapter Three Arithmetic Expressions and Assignment Statements
1 Chapter 3:Operators and Expressions| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2006 | Last Updated: July 2006 Slide 1 Operators and Expressions.
Check Digit - Mod 11 Please use speaker notes for additional information!
CS 1 Introduction CS 1 Part 11. Hardware 1.Central Processing Unit (CPU) 2.Main Memory 3.Secondary Memory / Storage 4.Input Devices 5.Output Devices CS.
1 Arrays and Strings Chapter 9 2 "All students to receive arrays!" reports Dr. Austin. Declaring arrays scores :
The simple built-in data types of the C language such as int, float, - are not sufficient to represent complex data such as lists, tables, vectors, and.
PL/SQL User Defined Types Record and Table Please use speaker notes for additional information!
12-Apr-15 Analysis of Algorithms. 2 Time and space To analyze an algorithm means: developing a formula for predicting how fast an algorithm is, based.
Arrays and Strings.
12-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
Chapter 12 Array Processing and Table Handling. Defining Series of Input Fields Coding record with 24 independent hourly fields is cumbersome 01Temp-Rec.
Advanced Tables.. 01 JeansTable. One Dimension Table.
25 October Conditionals and Loops. Presentations Brendan: Cyberwarfare Casey: Online shopping (No current event today)
Understanding Arrays and Pointers Object-Oriented Programming Using C++ Second Edition 3.
ISAT 252 Introduction to Arrays. Should have read 2 Chapter 8 –pp , and pp
12-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
12-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
12- 1 Chapter 12.  Single-Level OCCURS Clauses  Processing Data Stored in Array  Using OCCURS Clause for Table Handling  Use of SEARCH Statement 
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Chapter 5 Using Data and COBOL Operators. Initializing Variables When you define a variable in WORKING- STORAGE, you also can assign it an initial value.
The DATA DIVISION Chapter 3. COBOL Data Organization Field - group of characters forming a meaningful unit or basic fact –Characters in a name or digits.
3-1 Chapter 3. To familiarize you with  Ways in which data is organized in COBOL  Rules for forming data-names  Defining input and output files in.
CS CS Computing for Business Instructor:David Tucker GTA:Batul Mirza.
What is an Array? An array is a collection of variables. Arrays have three important properties: –group of related items(for example, temperature for.
BUILDING JAVA PROGRAMS CHAPTER 7 Arrays. Exam #2: Chapters 1-6 Thursday Dec. 4th.
Chapter 12 (part 2) Table Handling and Search Techniques.
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
C++ for Engineers and Scientists Second Edition Chapter 11 Arrays.
Lecture 41 Arithmetic Clauses The ROUNDED clause –Place ROUNDED after the variable that holds the result ADD A TO B ROUNDED. ADD A TO B GIVING C ROUNDED.
Programming, an introduction to Pascal
11- 1 Chapter 11.  Avoiding Logic Errors by Validating Input  What to Do If Input Errors Occur  Global Considerations in COBOL  When Data Should Be.
12- 1 Chapter 12.  Single-Level OCCURS Clauses  Processing Data Stored in Array  Using OCCURS Clause for Table Handling  Use of SEARCH Statement 
1 Chapter 5 – The Procedure Division File handling statements –OPEN statement Initiates processing for a file Input Output Each file opened must have been.
1 Review for test 2 Chapters 7, 8, 9, 11, What is wrong with the following paragraphs? PARA-A. PARA-B. ADD A TO B MOVE 0 TO X PERFROM PARA-A PERFORM.
11- 1 Chapter 11.  Avoiding Logic Errors by Validating Input  What to Do If Input Errors Occur  Global Considerations in COBOL  When Data Should Be.
12-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
For Friday Read No quiz Program 6 due. Program 6 Any questions?
CHAPTER 6 ARRAYS IN C 1 st semester King Saud University College of Applied studies and Community Service Csc 1101 F. Alakeel.
Data Storage So far variables have been able to store only one value at a time. What do you do if you have many similar values that all need to be stored?
12-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Screen I/O ACCEPT DISPLAY Relevant to the Fujitsu Compiler.
Programming in COBOL.
Chapter 3 The DATA DIVISION.
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
THE COMPUTE STATEMENT Purpose: performs mathematical calculations
CHAPTER 17 The Report Writer Module
Intro to Programming Concepts
Presentation transcript:

Tables1 TABLES (chp. 12) group of storage locations (i.e. elements) with the same name accessed by name and subscript ex. var-name (sub) similar to arrays in other languages

Tables2 Integer values from 1 to occurs clause value (specifies maximum value) Up to 7 subscripts are permitted in COBOL Subscripts are listed in parenthesis following the table name Each time the value of a subscript changes, data-name (sub) refers to a different element in the array Using a data-name as a subscript enables its contents to be varied Relative subscripting is used when what is in parenthesis can be an arithmetic expression if using subscript constants (named or literal) compiler will detect error if using subscript variables, error won't be detected until run-time Defines the number of elements in the table for each level Defines the maximum subscript for each level Up to seven levels of OCCURS permitted in COBOL Can not be used on 01 level item OCCURS Clause SUBSCRIPTS

Tables3 TABLE examples If item defined by OCCURS has PIC clause, it defines a series of elementary items 01 Totals. 05 Month-Totals Occurs 12 Times Pic 9(5)V99. For your information When a variable name has an OCCURS clause on it or above it with a smaller level number, it must have one subscript when referencing that memory location for each OCCURS.

Tables4 TABLE examples Identifier used with OCCURS may also be group item 01 Tax-Table. 05 Group-X Occurs 20 Times. 10 City Pic X(6). 10 Tax-RatePic V999.

Tables5 EXAMPLE #1 01 DAYS-OF-MONTH-TABLE. 03 MONTHS OCCURS 12 times. 05 Month-Name PIC X(15). 05 Month-Num-DaysPIC 99. Move January to Month-Name (1) Move 31 to Month-Num-Days (1) EXAMPLE #2 01 DAYS-OF-MONTH-TABLE. 05 Month-Name PIC X(15) OCCURS 12 TIMES. 05 Month-Num-DaysPIC 99 OCCURS 12 TIMES. Move January to Month-Name (1) Move 31 to Month-Num-Days (1) More TABLE examples How else initialize Month-Name and Month-Num-Days?!

Tables6 01 GRADE-TABLE. 05 QUIZ-TABLE OCCURS 40 TIMES. 10 QUIZ1 PIC 9(2). 10 QUIZ2 PIC 9(2). 10 QUIZ3 PIC 9(2). 10 QUIZ4 PIC 9(2). How do we average all the quiz scores for QUIZ4? Compute-Average-Quiz4. MOVE ZERO TO Total-Grade MOVE 1 TO Sub PERFORM UNTIL Sub > Num-Quizzes ADD QUIZ4(Sub) TO Total-Grade ADD 1 TO Sub END-PERFORM DIVIDE Total-Grade BY Num-Quizzes GIVING Average-Score One More TABLE example ***Convert to Perform-Varying

Tables7 Two ways to use VALUE clause to initialize all elements to zero: 01 Array-1Value Zero. 05 Totals Occurs 50 Times Pic 9(5). 01 Array Totals Occurs 50 Times Pic 9(5) Value Zero. Can also initialize each element to different value 01 Day-Names Value 'SUNMONTUEWEDTHUFRISAT'. 05 Days Occurs 7 Times Pic X(3). ??? Can an initialization be done on the 05 directly above??? INITIALIZE STATEMENT (i.e. in Procedure Division) A series of elementary items contained within a group item can all be initialized. Numeric items will be initialized to zero and nonnumeric items will be initialized to blank. FORMAT: INITIALIZE {identifier-1} … INITIALIZING TABLES

Tables8 REDEFINES Purpose : Used to define a field with a value clause then redefine it as an array. However, you cannot do the reverse; that is, once an entry has been defined by an OCCURS clause, it may NOT be redefined. FORMAT in Data Division: L# identifier-1 REDEFINES identifier-2 [finish declaration] where: L# means level number Identifier-1 and identifier-2 must be on the same level EXAMPLES : See table example program 01 Rates Rate PIC 99V999 value Rate REDEFINES 10Rate PIC 999V Rate REDEFINES 10Rate PIC 9999V9. Result 100Rate = and 1000Rate = HoldDate. 02 EuroDate. 03 EuroDay PIC 99 value EuroMonth PIC 99 value EuroYear PIC 9(4) value USDate REDEFINES EuroDate. 03 USMonth PIC USDay PIC USYear PIC 9(4). USMonth = 3 and USDay = 11

Tables9 Define array as follows: 01 Temperature-Array. 05Day-In-Week Occurs 7 Times. 10 Hour Occurs 24 Times. 15 TempPic 9(3). 2 dimensional TABLES (ex#1) For your information : If reading in from file, what does input file look like?! FD input file 01 input-rec pic 999. Find the average temp for: each day. Find the average temp for each hour. PARTICIPATION POINTS (5) (due in one week – graded on if works!) What if have negative temperatures? How solve?! That is, what does input file look like? What does declaration look like? Perform a from 1 by 1 until a > 7 perform b from 1 by 1 until b > 24 read input-file at end.. move input-rec to temp (a b) end-perform End-perform

Tables10 2 dimensional TABLES (ex#2) 01 Jeans-Table. 05 Jean-Gender OCCURS 2 TIMES. 10 Jean-Color OCCURS 3 TIMES. 15 Jean-SalesValue PIC 9(8)V Jean-NumSold PIC 9(7).

Tables11 2 dimensional TABLES (ex#3) 01 Jeans-Table. 05 Jean-Size OCCURS 10 TIMES. 10 Exact-Size PIC Jean-Style PIC X. 10 Jean-Color OCCURS 3 TIMES. 15 Jean-SalesValue PIC 9(8)V Jean-NumSold PIC 9(7).