SOEE1160: Computers and Programming in Geosciences Semester /08. Dr. Sebastian Rost

Size: px
Start display at page:

Download "SOEE1160: Computers and Programming in Geosciences Semester /08. Dr. Sebastian Rost"

Transcription

1 SOEE1160 L3-1 Structured Programming SOEE1160: Computers and Programming in Geosciences Semester /08 Dr. Sebastian Rost In a sense one could see a computer program as a recipe (this is pretty much true for any interaction with a computer). You could type your commands into the keyboard and the operating system encodes then and then passes them to the CPU and the results come back to you onto the screen. This works pretty well, but is probably not the best use of a computer. Why? Computers normally calculate much faster (at the rate of a couple of billion instructions per second (naturally depending on the speed of the computer)) than we can (I guess that is the reason why we use them). To get instructions to a computer at this speed typing won t do. We must assemble a list of instructions in advance and then get them to the computer by normally loading them into the computers memory. The CPU can then read and execute these at its own pace (which is normally pretty high). For a computer to understand the instructions they must be in a certain format or language. It is actually not necessary to write in a language that the computer understands directly since there is normally a layer between you and the CPU that actually translate your commands into something the computer understands. So, the computer program contains step-by-step instructions of what the computer should do. The computer normally works through the program from the top to the bottom, but computer programs also allow control of flow which means you can actually tell the computer to repeat part of the programs several times or to give conditions under which a part of the computer code should be run. Anything you want the computer to do has to be written in the recipe. Computers don t interpret what you might have done, they follow strictly the recipe. Normally you cannot blame the computer when things go wrong. Computer languages are lists of instructions that tell the computer what to do. As the CPU can only understand instructions written in binary code, the program passed to the CPU must be in binary code, or be executable. It is possible to write computer programs in binary code, but this is difficult and unnecessary. High Level languages have been developed, which deal with the concepts and abstractions needed for the user s problems. Typical examples of high-level languages are FORTRAN and C. So you will learn one of these during this class, which makes it easier to learn other languages as well.

2 SOEE1160 L3-2 Important parts of a Computer program A program can only instruct a computer to: Read Input Sequence Calculate Store data Compare and branch Iterate or Loop Write Output We will discuss what this means in the lecture. Pseudo-code and structure diagrams One of the first steps you should do when you write a computer program is to plan what it should do and how the structure of the code should look like. This normally makes code that is easier to read and to understand. The programmer should break down the task into simple stages. These should be expressed in pseudo-code, using normal English to express the steps required for a task Start by noting the overall tasks to be achieved then break these down into sub-tasks. The idea is to continue re-writing the instructions with the tasks resolved into smaller and smaller units until each sub-task is trivial enough to be represented by one high-level computer instruction. Later on we will see that good design at this stage gets carried through into the subprogram structure of the finished code, making it clear and easy to maintain. If you start your own code this is very good practice, together with documenting the code well through comments and using indentations to make the flow of the program clear. For example, let s assume the task to be carried out is to make some sandwiches. We might decide the steps are: 1. Get the ingredients out 2. Make the sandwiches 3. Tidy up Breaking each step down into smaller parts gives: 1.1 Get the bread out 1.2 Get the jam out 1.3 Get the butter out 2.1 Slice the bread 2.2 Put the butter and jam on

3 SOEE1160 L Cut the bread in half and put the halves together Put in the sandwich box Tidy up Note how the numbering indicates the subdivisions. In real applications, sections on the instructions may need to be repeated many times (e.g. when you want to make more than one slice). We can represent this using For each end of in our pseudo-code. 1.1 Get the bread out 1.2 Get the jam out 1.3 Get the butter out 2.1 For each slice of bread Slice the bread Put the butter and jam on Cut the bread in half and put the halves together Put in the sandwich box end of this slice 3. Tidy up. Some instructions may need to be executed only if a certain condition is true. We can represent this using if end of if in our pseudo-code. We can include or else to specify what actions should happen if the condition is not true. 1.1 if the bread-bin is empty go to the shop and buy another loaf or else Get the bread out end of if 1.2 Get the jam out. Logic Flowcharts Another way to represent the logic within a computer program is to use structure diagrams or flow charts. In these, different symbols show the parts of the computer program and flow lines connecting the different parts. To make things in the flow charts more obvious one uses special forms in the graphical display. A list of these symbols is given below. There are three ways a task can be broken down, into a sequence of sub-tasks, where the boxes drawn below are all executed in order; conditionals are represented as diamonds,

