Cmpt 102 introduction to scientific computer programming
This presentation is the property of its rightful owner.
Sponsored Links
1 / 68

CMPT 102 Introduction to Scientific Computer Programming PowerPoint PPT Presentation


  • 116 Views
  • Uploaded on
  • Presentation posted in: General

CMPT 102 Introduction to Scientific Computer Programming. Course Organization. CMPT 102: Introduction to Scientific Computer Programming. Monday, Wednesday, Friday 9:30-10:20 Textbook: C Program Design for Engineers Authors: Jeri R. Hanly, Elliot B. Koffman Additional References:

Download Presentation

CMPT 102 Introduction to Scientific Computer Programming

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Cmpt 102 introduction to scientific computer programming

CMPT 102Introduction to Scientific Computer Programming

Course Organization


Cmpt 102 introduction to scientific computer programming1

CMPT 102: Introduction to Scientific Computer Programming

  • Monday, Wednesday, Friday 9:30-10:20

  • Textbook:

    • C Program Design for Engineers

      Authors: Jeri R. Hanly, Elliot B. Koffman

  • Additional References:

    • Engineering Problem Solving with C, 3rd edition

      Author: Delores M. Etter

    • The C Programming Language

      Authors: B. W. Kernighan, D. M. Ritchie


Class web site

Class web-site

  • All the information discussed today and more can always be found on the class web-site

  • To find the class web site go to http://www.cs.sfu.ca/CourseCentral

    • Select Course Home pages

    • Select the Homepage for CMPT 102

  • Course Central is also a useful link to abundant information useful to students taking a computing science course


Http www cs sfu ca coursecentral

http://www.cs.sfu.ca/CourseCentral


Course selection page

Course selection page

Click here to go to CMPT102 website


Cmpt 102 website

CMPT 102 Website


My availability

My availability


Exams dates course evaluation

Exams Dates, Course Evaluation


Exams and evaluation

Exams and Evaluation


Evaluation

Evaluation

  • Assignments: 30%

  • Weekly Quizzes: 15%

    • No quiz in week of midterm, week of Thanksgiving or week of Remembrance day

  • Lab Problems: 5%

  • Practice Problems: no credit

  • Midterm Examination: 15%

  • Final Examination: 35%


Assignments

Assignments

  • Four assignments

    • Each assignment worth 7.5% of your course grade

    • Assignments are to be completed individually

    • Problems similar to the assignments will appear on the midterm and the final.

    • Help is available during weekly lab hours

    • Complete solutions will be posted


Lab problems

Lab Problems

  • Four short lab problems

  • Each lab problem is worth 1.25% of your final grade

  • Practice Problems: no credit BUT valuable experience that will be useful when completing lab problems and assignments

    • There are no Labs in the first week of classes (Sept. 5-8)

    • Lab hours are not held on statutory holidays (Thanksgiving and Remembrance Day)

  • Weekly Quizzes: 15%

    • One question on material covered in labs Monday-Tuesday of the same week

    • Each quiz marked out of 17, worth 1.7% of the final grade

    • All quiz results will be included in your final grade

  • Midterm: 15%

  • Final: 35%


Quizzes

Quizzes

  • During each Wednesday’s lecture, you will be asked to answer one question based on material covered in the lab exercises that week.

  • You will be asked to write a short concise paragraph of 10-15 sentences, explaining a concept or method, or a short piece of code.

  • You will be given 10-15 minutes to answer.

  • Your answer will be graded out of 17 (each quiz is worth 1.7% of your final grade)


Midterm and final

Midterm and Final

  • One 50 minute in class midterm

  • One 3 hour final examination

  • 35% short answer problems

  • 65% longer problems that utilize several important concepts and require integration of those concepts.

  • A sample exam, including solutions, will be posted two weeks before the midterm and two weeks before the final exam


Assignments labs solutions

Assignments, Labs, Solutions


Important dates

Important Dates


Assignments1

Assignments

  • At least two weeks before the due date the assignment will be posted on the website

    • Assignments must be completed individually

    • Assignments will require you to combine and use many concepts and tools you have learned

    • Assignments will be much more demanding than lab problems or practice problems

    • Complete solutions to all assignments will be posted

    • Information of proper preparation of assignments and lab problems is available on the class website.


Cmpt 102 introduction to scientific computer programming

