Textbook C for Scientists and Engineers © Prentice Hall 1997 Available at NUS CO-OP at S$35.10.

Slides:



Advertisements
Similar presentations
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
Advertisements

The Analytical Engine Module 6 Program Translation.
Computer Concepts 5th Edition Parsons/Oja Page 546 CHAPTER 11 Software Engineering Section A PARSONS/OJA Computer Programming.
Lecture 1: Intro to Computers Yoni Fridman 6/28/01 6/28/01.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
Assembly Language for Intel-Based Computers, 4th Edition
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 1: Getting Started by George Lamperti & BU Faculty.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Introduction to a Programming Environment
Ceng 230 Programming with C
Introduction to Computers and Programming. Some definitions Algorithm: Algorithm: A procedure for solving a problem A procedure for solving a problem.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#1) By Dr. Syed Noman.
1 Programming Languages Examples: C, Java, HTML, Haskell, Prolog, SAS Also known as formal languages Completely described and rigidly governed by formal.
Introduction to Programming (in C++) Introduction Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Assembly Language for Intel-Based Computers, 5th Edition
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Final Exam Review Instructor : Yuan Long CSC2010 Introduction to Computer Science Apr. 23, 2013.
Computer Science 101 Introduction to Programming.
1 I.Introduction to Algorithm and Programming Algoritma dan Pemrograman – Teknik Informatika UK Petra 2009.
ENGR. SHOAIB ASLAM Computer Programming I Lecture 02.
Introduction to Programming G50PRO University of Nottingham Unit 1 : Introduction Paul Tennent
Introduction COMP104: Fundamentals and Methodology.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Integer Data representation Addition and Multiplication.
Simple Data Type Representation and conversion of numbers
CS 1 •This is Computer Science 1. •Who is Professor Adams?
High-Level Programming Languages: C++
1 Intro to Computer Science I Chapter 1 Introduction to Computation Algorithms, Processors, and Programs.
CIS Computer Programming Logic
CS2303 C14 Systems Programming Concepts Bob Kinicki.
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Assembly Language for x86 Processors 7th Edition
AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Comp Sci 251 Intro 1 Computer organization and assembly language Wing Huen.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Computer Science 101 Introduction to Programming.
LANGUAGE TRANSLATORS: WEEK 24 TRANSLATION TO ‘INTERMEDIATE’ CODE (overview) Labs this week: Tutorial Exercises on Code Generation.
CS100J Spring 2006 CS100J: 11 weeks of programming using Java and 2 weeks using Matlab. David Gries is teaching CS100J. Graeme Bailey is teaching a special.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
6 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
EG280 Computer Science for Engineers Fundamental Concepts Chapter 1.
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
Number Representation, Data Types and Elementary Programming Shirley Moore CS 1401 February 5-7, 2013.
Introduction to Programming Instructor: Yong Tang Brookhaven National Laboratory Working on accelerator control (BNL Phone #)
CZ1102 Scientific Problem Solving and Computation Monday/Thursday 2:00pm, LT22 Your lecturer: Dr. Wang Jian-Sheng.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 3, Lecture 1.
ACOE2511 Assembly Language for the 80X86/Pentium Intel Microprocessors Lecturer: Dr. Konstantinos Tatas.
CMSC 150 PROGRAM EXECUTION CS 150: Wed 1 Feb 2012.
COIT29222 Structured Programming1 COIT29222-Structured Programming Lecture Week01 Reading: Course Profile Textbook (4 th Ed.), Chapter 1 Textbook (6 th.
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
1 Programming a Computer Lecture Ten. 2 Outline  A quick introduction to the programming language C  Introduction to software packages: Matlab for numerical.
8 January 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
CS 125 Lecture 2 Martin van Bommel. Hardware vs Software Hardware - physical components you can see and touch –e.g. processor, keyboard, disk drive Software.
WELCOME To ESC101N: Fundamentals of Computing Instructor: Ajai Jain
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Introduction to Computing
Topic: Python’s building blocks -> Variables, Values, and Types
Assembly Language for x86 Processors 6th Edition
PROGRAMMING LANGUAGES
CS190/295 Programming in Python for Life Sciences: Lecture 1
Introduction to Computer Programming
Presentation transcript:

Textbook C for Scientists and Engineers © Prentice Hall 1997 Available at NUS CO-OP at S$35.10

Organization of the Course 24 Lectures (2 per week) 6 (Computer) Labs 5 Tutorials Midterm exam [14 Sep 98] (20%) Lab/Home Work (20%) Final exam (60%) Sign up lab sessions, Unix training, time and venue

Goal/Objective Basic ability to write C programs Formulate scientific problems as computer algorithms A preparation for almost all other CZ modules

Algorithms An algorithm is a precise, step-by-step method for solving a problem. Example Compute ··· + n 1. sum = 0 2. i = 0 3. i = i sum = sum + i 5. Repeat lines 3 and 4 until i == n.

Computer Code (i. e., Program) sum = 0; i = 0; do { i = i + 1; sum = sum + i; } while (i < n); The concepts of “variable”, “assignment’’, “logical expression’’, and “loop’’.

How does the Computer Code Execute? 1) sum = 0; 2) i = 0; 3) do { 4) i = i + 1; 5) sum = sum + i; 6) } while (i < n); We assume n = 3. Line 1) variable sum gets a value 0; Line 2) variable i gets 0; Line 3) mark the beginning of a while-loop; Line 4) replace the value of variable i by its old value (0) plus 1. I.e., i = 1; Line 5) replace the value of sum by its old value (0) + current value of i, i.e., sum = 0+1=1. Line 6) is i < 3? yes, since I=1, so go back to line 4); Line 4) value i increased by 1 to 2; Line 5) value sum becomes = 3; Line 6) is i < 3? yes, since i = 2, go back to Line 4); Line 4) i becomes 2 +1 = 3; Line 5) sum becomes = 6; Line 6) is i < 3? no, since i = 3. Program stops.

Computer System ENIAC, built in 1940s, with vacuum tubes. It is 10 2 times bigger in size and more than 10 4 times slower than today’s typical PC. CPU Main memory Input Output

Internal Representations All data (integer, real number, character) and programs (machine code) are represented as strings of 0s and 1s. E.g., Units of the data The meaning of the strings of 0 and 1 depends on interpretation. 1 byte = 8 bits 1 kilobyte (Kbytes) = 1024 bytes 1 Megabyte = 1024 Kbytes

(Unsigned) Binary Integers ‚We are familiar with the decimal integers 0, 1, 2, 3, 4, … ‚In (unsigned/positive) binary representation, the same set of numbers are written as 0, 1, 10, 11, 100, ‚In general, binary and decimal numbers are related by (e.g.) = 1· · · · · · 2 0 = = Hexadecimal, representation of negative numbers, read the textbook.

Programming Process Main() { int i; i = 5; printf(“I=%”,i); High-level programming language Machine instructions Compilation

Language Tree 1950 Fortran 1977 Fortran77 Fortran95 Pascal 1990 BCPL B C ANSI C C++ Java Why C? Portability, efficiency, modularity, simple syntax and semantics, programming support.

Reading/Home Working Read Chapter 1 –Pages 2 to 30. –Please DO read for at least a hour of textbook material associated with each lecture. –Do not procrastinate until exam. Work on Exercises at –Section 1.3/page 16-17, exercise 1, 3, 5. –Answers are on in the back of the book. –Do not hand in.