4 SOEE1160 L3-4 and repetitions are normally based on some kind of conditional and then a loop back towards the start. Processing steps are shown as boxes and input output parts are shown as trapezes. This way the logic of a program is very easy to understand and the different processing steps are obvious. Not all of the symbols actually have to appear within a computer program. The minimum number of steps in any useful program are probably 3: an input, a processing stage and an output stage. Below is an example of how a logic flowchart for a cash register would look like. Common Flowchart Terminator. Shows the starting and ending points of the program. A terminator has flowlines in only one direction, either in (a stop node) or out (a start node). Data Input or Output. Allows the user to inputdata and results to be displayed. Processing. Indicates an operation performed by the computer, such as a variable assignment or mathematical operation. Decision. The diamond indicates a decision structure. A diamond always has two flowlines out. One flowlineout is labeled the yes branch and the other is labeled the no branch. Predefined Process. One statement denotes a group of previously defined statements. For instance, Calculate m! indicates that the program executes the necessary commands to compute m factorial. Connector. Connectors avoid crossing flowlines, making the flowchart easier to read. Connectors indicate where flowlines are connected. Connectors come in pairs, one with a flowline in and the other with a flowline out. Off-page connector. Even fairly small programs can have flowcharts that extend several pages. The off-page connector indicates the continuation of the flowchart on another page. Just like connectors, off-page connectors come in pairs. Flowline. Flowlines connect the flowchart symbols and show the sequence of operations during the program execution.