Labs

  • On or before Friday of each week problems will be posted for the next week. These problems will be identified as

    • Lab Problems: To be completed individually or in a small group (up to four students)

      • Submitted for grading

    • Practice Problems: A chance to use a new idea in a simple application, before you need to integrate multiple ideas into assignments.

      • Collaboration is encouraged

      • Not submitted for grading

    • Complete solutions to all problems will be posted


Grading information

Grading Information

  • Assignments and Lab Problems should be:

    • submitted electronically using the submission server

    • submitted in hard copy to the 102 drop box

  • Bonus points (10%) are available for submitting assignments more than 72 hours early

  • No late assignments or lab problems will be accepted

  • Unofficial grades will be available on GradeBook

    • Login: your SFU computer ID, your student number as password. Find link on Course Central


Where to submit assignments 1

Where to submit assignments: 1


Where to submit assignments 2

Where to submit assignments: 2

Submission drop boxes


Required readings notes

Required Readings, Notes


Readings and notes

Readings and Notes


Academic honesty

Academic Honesty


Academic honesty1

Academic Honesty

Read the policy


Getting started

Getting Started

  • If you have not already done so activate your SFU computing account (CCN, Campus Computing Network account.)

    • Use your own machine at home, or go to the assignment lab (AQ 3145)

    • Email regarding the class will be sent to your Campus Account, so check it regularly

    • Steps to activate your account …


Activating your ccn account 1

Activating your CCN account (1)

Select mySFU


Activating your ccn account 2

Activating your CCN Account (2)

Select Apply for ID, the follow the instructions.

You will need your student ID and your TeleReg PIN


Computing science instructional labs csil

Computing Science Instructional Labs (CSIL)

  • The CSIL LINUX lab is available for your use at all times beginning in the second week of classes. (ASB 9838)

  • At particular times the instructor and/or TA will be available in the lab to answer your questions.

    • Instructor: Mon. 1:30-3:00 PM,

      Tue: 9:00-10:30 AM

    • TA:Tue: 10:00 – 10:30 AM

    • . TBA


Finding csil labs 1

Finding CSIL labs: 1


Finding csil labs 2

Finding CSIL labs: 2

CSIL Labs


Access to csil

Access to CSIL

  • CSIL is protected by a security card access system

    • As a student in a computing science course you are eligible to have a security access card for CSIL

    • If you are pre-registered your access card may be picked up from the card office at traffic and security (there is a $15 refundable deposit and a $3 processing fee)


Csil rules

CSIL Rules

  • Before you can use any of the computers in the CSIL you must sign and return an ethics form.

    • By signing the ethics form you indicate that you have read and agree to abide by the SFU and CSIL regulations regarding use of computing resources and computer labs.

    • Links to these policies can be found on the class website or on Course Central

    • You can return your ethics forms during next class, or directly to the computing science main office.


Http www cs sfu ca coursecentral1

http://www.cs.sfu.ca/CourseCentral

Select to reach Policies


Csil page

CSIL page

IMPORTANT

Read the

Policies

Before

Signing

Your

Ethics form


Getting started in csil

Getting Started in CSIL

  • Before you try programming in CSIL read the information provided for you

    • Read the general information pages

    • Browse the FAQs,

    • Now you are ready to start

  • Your CSIL computer ID and password and the ID an password you use for your SFU email account.


Csil page1

CSIL page

Read the

general

information

Browse

The

FAQs


Labs and using csil

Labs and using CSIL

  • The computers in CSIL are available 24/7

  • At some times your instructor or TA will be available to answer questions

  • At some times OPEN LAB TA’s will be available to answer questions.

  • A list of TA’s presently in the lab will be posted on the white board in CSIL.


Optional lab hours

Optional Lab Hours

  • Attendance at optional Lab hours is strongly encouraged

    • Lab Hours are held in the LINUX area of CSIL labs

    • Lab Hours provide an opportunity to work with others sharing knowledge and experience.

    • Lab Hours give you an opportunity to ask the instructor or TA one on one questions about problems and assignments.

    • Lab Hours help you learn the required concepts one by one and allow you to ask questions to assure you understand each one.


Operating system

Operating System

  • In the CSIL labs you will be using computers that run the LINUX operating system

  • In the first optional lab hours there will be tutorials on how to use the LINUX operating system (1 per hour)

  • The tutorial will also be posted so you can try it yourself at another time


