General Introduction Algorithms. Let’s write a program  A program is a collection of statements written in a language the computer understands.  A computer.

Slides:



Advertisements
Similar presentations
Check Digit - Mod 11 Please use speaker notes for additional information!
Advertisements

Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
CALCULATOR MANIPULATION. Due to the differences in calculators you will have to be able to use your own effectively.
CMSC 104, Version 9/011 Arithmetic Operators Topics Arithmetic Operators Operator Precedence Evaluating Arithmetic Expressions In-class Project Incremental.
- Kav Shrestha.  Introduction  History  Features  COBOL Usage  Characteristics  Structure of COBOL Programs  COBOL Divisions  Data Items  Variable.
BY: JOSHUA THOMAS IGNATIUS TOWERS COBOL. Overview What is COBOL History Design Implementations What did it do Program structure Data types Syntax Sample.
Chapter 15 Indexed Sequential Files. Disk File Organization File is collection of records Three major ways records stored or organized on disk - Sequential.
Pseudocode.
COBOL for the 21 st Century Stern, Stern, Ley Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.
COBOL COmmon Business Oriented Language  Work began in 1959 and has never stopped.
Pseudocode.
COBOL for the 21st Century
First appearedFeaturesMain paradigmsPopular uses COMPUTING Basic FOR A=1 TO 100 IF A MOD 15 = 0 THEN PRINT “FizzBuzz” ELSE IF A MOD 3 = 0 THEN PRINT “Fizz”
Relative Files.. Creating a Relative File $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. CreateRelativeFromSeq. * Creates a Relative file.
Structured COBOL Programming, Stern & Stern, 9th edition
4-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)
Lecture 2 Introduction to C Programming Arne Kutzner Hanyang University / Seoul Korea.
COBOL Basics 1. COBOL coding rules  Almost all COBOL compilers treat a line of COBOL code as if it contained two distinct areas. These are known as;
4-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)
Chapter To familiarize you with  Why COBOL is a popular business-oriented language.  Programming practices and techniques  History of COBOL.
Multiplication by multiples of 10 and 100 Objective to multiply numbers when 0’s are involved.
Introduction to COBOL. COBOL  COBOL is an acronym which stands for Common Business Oriented Language.  The name indicates the target area of COBOL applications.
Modifications to program Addda.cbl Please use speaker notes for additional information!
General Programming Introduction to Computing Science and Programming I.
History COBOL (Common Business Oriented Language) was one of the earliest high-level programming languages. COBOL was first proposed in 1959 by the Conference.
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
Computer Programming Basics Assistant Professor Jeon, Seokhee Assistant Professor Department of Computer Engineering, Kyung Hee University, Korea.
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.
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
Totals on the Screen Please use speaker notes for additional information!
1 Interactive vs Batch Programs Cobol suited for developing both types of programs Interactive programs Accept input data from keyboard Input data processed.
CS CS Computing for Business Instructor:David Tucker GTA:Batul Mirza.
Arithmetic Operators Topics Arithmetic Operators Operator Precedence
COBOL Basics 2. H E N N E S S Y R M L M F Group Items/Records StudentDetails WORKING-STORAGE SECTION. 01StudentDetailsPIC X(26).
Array - adding to array at run time Please see speaker notes for additional information!
Indexed and Relative File Processing
1 The Procedure Division Chapter 4. 2 Main Two Sections File Section –Used to define files and record formats –Field names within records Working Storage.
CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez.
Chapter 2 Pseudocode. Objectives To introduce common words, keywords and meaningful names when writing pseudocode To define the three basic control structures.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
9-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)
Program #2 Cell Phone Usage ….Let’s start with understanding the problem!
EXERCISES for ALGORITHMS WRITING
Chapter 3 Decision Making. What is IF? The primary method of changing the flow of a program is by making decisions using the IF verb. The following example.
HELLO WORLD program in COBOL - CIS12 Please use speaker notes for additional information!
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
COBOL Screens Please use speaker notes for additional information!
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 Chapter 9. To familiarize you with  Simple PERFORM  How PERFORM statements are used for iteration  Options available with PERFORM 2.
Chapter 2 Using Variables and Constant. What is a Constant ? The data in COBOL programs falls in two broad categories: – Constants and Variables A constant.
One & Two dimensional Tables Cont.. Table of Major Codes 02ART HISTORY 04BIOLOGY 19CHEMESTRY 21CIVIL ENGINEERING 24COMP INF SYS 32ECONOMICS 39FINANCE.
IBM-Mainframes COBOL Class-1. Background and History  COBOL is an acronym for: Common Business Oriented Language  COBOL was developed in 1959 by the.
Module 1 1. Cobol Hierarchy Revised on COBOL Hierarchy There are four DIVISIONS:- IDENTIFICATION DIVISION. ENVIRONMENT DIVISION. DATA DIVISION.
CMSC 104, Version 8/061L10ArithmeticOps.ppt Arithmetic Operators Topics Arithmetic Operators Operator Precedence Evaluating Arithmetic Expressions In-class.
INTRODUCTION TO PROGRAMMING. Program Development Life Cycle The program development life cycle is a model that describes the stages involved in a program.
Analysis of SAMPLE1.CBL Please check speaker notes for additional information!
Indexed Files.. Creating an Indexed File $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. CreateIndexedFromSeq. * Creates an indexed file.
WHAT IS THIS? Clue…it’s a drink SIMPLE SEQUENCE CONTROL STRUCTURE Introduction A computer is an extremely powerful, fast machine. In less than a second,
Chapter 4 PROCEDURE DIVISION. Paragraphs PROCEDURE DIVISION divided into paragraphs Each is independent module or routine Made up of series of instructions.
The PERFORM. The PERFORM Verb  Iteration is an important programming construct. We use iteration when we need to repeat the same instructions over and.
Random update Please use speaker notes for additional information!
Lecture Notes 1/20/05 Pseudocode.  Pseudocode standard which we will follow in this class: - Statements are written in simple English; - Each instruction.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Introduction to Sequential Files. COBOL's forte  COBOL is generally used in situations where the volume of data to be processed is large.  These systems.
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
PROGRAM CONTROL STRUCTURE
Chapter 5: Control Structure
An Introduction to Structured Program Design in COBOL
THE COMPUTE STATEMENT Purpose: performs mathematical calculations
Using screens and adding two numbers - addda.cbl
Presentation transcript:

General Introduction Algorithms

Let’s write a program  A program is a collection of statements written in a language the computer understands.  A computer executes program statements one after another in sequence until it reaches the end of the program unless some statement in the program alters the order of execution.  Let’s write a program to accept two numbers from the user, multiply them together and display the result on the screen.  We’ll write the program in COBOL.  What COBOL program statements will we need to do the job?

Program Statements  We need a statement to take in the first number and store it in a named memory location. l l ACCEPT Num1.  We need a statement to take in the second number and store it in a named memory location. l l ACCEPT Num2.  We need a statement to multiply the two numbers together and store the result in a named location. l l MULTIPLY Num1 BY Num2 GIVING Result.  We need a statement to display the result on the screen. l l DISPLAY "Result is = ", Result.

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. Program-1 PROGRAM-ID. Program-1. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result Calc-Result. ACCEPT Num1. MULTIPLY Num1 BY Num2 GIVING Result. ACCEPT Num2. DISPLAY "Result is = ", Result. STOP RUN. Num1 Num2 Result D ATA

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Program-1. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result. ACCEPT Num1 ACCEPT Num1. MULTIPLY Num1 BY Num2 GIVING Result. ACCEPT Num2. DISPLAY "Result is = ", Result. STOP RUN. Num1 Num2 Result D ATA

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Program-1. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result. ACCEPT Num1. MULTIPLY Num1 BY Num2 GIVING Result MULTIPLY Num1 BY Num2 GIVING Result. ACCEPT Num2. DISPLAY "Result is = ", Result. STOP RUN. Num1 Num2 Result D ATA

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Program-1. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result. ACCEPT Num1. MULTIPLY Num1 BY Num2 GIVING Result. ACCEPT Num2 ACCEPT Num2. DISPLAY "Result is = ", Result. STOP RUN. Num1 Num2 Result D ATA

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Program-1. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result. ACCEPT Num1. MULTIPLY Num1 BY Num2 GIVING Result. ACCEPT Num2. DISPLAY "Result is = ", Result DISPLAY "Result is = ", Result. STOP RUN. Num1 Num2 Result D ATA Oh No!! We got the wrong answer. Let’s try again.

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. Program-2 PROGRAM-ID. Program-2. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result Calc-Result. ACCEPT Num1. ACCEPT Num2. DISPLAY "Result is = ", Result. MULTIPLY Num1 BY Num2 GIVING Result. STOP RUN. Num1 Num2 Result D ATA

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Program-2. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result. ACCEPT Num1. ACCEPT Num2. DISPLAY "Result is = ", Result. MULTIPLY Num1 BY Num2 GIVING Result. STOP RUN. Num1 Num2 Result D ATA

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Program-2. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result. ACCEPT Num1. ACCEPT Num2 ACCEPT Num2. DISPLAY "Result is = ", Result. MULTIPLY Num1 BY Num2 GIVING Result. STOP RUN. Num1 Num2 Result D ATA

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Program-2. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result. ACCEPT Num1. ACCEPT Num2. DISPLAY "Result is = ", Result DISPLAY "Result is = ", Result. MULTIPLY Num1 BY Num2 GIVING Result. STOP RUN. Num1 Num2 Result D ATA Oh No!! We got the wrong answer again. Let’s have one more try.

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Program-2. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result. ACCEPT Num1. ACCEPT Num2. DISPLAY "Result is = ", Result. MULTIPLY Num1 BY Num2 GIVING Result MULTIPLY Num1 BY Num2 GIVING Result. STOP RUN. Num1 Num2 Result D ATA