5 SOEE1160 L3-5 Start sum=0 Input price sum=sum+price Yes More items? No tax=sum x total=sum+tax Output sum, tax, and total Stop Introducing Fortran Fortran was the first widely used high-level language. Originally designed in the early 1950 s for scientific and engineering applications, Fortran stands for Formula Translation. The intention was that mathematical expressions could be coded in more or less the same was as they would be written. There is a very large base of Fortran code, with a large number of programmers and users, mostly in the fields of science and engineering. This ensures that, although new versions of Fortran are being introduced, they retain the ability to compile older Fortran codes without modification. Many codes in the geosciences are written in an older standard called Fortran 77. That s the reason why we will learn Fortran by the Fortran 77 standard. The American National Standards Institute (ANSI) produced the first standardized version in 1966 (FORTRAN 66) later replaced by FORTRAN 77. Modern versions are Fortran 90, Fortran 95, Fortran 2000, Fortran 2003 and the new standard of Fortran 2008 is looming at the horizon. Some of these newer standards actually saw only rather minor changes, especially in the areas of interest here (i.e. the level of coding you will do here), but the jump from 77 to 90/95 was actually pretty major and if you start a new piece of larger code you might want to think of using Fortran 90/95. Fortran was designed to be input via punchcards, one for each statement or line of data. Shown below is one of the punchcards of a Fortran code (

6 SOEE1160 L3-6 Each card had 80 positions available for punching. This led to Fortran 77 fixed-format source-code, with particular columns assigned to particular uses, and to conventional data layout using 80-character long records. The table below shows what can be written in each column of a Fortran program. Some editors (e.g. emacs) actually notice when you are writing in Fortran and put in the right tabs for this format. Column Content Comment 1 C or * With a C or * the line is marked as a commentary line. You can put any text in here 1-5 Number between 1 and Statement labels 6 Empty This is the normal case 6 + or & 7 to 72 Fortran Code 73 to 80 This continues a line, i.e. you can write additional content into the next file and it will be read together with the first line Fortrans are to be written in columns 7 through 72. No need to left justify the commands These lines will not be used by FORTRAN Newer standards starting with Fortran 90 did get rid of the fixed-format since punch cards are no longer. But as mentioned before the modern compilers (more about that in a

7 SOEE1160 L3-7 minute) understand the legacy format of Fortran 77 and won t shout at you for using the older format. How can you write something in Fortran? The Fortran character set consists of: Letters A-Z (uppercase and lowercase, but not case sensitive) Decimal digits 0-9 Arithmetic operators + - * / and = Brackets () Comma and Period,. Colon : Apostrophe Currency symbol $ Blank (Space) So you actually don t have too many characters available. Fortran is not case sensitive, so a command WRITE is the same as write. Using upper case and lower case characters might help with the readability (for a human) of the code. Spaces are actually again a very important part of the code since they clarify the structure of the code and they are needed to separate things. More about this in the next lecture. We call the Fotran program you are writing the source code or simply the code. The source code is written in ASCII in an editor of your choice. So how is the computer actually able to understand what you wrote in the source code and to execute the recipe you wrote? Directly the computer does not understand a thing you wrote in that file. It is simply an ASCII file written in a specific format. You have to compile the code for it to be useful to the computer. The compiler then translates the code into binary that can be understood and executed by the CPU. Compiling is very different from what you did to your C-shell script with the chmod command. There, you only told the operating system that the file is executable. The shell then translated the commands you wrote in the C-shell script to binary code on the fly. So there is no compilation step involved. It is simply a translating stage. Things are different for Fortran code which needs to be compiled. The compiled binary of a Fortran program actually lives in its own file. This file is written in binary, which can be understood by the computer, but no longer by a human. There are several Fortran compilers out there. They more or less follow the published Fortran standards, but each one has its own little interpretation of these standards. So code that compiles well with one compiler might have to be changed a little when you

8 SOEE1160 L3-8 use another compiler. A common compiler for Fortran under Linux is gfortran which is the fortran compiler from the GNU initiative. How to compile a code in the EFC Lab? To compile a code in the EFC lab please use the g77 which is the gfortran compiler for Fortran 77. Fortran code should have the extension.f, e.g. hello.f. That way it is clear that the content is a Fortran code and the editor has a chance to actually fit the right format to the file (when you are using emacs). Some editors actually use syntax color coding that might show which part is a variable, a command, etc. Again more about this later. Syntax for the Fortran compiler: g77 input.f If you do this, the executable binary will be a file called a.out. This is the default output file of g77. If you compile another Fortran code, this executable will be overwritten. So this is probably not desirable. Therefore there is a way tom define an output file: g77 o output input.f Now your binary lands in the file output. You can now run this file. There is no need for an extension for these files (so no.exe or something is necessary, the shell checks if things are executable by looking at the rwx fields).

Week - 01 Lecture - 04 Downloading and installing Python

Week - 01 Lecture - 04 Downloading and installing Python Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 01 Lecture - 04 Downloading and

More information

Programming with Python

Programming with Python Programming with Python Dr Ben Dudson Department of Physics, University of York 21st January 2011 http://www-users.york.ac.uk/ bd512/teaching.shtml Dr Ben Dudson Introduction to Programming - Lecture 2

More information

AMath 483/583 Lecture 7. Notes: Notes: Changes in uwhpsc repository. AMath 483/583 Lecture 7. Notes:

AMath 483/583 Lecture 7. Notes: Notes: Changes in uwhpsc repository. AMath 483/583 Lecture 7. Notes: AMath 483/583 Lecture 7 This lecture: Python debugging demo Compiled langauges Introduction to Fortran 90 syntax Declaring variables, loops, booleans Reading: class notes: Python debugging class notes:

More information

AMath 483/583 Lecture 7

AMath 483/583 Lecture 7 AMath 483/583 Lecture 7 This lecture: Python debugging demo Compiled langauges Introduction to Fortran 90 syntax Declaring variables, loops, booleans Reading: class notes: Python debugging class notes:

More information

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1 Chapter 2 Input, Processing, and Output Fall 2016, CSUS Designing a Program Chapter 2.1 1 Algorithms They are the logic on how to do something how to compute the value of Pi how to delete a file how to

More information

Stating the obvious, people and computers do not speak the same language.

Stating the obvious, people and computers do not speak the same language. 3.4 SYSTEM SOFTWARE 3.4.3 TRANSLATION SOFTWARE INTRODUCTION Stating the obvious, people and computers do not speak the same language. People have to write programs in order to instruct a computer what

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

Computers and FORTRAN Language Fortran 95/2003. Dr. Isaac Gang Tuesday March 1, 2011 Lecture 3 notes. Topics:

Computers and FORTRAN Language Fortran 95/2003. Dr. Isaac Gang Tuesday March 1, 2011 Lecture 3 notes. Topics: Computers and FORTRAN Language Fortran 95/2003 Dr. Isaac Gang Tuesday March 1, 2011 Lecture 3 notes Topics: - Program Design - Logical Operators - Logical Variables - Control Statements Any FORTRAN program

More information

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007 CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007 Course Web Site http://www.nps.navy.mil/cs/facultypages/squire/cs2900 All course related materials will be posted

More information

Introduction Objectives: 1) differentiate between high-level, low-level, and machine language; 2) explain why it is necessary to translate a program

Introduction Objectives: 1) differentiate between high-level, low-level, and machine language; 2) explain why it is necessary to translate a program Introduction Objectives: 1) differentiate between high-level, low-level, and machine language; 2) explain why it is necessary to translate a program written in a high-level programming language into machine

More information

Review. Input, Processing and Output. Review. Review. Designing a Program. Typical Software Development cycle. Bonita Sharif

Review. Input, Processing and Output. Review. Review. Designing a Program. Typical Software Development cycle. Bonita Sharif Input, Processing and Output Bonita Sharif 1 Review A program is a set of instructions a computer follows to perform a task The CPU is responsible for running and executing programs A set of instructions