Reading assignment

Reading Assignment

  • Visit and read the information on the class website

  • Be sure you can find

    • Posted notes

    • Reading assignments for each lecture

    • Assignment due dates

    • Instructions on using the CSIL labs

    • Instructions on using your own computer for assignments

  • Have any questions ready for next lecture


Cmpt 102 introduction to scientific computer programming2

CMPT 102Introduction to Scientific Computer Programming

Chapter 1:

Computer Components


Hardware and software

Hardware and Software

  • A computer is a machine designed to perform operations specified with a set of instructions called a program.

  • Hardware refers to the computer equipment.

    • keyboard, mouse, terminal, hard disk, printer, CPA

  • Software refers to the programs that describe the steps we want the computer to perform.


Computer hardware

Computer Hardware

  • CPU –

    • Central processing unit

  • ALU –

    • Arithmetic and logic unit

  • ROM –

    • Read only memory

  • RAM –

    • Random access memory

Internal

Memory

External

Memory

CPU

Input

Output

Processor

ALU

Cache/

Memory


Software operating system

Software: Operating System

  • A system of computer programs that control the interaction of the user and the computer hardware. Examples: Linux, Windows, QNX,…

  • Purposes of the operating system

    • Controls communication between input and output hardware and each process running in the computer.

    • Directs and orders all operations of the computer

    • Allocates and shares resources (memory,processor…)

    • Controls access to resources and data (security)

    • Provides a user interface (UI) and/or graphical user interface (GUI)

    • Stores and accesses data and applications


Example command line ui

Example: Command Line UI

  • Windows Command Prompt


Example graphical ui gui

Example: Graphical UI (GUI)

  • Windows explorer


Computer software applications

Computer Software: Applications

  • Application Software (Software Tools)

    • Word processors (Microsoft Word, WordPerfect, ...)

    • Spreadsheet programs (Excel, Lotus1-2-3, ...)

    • Computer games

    • Communication software (email, chat, web browser…)

    • Telecommunication software (VOIP, …)


Computer software languages

Computer Software: Languages

  • Some Computer Languages

    • Machine language (machine instruction set)

    • assembly language

    • high level languages

      • C, C++, Ada, Fortran, Basic, Java

      • Do YOU know of any others?

      • mathematical computation tools (MATLAB, Mathematica, ...)

  • Application software is written using computer languages.


Machine language

Machine language

  • Each type of processor (like Pentium 4, Athalon, Z80, …) has its own instruction set

  • Each instruction in an instruction set does a single thing like access a piece of data, add two pieces of data, compare two pieces of data …

  • Each instruction is represented by a unique number This # may be different for different instruction sets, but no two instructions in the same instruction set will have the same #


Machine language programs

Machine Language programs

  • In machine language a program is a list of instructions

    • Each instruction is represented by a number

    • Inside the memory of the computer each number is represented in binary (as a constant length string of 1’s and 0’s)

    • The long string of 0’s and 1’s is easy for the computer to understand and very difficult for a Human to read or write


Assembler

Assembler

  • Assembler languages make it easier for the programmer.

    • Assembler is easier for humans to read/write

    • The numbers that identify each of the instructions in the instruction set are replaced with mnemonics like ADD, CMP, …

    • The code, written using these mnemonics is written into a text file.


Assembler programs

Assembler Programs

  • The code for an Assembler program is written into a text file.

  • The computer read 1’s and 0’s not text

  • How do we translate to machine readable form?

    • A computer program called a compiler is used to translate the text file (called a source file) containing the assembler code into machine readable code

    • The compiler writes a binary file containing the machine readable code (called an object file)


Programs in high level languages

Programs in High Level Languages

  • Assembler is easier to read/write than machine language. It is still very cumbersome

  • High level languages are easier to write than assembler

    • The compiler is more complex, but that is a tool you use, not one you write

  • In this course we will learn the language C

  • The rest of today's discussion is equally applicable to C or to any other compiled language (C++, Fortran, …)


Writing your program

Writing your program

Editor, Type in

your program

Source File

Text saved on hard disk

Compiler

Translate text into

Machine

Readable code


Source files

Source files

  • Contains the text you type into a text editor

  • The text is a program

  • The program is a list of instructions written in a special Human readable language (C)

  • The program can be translated, from the Human readable language (in source file) to a machine readable language (in object file), by a compiler

  • A compiler is a special piece of software used to translate from source files to object files