Num1 Num2 Result $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. Sequence-Program PROGRAM-ID. Sequence-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result Calc-Result. ACCEPT Num1. ACCEPT Num2. MULTIPLY Num1 BY Num2 GIVING Result. DISPLAY "Result is = ", Result. STOP RUN D ATA

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Sequence-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result. ACCEPT Num1 ACCEPT Num1. ACCEPT Num2. MULTIPLY Num1 BY Num2 GIVING Result. DISPLAY "Result is = ", Result. STOP RUN Num1 Num2 Result D ATA

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Sequence-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result. ACCEPT Num1. ACCEPT Num2 ACCEPT Num2. MULTIPLY Num1 BY Num2 GIVING Result. DISPLAY "Result is = ", Result. STOP RUN Num1 Num2 Result D ATA

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Sequence-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result. ACCEPT Num1. ACCEPT Num2. MULTIPLY Num1 BY Num2 GIVING Result MULTIPLY Num1 BY Num2 GIVING Result. DISPLAY "Result is = ", Result. STOP RUN Num1 Num2 Result D ATA

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Sequence-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. PROCEDURE DIVISION. Calc-Result. ACCEPT Num1. ACCEPT Num2. MULTIPLY Num1 BY Num2 GIVING Result. DISPLAY "Result is = ", Result DISPLAY "Result is = ", Result. STOP RUN Num1 Num2 Result D ATA Right.. At last!! It’s not enough to know what statements we need. We must make sure the computer executes them in the right order.

 Sequence.  Selection.  Iteration. Programs are written using three main programming constructs Programs are written using three main programming constructs.