More information

Pseudo Code and Flow Charts. Chapter 1 Lesson 2

Pseudo Code and Flow Charts. Chapter 1 Lesson 2 Pseudo Code and Flow Charts Chapter 1 Lesson 2 Pseudocode Using Pseudocode Statements and Flowchart Symbols English-like representation of the logical steps it takes to solve a problem Flowchart Pictorial

More information

MAS115: R programming Lecture 2: Pseudocode Lab Class and Technical Material: Matrices, Factors, Data frames, Lists

MAS115: R programming Lecture 2: Pseudocode Lab Class and Technical Material: Matrices, Factors, Data frames, Lists MAS115: R programming Lecture 2: Pseudocode Lab Class and Technical Material: Matrices, Factors, Data frames, Lists The University of Sheffield School of Mathematics and Statistics Problems Class Aims

More information

2 A little on Spreadsheets

2 A little on Spreadsheets 2 A little on Spreadsheets Spreadsheets are computer versions of an accounts ledger. They are used frequently in business, but have wider uses. In particular they are often used to manipulate experimental

More information

National 5 Computing Science Software Design & Development

National 5 Computing Science Software Design & Development National 5 Computing Science Software Design & Development 1 Stages of Development 2 Analysis 3 Design 4 Implementation 5 Testing 6 Documentation 7 Evaluation 8 Maintenance 9 Data Types & Structures 10

More information

1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d.

1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d. Gaddis: Starting Out with Python, 2e - Test Bank Chapter Two MULTIPLE CHOICE 1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical

More information

Introduction to Programming: Variables and Objects. HORT Lecture 7 Instructor: Kranthi Varala

Introduction to Programming: Variables and Objects. HORT Lecture 7 Instructor: Kranthi Varala Introduction to Programming: Variables and Objects HORT 59000 Lecture 7 Instructor: Kranthi Varala What is a program? A set of instructions to the computer that perform a specified task in a specified

More information

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA 1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

Flow Control: Branches and loops

Flow Control: Branches and loops Flow Control: Branches and loops In this context flow control refers to controlling the flow of the execution of your program that is, which instructions will get carried out and in what order. In the

More information

Week One: Introduction A SHORT INTRODUCTION TO HARDWARE, SOFTWARE, AND ALGORITHM DEVELOPMENT

Week One: Introduction A SHORT INTRODUCTION TO HARDWARE, SOFTWARE, AND ALGORITHM DEVELOPMENT Week One: Introduction A SHORT INTRODUCTION TO HARDWARE, SOFTWARE, AND ALGORITHM DEVELOPMENT Outline In this chapter you will learn: About computer hardware, software and programming How to write and execute

More information

Introduction to Programming Style

Introduction to Programming Style Introduction to Programming Style Thaddeus Aid The IT Learning Programme The University of Oxford, UK 30 July, 2013 Abstract Programming style is the part of the program that the human reads and the compiler

More information

How to approach a computational problem

How to approach a computational problem How to approach a computational problem A lot of people find computer programming difficult, especially when they first get started with it. Sometimes the problems are problems specifically related to

More information

ENT 189: COMPUTER PROGRAMMING. H/P: Home page:

ENT 189: COMPUTER PROGRAMMING.   H/P: Home page: ENT 189: COMPUTER PROGRAMMING Dr. PAULRAJ M P, Associate Professor, School of Mechatronic Engineering, #42- Level 2, Ulu Pauh New Campus 02600-Arau. PERLIS Email: paul@unimap.edu.my H/P: 017 5103757 Home

More information

Week 1 Introduction to Programming

Week 1 Introduction to Programming CME111 Programming Languages I Week 1 Introduction to Programming Assist. Prof. Dr. Caner ÖZCAN Introduction Course Web Site: www.canerozcan.net Office Hours: Tuesday 13:00-15:00 Wednesday 15:30-17:00

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Introduction. Arizona State University 1