Source files1

Source files

  • Source File:

    • Write using a text editor like Kate

    • Do not write your code using a word processor like Microsoft Word. A word processor will save in a special format.

    • The compiler reads only text, not special formats.

  • Beware: your text does not differentiate between a word processor and an editor


Perfect code finding errors 1

Perfect Code? Finding Errors 1

  • It is highly unlikely than any of us will always write perfect code that contains no errors

  • How do we find errors?

  • Are there different kinds of errors? Yes

  • A computer program can contain syntax errors. semantic errors, or logical errors

  • When and how can we detect and correct errors?

    • Compile errors

    • Link errors

    • Run Time Errors


Syntax errors

Syntax Errors

  • A computer program can contain syntax errors

  • A computer language follows simple rules

    • how words and punctuation of different types may be combined.

    • In English syntax is similar to grammatical structure

  • The compiler for a high level language can detect errors that break those simple of syntax (syntax errors)

  • Syntax Errors are usually detected at compile time


Semantic errors

Semantic Errors

  • A computer program can contain semantic errors

  • Semantics relates to the meaning of the words in a sentence or a computer language command

  • Just like a grammatically correct English sentence can be nonsense, a syntactically correct high level computer language command can also contain semantic errors

  • Some semantic errors may be found by the compiler, some will be found when the program is linked, some may be found at run time


Logical errors

Logical Errors

  • When your program completes but gives an unexpected answer it usually means there is a error in the logic in your solution of the problem

  • Logic errors can also cause a program to fail part way through execution


Writing your program1

Writing your program

Editor, Type in

your program

Editor, Correct

Syntax Errors

Source File

Code with syntax

Or semantic errors

Syntax or Semantic Errors,

Compiler Generates error

Messages. To help us find

and Correct errors in the

Source File

Compiler

Translation to

Machine code

Syntactically Correct

code

Object File

Binary,

machine readable file


Perfect code finding errors 2

Perfect Code? Finding Errors 2

  • If your code contains compile time errors is it correct? NOT NECESSARILY

  • How do we find the remaining errors?

  • Use a tool that does more checks than the compiler (splint).

  • Move on to linking the code to libraries etc.

    • The linker resolves references, words in your program than are defined elsewhere

    • Errors occur when the definitions cannot be found

    • Errors occur when the use of the word does not correspond to the definition


Linking your program

Linking your program

Editor,

Enter

program

Source

File

(Text)

Correct

Errors

Other Object Files

Libraries …

Compile

Find Syntax

and

SemanticErrors

Linker

Resolves

References

among

object files

Object

File

(binary)

Code has linker errors

Semantic Errors Reported:

Finds words with no defined meaning.

Executable File

(load module)

(binary)


Perfect code finding errors 3

Perfect Code? Finding Errors 3

  • If your code compiles and contains no errors that can be found by the linker (or splint) is it correct? NOT NECESSARILY

  • How do we find the remaining logic and semantic errors?

  • When you run your executable program

    • it may not complete (may or may not generate error message)

    • It may complete and give the wrong answer


Loading running your program

Loading/Running your program

Editor,

Enter

program

Source

File

(Text)

Correct

Errors

Compile

Find Syntax

and some

SemanticErrors

Object

File

(binary)

output

results

CPU

Input

data

Link Errors Reported:

Loader

Copies

Executable

And Runs

Linker

Resolves

References

Executable File

(binary)

Other

Object Files


Summary executing a computer program

Summary:Executing a Computer Program

Input data

  • Compiler

    • Converts a source file (containing your human readable program in C) to and object file (computer readable binary file)

  • Linker

    • Converts object program to executable program

Machine

language

Program

In binary file

(object file)

Compile

Link/load

Execute

C language

Program in

Text file

(source file)

Program

output

Other

object files


Summary types of errors

Summary: Types of Errors

  • Syntax errors

    • Errors in syntax, how words are combined and used

      • reported by the compiler or splint

  • Semantic errors

    • Errors in the meaning of words,

      • Reported by the linker (linker errors)

      • Reported by the compiler (compile time errors)

      • Found at execution time (run-time errors)

  • Logic errors

    • Errors causing the incorrect results, not reported

    • Errors causing program failure (run-time errors)


  • Login