Num1 Num2 Result Operator $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. Selection-Program PROGRAM-ID. Selection-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator Calculator. ACCEPT Num1. ACCEPT Num2. ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF. DISPLAY "Result is = ", Result. STOP RUN D ATA _ _

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Selection-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. ACCEPT Num1 ACCEPT Num1. ACCEPT Num2. ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF. DISPLAY "Result is = ", Result. STOP RUN. Num1 Num2 Result Operator D ATA _ _

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Selection-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. ACCEPT Num1. ACCEPT Num2 ACCEPT Num2. ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF. DISPLAY "Result is = ", Result. STOP RUN. Num1 Num2 Result Operator D ATA _ _

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Selection-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. ACCEPT Num1. ACCEPT Num2. ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF. DISPLAY "Result is = ", Result. STOP RUN. Num1 Num2 Result Operator D ATA + +

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Selection-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. ACCEPT Num1. ACCEPT Num2. ACCEPT Operator IF Operator = "+" THEN IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF. DISPLAY "Result is = ", Result. STOP RUN. Num1 Num2 Result Operator D ATA + +

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Selection-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. ACCEPT Num1. ACCEPT Num2. ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF. DISPLAY "Result is = ", Result. STOP RUN. Num1 Num2 Result Operator D ATA + +

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Selection-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. ACCEPT Num1. ACCEPT Num2. ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF END-IF. DISPLAY "Result is = ", Result. STOP RUN. Num1 Num2 Result Operator D ATA + +

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Selection-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. ACCEPT Num1. ACCEPT Num2. ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF. DISPLAY "Result is = ", Result DISPLAY "Result is = ", Result. STOP RUN. Num1 Num2 Result Operator D ATA + +

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. Iteration-Program PROGRAM-ID. Iteration-Program. AUTHOR. Team SarMag. DATA DIVISION DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. PERFORM 5 TIMES ACCEPT Num1 ACCEPT Num2 ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF DISPLAY "Result is = ", Result END-PERFORM. STOP RUN. D ATA Num1 Num2 Result Operator D ATA _ _

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Iteration-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. PERFORM 5 TIMES PERFORM 5 TIMES ACCEPT Num1 ACCEPT Num2 ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF DISPLAY "Result is = ", Result END-PERFORM END-PERFORM. STOP RUN. D ATA Num1 Num2 Result Operator D ATA _ _

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Iteration-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. PERFORM 5 TIMES ACCEPT Num1 ACCEPT Num1 ACCEPT Num2 ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF DISPLAY "Result is = ", Result END-PERFORM. STOP RUN. D ATA Num1 Num2 Result Operator D ATA _ _

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Iteration-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. PERFORM 5 TIMES ACCEPT Num1 ACCEPT Num2 ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF DISPLAY "Result is = ", Result END-PERFORM. STOP RUN. D ATA Num1 Num2 Result Operator D ATA _ _

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Iteration-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. PERFORM 5 TIMES ACCEPT Num1 ACCEPT Num2 ACCEPT Operator ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF DISPLAY "Result is = ", Result END-PERFORM. STOP RUN. D ATA Num1 Num2 Result Operator D ATA * *

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Iteration-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. PERFORM 5 TIMES ACCEPT Num1 ACCEPT Num2 ACCEPT Operator IF Operator = "+" THEN IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF DISPLAY "Result is = ", Result END-PERFORM. STOP RUN. D ATA Num1 Num2 Result Operator D ATA * *

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Iteration-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. PERFORM 5 TIMES ACCEPT Num1 ACCEPT Num2 ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF DISPLAY "Result is = ", Result END-PERFORM. STOP RUN. D ATA Num1 Num2 Result Operator D ATA * *

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Iteration-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. PERFORM 5 TIMES ACCEPT Num1 ACCEPT Num2 ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF DISPLAY "Result is = ", Result END-PERFORM. STOP RUN. D ATA Num1 Num2 Result Operator D ATA * *

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Iteration-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. PERFORM 5 TIMES ACCEPT Num1 ACCEPT Num2 ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF DISPLAY "Result is = ", Result DISPLAY "Result is = ", Result END-PERFORM. STOP RUN. D ATA Num1 Num2 Result Operator D ATA * *

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Iteration-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. PERFORM 5 TIMES ACCEPT Num1 ACCEPT Num1 ACCEPT Num2 ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF DISPLAY "Result is = ", Result END-PERFORM. STOP RUN. D ATA Num1 Num2 Result Operator D ATA * *

$ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. Iteration-Program. AUTHOR. Team SarMag. DATA DIVISION. WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Result PIC 99 VALUE ZEROS. 01 Operator PIC X VALUE SPACE. PROCEDURE DIVISION. Calculator. PERFORM 5 TIMES ACCEPT Num1 ACCEPT Num2 ACCEPT Operator IF Operator = "+" THEN ADD Num1, Num2 GIVING Result END-IF IF Operator = "*" THEN MULTIPLY Num1 BY Num2 GIVING Result END-IF DISPLAY "Result is = ", Result END-PERFORM. STOP RUN. D ATA Num1 Num2 Result Operator D ATA * *