Introduction. Arizona State University 1 Introduction CSE100 Principles of Programming with C++, Fall 2018 (based off Chapter 1 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

Welcome to Python! If you re the type of person who wants to know

Welcome to Python! If you re the type of person who wants to know In This Chapter The history of Python What people use Python for Chapter 1 Introducing Python Useful concepts for Python programming Welcome to Python! If you re the type of person who wants to know what

More information

CSC 101: Lab Manual#9 Machine Language and the CPU (largely based on the work of Prof. William Turkett) Lab due date: 5:00pm, day after lab session

CSC 101: Lab Manual#9 Machine Language and the CPU (largely based on the work of Prof. William Turkett) Lab due date: 5:00pm, day after lab session CSC 101: Lab Manual#9 Machine Language and the CPU (largely based on the work of Prof. William Turkett) Lab due date: 5:00pm, day after lab session Purpose: The purpose of this lab is to gain additional

More information

Identifiers. Identifiers are the words a programmer uses in a program Some identifiers are already defined. Some are made up by the programmer:

Identifiers. Identifiers are the words a programmer uses in a program Some identifiers are already defined. Some are made up by the programmer: C1 D6 Obj: cont. 1.3 and 1.4, to become familiar with identifiers and to understand how programming languages work HW: p.51 #1.8 1.9 (Short Answers) Chapter 1 Test in two class days!! Do Now: How is the

More information

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming Topics C H A P T E R 1 Introduction to Computers and Programming Introduction Hardware and Software How Computers Store Data Using Python Introduction Computers can be programmed Designed to do any job

More information

Introduction to computers and Python. Matthieu Choplin

Introduction to computers and Python. Matthieu Choplin Introduction to computers and Python Matthieu Choplin matthieu.choplin@city.ac.uk http://moodle.city.ac.uk/ 1 Objectives To get a brief overview of what Python is To understand computer basics and programs

More information

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department Program Development Cycle Program development

More information

FLOW CHART AND PSEUDO CODE

FLOW CHART AND PSEUDO CODE FLOW CHART AND PSEUDO CODE Flowchart A Flowchart is a pictorial representation of an algorithm. The First flowchart is made by John Von Newman in 1945. It is a symbolic diagram of operation sequence, dataflow,

More information

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0 VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 L J Howell UX Software 2009 Ver. 1.0 TABLE OF CONTENTS INTRODUCTION...ii What is this book about?... iii How to use this book... iii

More information

Python: Functions. Thomas Schwarz, SJ Marquette University

Python: Functions. Thomas Schwarz, SJ Marquette University Python: Functions Thomas Schwarz, SJ Marquette University History Early computer programming was difficult Not only because interacting with the computer was difficult Data was entered by setting switches,

More information

C Language, Token, Keywords, Constant, variable

C Language, Token, Keywords, Constant, variable C Language, Token, Keywords, Constant, variable A language written by Brian Kernighan and Dennis Ritchie. This was to be the language that UNIX was written in to become the first "portable" language. C

More information

SNS COLLEGE OF ENGINEERING,

SNS COLLEGE OF ENGINEERING, SNS COLLEGE OF ENGINEERING, COIMBATORE Department of Computer Science and Engineering QUESTION BANK(PART A) GE8151 - PROBLEM SOLVING AND PYTHON PROGRAMMING TWO MARKS UNIT-I 1. What is computer? Computers

More information

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture - 04 Introduction to Programming Language Concepts

More information

Outline. Program development cycle. Algorithms development and representation. Examples.

Outline. Program development cycle. Algorithms development and representation. Examples. Outline Program development cycle. Algorithms development and representation. Examples. 1 Program Development Cycle Program development cycle steps: Problem definition. Problem analysis (understanding).

More information

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming) Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming) Learning any imperative programming language involves mastering a number of common concepts: Variables: declaration/definition

More information

INTRODUCTION 1 AND REVIEW

INTRODUCTION 1 AND REVIEW INTRODUTION 1 AND REVIEW hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Programming: Advanced Objectives You will learn: Program structure. Program statements. Datatypes. Pointers. Arrays. Structures.

More information

A quick guide to Fortran

A quick guide to Fortran A quick guide to Fortran Sergiy Bubin Department of Physics Nazarbayev University History of Fortran One of the oldest general purpose high-level computer languages First developed in 1957 at IBM in the

More information

printf( Please enter another number: ); scanf( %d, &num2);

printf( Please enter another number: ); scanf( %d, &num2); CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful

More information

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners Getting Started Excerpted from Hello World! Computer Programming for Kids and Other Beginners EARLY ACCESS EDITION Warren D. Sande and Carter Sande MEAP Release: May 2008 Softbound print: November 2008

More information

5 The Control Structure Diagram (CSD)

5 The Control Structure Diagram (CSD) 5 The Control Structure Diagram (CSD) The Control Structure Diagram (CSD) is an algorithmic level diagram intended to improve the comprehensibility of source code by clearly depicting control constructs,

More information

CMSC 201 Computer Science I for Majors

CMSC 201 Computer Science I for Majors CMSC 201 Computer Science I for Majors Lecture 02 Intro to Python Syllabus Last Class We Covered Grading scheme Academic Integrity Policy (Collaboration Policy) Getting Help Office hours Programming Mindset

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

Chapter 2 Basic Elements of C++

Chapter 2 Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion

More information

Why Study Assembly Language?

Why Study Assembly Language? Why Study Assembly Language? This depends on the decade in which you studied assembly language. 1940 s You cannot study assembly language. It does not exist yet. 1950 s You study assembly language because,

More information

Memory Addressing, Binary, and Hexadecimal Review

Memory Addressing, Binary, and Hexadecimal Review C++ By A EXAMPLE Memory Addressing, Binary, and Hexadecimal Review You do not have to understand the concepts in this appendix to become well-versed in C++. You can master C++, however, only if you spend

More information

C++ Programming Language Lecture 1 Introduction

C++ Programming Language Lecture 1 Introduction C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department Introduction In this course you will learn C++ and the legacy C code. It is

More information

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 02: Algorithms Readings: Not Covered in Textbook Problem Solving Process System Design:

More information

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG) SKILL AREA 304: Review Programming Language Concept Computer Programming (YPG) 304.1 Demonstrate an Understanding of Basic of Programming Language 304.1.1 Explain the purpose of computer program 304.1.2

More information

Chapter 1: An Overview of Computers and Logic

Chapter 1: An Overview of Computers and Logic Chapter 1: An Overview of Computers and Logic Programming Logic and Design, Third Edition Comprehensive Objectives After studying Chapter 1, you should be able to: Understand computer components and operations

More information

Programming Fundamentals

Programming Fundamentals Programming Fundamentals Computers are really very dumb machines -- they only do what they are told to do. Most computers perform their operations on a very primitive level. The basic operations of a computer

More information

St. Benedict s High School. Computing Science. Software Design & Development. (Part 2 Computer Architecture) National 5

St. Benedict s High School. Computing Science. Software Design & Development. (Part 2 Computer Architecture) National 5 Computing Science Software Design & Development (Part 2 Computer Architecture) National 5 DATA REPRESENTATION Numbers Binary/Decimal Conversion Example To convert 69 into binary: write down the binary

More information

An Introduction to Python (TEJ3M & TEJ4M)

An Introduction to Python (TEJ3M & TEJ4M) An Introduction to Python (TEJ3M & TEJ4M) What is a Programming Language? A high-level language is a programming language that enables a programmer to write programs that are more or less independent of

More information

COMP 102: Computers and Computing

COMP 102: Computers and Computing COMP 102: Computers and Computing Lecture 5: What is Programming? Instructor: Kaleem Siddiqi (siddiqi@cim.mcgill.ca) Class web page: www.cim.mcgill.ca/~siddiqi/102.html Motivation The advantage of a computer

More information

2. Numbers In, Numbers Out

2. Numbers In, Numbers Out COMP1917: Computing 1 2. Numbers In, Numbers Out Reading: Moffat, Chapter 2. COMP1917 15s2 2. Numbers In, Numbers Out 1 The Art of Programming Think about the problem Write down a proposed solution Break

More information

Week - 03 Lecture - 18 Recursion. For the last lecture of this week, we will look at recursive functions. (Refer Slide Time: 00:05)

Week - 03 Lecture - 18 Recursion. For the last lecture of this week, we will look at recursive functions. (Refer Slide Time: 00:05) Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 03 Lecture - 18 Recursion For the

More information

Perl Basics. Structure, Style, and Documentation

Perl Basics. Structure, Style, and Documentation Perl Basics Structure, Style, and Documentation Copyright 2006 2009 Stewart Weiss Easy to read programs Your job as a programmer is to create programs that are: easy to read easy to understand, easy to

More information

Computers and Computation. The Modern Computer. The Operating System. The Operating System

Computers and Computation. The Modern Computer. The Operating System. The Operating System The Modern Computer Computers and Computation What is a computer? A machine that manipulates data according to instructions. Despite their apparent complexity, at the lowest level computers perform simple

More information

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017 Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls

More information

GCSE Computer Science Component 02

GCSE Computer Science Component 02 GCSE Computer Science Component 02 Revision Computational Thinking ABSTRACTION Making a problem simpler by removing unnecessary details. This is important when coding as it: Makes it easier to code! Means

More information

Chapter 17. Fundamental Concepts Expressed in JavaScript

Chapter 17. Fundamental Concepts Expressed in JavaScript Chapter 17 Fundamental Concepts Expressed in JavaScript Learning Objectives Tell the difference between name, value, and variable List three basic data types and the rules for specifying them in a program

More information

Chapter 1 Operations With Numbers

Chapter 1 Operations With Numbers Chapter 1 Operations With Numbers Part I Negative Numbers You may already know what negative numbers are, but even if you don t, then you have probably seen them several times over the past few days. If

More information

If you have more in-depth questions after the presentation please feel free to contact me at the e- address below.

If you have more in-depth questions after the presentation please feel free to contact me at the e- address below. Thank you for your interest in this topic. I hope to provide you with a 50 minute informative and interesting presentation and at the end of the presentation we will have a Q&A period. If you have more

More information

This is the basis for the programming concept called a loop statement

This is the basis for the programming concept called a loop statement Chapter 4 Think back to any very difficult quantitative problem that you had to solve in some science class How long did it take? How many times did you solve it? What if you had millions of data points

More information

Control Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur

Control Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur Control Structures Code can be purely arithmetic assignments At some point we will need some kind of control or decision making process to occur C uses the if keyword as part of it s control structure

More information

Chapter 1 INTRODUCTION TO COMPUTER AND PROGRAMMING

Chapter 1 INTRODUCTION TO COMPUTER AND PROGRAMMING Chapter 1 INTRODUCTION TO COMPUTER AND PROGRAMMING Computer programming BTI 10202 Compiled by SIA CHEE KIONG DEPARTMENT OF MATERIAL AND DESIGN ENGINEERING FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING

More information

Section 1. The essence of COBOL programming. Mike Murach & Associates

Section 1. The essence of COBOL programming. Mike Murach & Associates Chapter 1 Introduction to COBOL programming 1 Section 1 The essence of COBOL programming The best way to learn COBOL programming is to start doing it, and that s the approach the chapters in this section

More information

Game keystrokes or Calculates how fast and moves a cartoon Joystick movements how far to move a cartoon figure on screen figure on screen

Game keystrokes or Calculates how fast and moves a cartoon Joystick movements how far to move a cartoon figure on screen figure on screen Computer Programming Computers can t do anything without being told what to do. To make the computer do something useful, you must give it instructions. You can give a computer instructions in two ways:

More information

Working with JavaScript

Working with JavaScript Working with JavaScript Creating a Programmable Web Page for North Pole Novelties 1 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page 2 Objectives

More information

CMSC 201 Fall 2018 Python Coding Standards

CMSC 201 Fall 2018 Python Coding Standards CMSC 201 Fall 2018 Python Coding Standards The purpose of these coding standards is to make programs readable and maintainable. In the real world you may need to update your own code more than 6 months

More information

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture 18 Switch Statement (Contd.) And Introduction to

More information

Numerical Methods in Scientific Computation

Numerical Methods in Scientific Computation Numerical Methods in Scientific Computation Programming and Software Introduction to error analysis 1 Packages vs. Programming Packages MATLAB Excel Mathematica Maple Packages do the work for you Most

More information

Students received individual feedback throughout year on assignments.

Students received individual feedback throughout year on assignments. ACS108 No exam. Students received individual feedback throughout year on assignments. ACS123 In general, during ACS123 exam session, students have shown satisfactory performance, clear understanding of

More information

1. Lexical Analysis Phase

1. Lexical Analysis Phase 1. Lexical Analysis Phase The purpose of the lexical analyzer is to read the source program, one character at time, and to translate it into a sequence of primitive units called tokens. Keywords, identifiers,

More information

CS 201 Problem Solving with Computers

CS 201 Problem Solving with Computers Welcome to CS 201 Problem Solving with Computers Dr., Dept. of Computer Science Welcome Lectures on Mondays & Wednesdays Labs on Tuesdays & Thursdays Course website at http://www2.cs.siu.edu/~wainer/201f11/cs201f11outline.html

More information

بسم اهلل الرمحن الرحيم

بسم اهلل الرمحن الرحيم بسم اهلل الرمحن الرحيم Fundamentals of Programming C Session # 3 By: Saeed Haratian Spring 2016 Outlines Equality and Relational Operators A Simple C Program: Relations Keywords Algorithm Flow Chart Pseudo

More information

DEVS306 Tables & Graphs. Rasa Zakeviciute

DEVS306 Tables & Graphs. Rasa Zakeviciute DEVS306 Tables & Graphs Rasa Zakeviciute rasa.zakeviciute@jyu.fi Creating tables & graphs Year Your salary, yearly 2020 30 000 2021 40 000 2022 50 000 2023 60 000 Inflation rate, annual % 3% 1% 15% 20%

More information

Chapter 2 Author Notes

Chapter 2 Author Notes Chapter 2 Author Notes Good Programming Practice 2.1 Every program should begin with a comment that explains the purpose of the program, the author and the date and time the program was last modified.

More information

Higher Computing Science Software Design and Development - Programming Summary Notes

Higher Computing Science Software Design and Development - Programming Summary Notes Higher Computing Science Software Design and Development - Programming Summary Notes Design notations A design notation is the method we use to write down our program design. Pseudocode is written using

More information

Module 1: Introduction RStudio

Module 1: Introduction RStudio Module 1: Introduction RStudio Contents Page(s) Installing R and RStudio Software for Social Network Analysis 1-2 Introduction to R Language/ Syntax 3 Welcome to RStudio 4-14 A. The 4 Panes 5 B. Calculator

More information

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications Hello World! Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande Chapter 1 Copyright 2009 Manning Publications brief contents Preface xiii Acknowledgments xix About this

More information

Business Data Analysis MA0123. Dr Gavin Shaddick Department of Mathematical Sciences 4W 5.7

Business Data Analysis MA0123. Dr Gavin Shaddick Department of Mathematical Sciences 4W 5.7 Business Data Analysis MA0123 Dr Gavin Shaddick Department of Mathematical Sciences g.shaddick@bath.ac.uk 4W 5.7 Lectures and computer labs Two lectures a week (Monday and Friday). One computing lab (time

More information

Steps to program development

Steps to program development Automate processes - Programming Concepts and Design Steps to program development A computer program is a set of formal instructions, which the computer executes in order to carry out some designated task.

More information

Visual Basic Course Pack

Visual Basic Course Pack Santa Monica College Computer Science 3 Visual Basic Course Pack Introduction VB.NET, short for Visual Basic.NET is a language that was first introduced by Microsoft in 1987. It has gone through many changes

More information

CITS2401 Computer Analysis & Visualisation

CITS2401 Computer Analysis & Visualisation FACULTY OF ENGINEERING, COMPUTING AND MATHEMATICS CITS2401 Computer Analysis & Visualisation SCHOOL OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING Topic 3 Introduction to Matlab Material from MATLAB for

More information

Python Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018

Python Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018 Python Input, output and variables Lecture 23 COMPSCI111/111G SS 2018 1 Today s lecture What is Python? Displaying text on screen using print() Variables Numbers and basic arithmetic Getting input from

More information

And Parallelism. Parallelism in Prolog. OR Parallelism

And Parallelism. Parallelism in Prolog. OR Parallelism Parallelism in Prolog And Parallelism One reason that Prolog is of interest to computer scientists is that its search mechanism lends itself to parallel evaluation. In fact, it supports two different kinds

More information

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: Bits and Bytes and Numbers Number Systems Much of this is review, given the 221 prerequisite Question: how high can

More information

Civil Engineering Computation

Civil Engineering Computation Civil Engineering Computation First Steps in VBA Homework Evaluation 2 1 Homework Evaluation 3 Based on this rubric, you may resubmit Homework 1 and Homework 2 (along with today s homework) by next Monday

More information

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5.

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5. Page 1 of 5 6.170 Laboratory in Software Engineering Java Style Guide Contents: Overview Descriptive names Consistent indentation and spacing Informative comments Commenting code TODO comments 6.170 Javadocs

More information

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed

More information

Method & Tools for Program Analysis & Design

Method & Tools for Program Analysis & Design Method & Tools for Program Analysis & Design TMB208 Pemrograman Teknik Kredit: 3 (2-3) 1 Programming Logic and Design, Introductory, Fourth Edition 2 1 Programming Methods Based on structures of programming

More information

Engineering Computing M1H Together Towards A Green Environment

Engineering Computing M1H Together Towards A Green Environment Engineering Computing M1H321538 Module Induction Course Resources Lecture/Tutorial hours Course Syllabus Assessment Procedure Expectation from the Students General Terms and Conditions Course Resources

More information

Computer Organization and Assembly Language. Lab Session 3

Computer Organization and Assembly Language. Lab Session 3 Lab Session 3 Objective: To be familiar with Basic Elements of Assembly Language Understanding Constants, Identifiers, Directives and Instructions. Theory: Integer Constants An integer constant (or integer

More information

ENGR 105: Introduction to Scientific Computing. Dr. Graham. E. Wabiszewski

ENGR 105: Introduction to Scientific Computing. Dr. Graham. E. Wabiszewski ENGR 105: Introduction to Scientific Computing Variable and Function Naming Conventions, Accessing Vector Elements, Precedence, Iteration, Relational Operators Dr. Graham. E. Wabiszewski ENGR 105 Lecture

More information

(Refer Slide Time: 01:12)

(Refer Slide Time: 01:12) Internet Technology Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No #22 PERL Part II We continue with our discussion on the Perl

More information