CSc 10200! Introduction to Computing. Lecture 1 Edgardo Molina Fall 2013 City College of New York

Similar documents
Lecture 1: Preliminaries

CSc Introduction to Computing

EKT 120/4 Computer Programming KOLEJ UNIVERSITI KEJURUTERAAN UTARA MALAYSIA

Chapter 1: An Overview of Computers and Programming Languages. Objectives. Objectives (cont d.) Introduction

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

BITG 1113: Introduction To Computers And Programming Language LECTURE 1 LECTURE 1 1

Programming 1. Lecture 1 COP 3014 Fall August 28, 2017

1a Computers, Problem Solving!

Introduction. Arizona State University 1

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

0 Introduction: Computer systems and program development

C++ Programming Language Lecture 1 Introduction

Programming Languages and Program Development Life Cycle Fall Introduction to Information and Communication Technologies CSD 102

Programming 1 - Honors

Computer is an electronic machine that can receive, store, transform and output data of all kinds (image, text, numeric, graphics and sound).

17. Instruction Sets: Characteristics and Functions

Week 1 Introduction to Computer and Algorithm (Part1) UniMAP Sem II 11/12 DKT121: Basic Computer Programming 1

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

The births of the generations are as follow. First generation, 1945 machine language Second generation, mid 1950s assembly language.

CSI32 Object-Oriented Programming

Chapter 1 Introduction to Computers and C++ Programming

Organisation. Assessment

Lecture Objectives. Structured Programming & an Introduction to Error. Review the basic good habits of programming

Chapter 1 INTRODUCTION

Computer Fundamentals

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

Chapter 3: Operating-System Structures

CS1500 Algorithms and Data Structures for Engineering, FALL Virgil Pavlu, Jose Annunziato,

CSc 10200! Introduction to Computing. Lecture 4-5 Edgardo Molina Fall 2013 City College of New York

Introduction to Java Programming

CSc Introduc/on to Compu/ng. Lecture 8 Edgardo Molina Fall 2011 City College of New York

Problem Solving and Program Design - Chapter 1. Cory L. Strope

Algorithm: 1. Introduction

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

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

8/16/12. Computer Organization. Architecture. Computer Organization. Computer Basics

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

Introduction to C++ Programming. Adhi Harmoko S, M.Komp

Review for COSC 120 8/31/2017. Review for COSC 120 Computer Systems. Review for COSC 120 Computer Structure

Computer Software: Introduction

ECS15, Lecture 10. Goals of this course 2/8/13. Mini-Review & Topic 3.2 Software. Today s agenda

Adding Binary Integers. Part 5. Adding Base 10 Numbers. Adding 2's Complement. Adding Binary Example = 10. Arithmetic Logic Unit

An Introduction to Computers and Java CSC 121 Spring 2015 Howard Rosenthal

Software Concepts. It is a translator that converts high level language to machine level language.

Operating-System Structures

OS and Computer Architecture. Chapter 3: Operating-System Structures. Common System Components. Process Management

Week 0: Intro to Computers and Programming. 1.1 Why Program? 1.2 Computer Systems: Hardware and Software. Hardware Components

Chapter Twelve. Systems Design and Development

Programming Languages FILS Andrei Vasilateanu

CS 102 Lecture 1. Syllabus, history, intro

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

CS102 Unit 2. Sets and Mathematical Formalism Programming Languages and Simple Program Execution

Chapter 1 Introduction to Computers and Programming

CHAPTER 1 Introduction to Computers and Java

Chapter 3: Operating-System Structures

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

CSC180: Lecture 2. Wael Aboulsaadat.

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

Programming Languages and Program Development

IS 0020 Program Design and Software Tools

CSCE150A. Administrivia. Overview. Hardware. Software. Example. Program. Pseudocode. Flowchart. Control Structures. Hello World Program CSCE150A

Computer Science & Engineering 150A Problem Solving Using Computers

Computer Organization and Assembly Language. Lab Session 01

Week 1 Introduction to Programming

Chapter 1: Why Program? Computers and Programming. Why Program?

1) Which of the following is an example of a programming language? 1) A) Microsoft Word B) English C) HTML D) Java

Computer Basics 1/6/16. Computer Organization. Computer systems consist of hardware and software.

Computer Programming : C++

M1 Computers and Data

Information Science 1

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program?

Chapter 2 Basic Elements of C++

ORG ; TWO. Assembly Language Programming

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Basic Operations jgrasp debugger Writing Programs & Checkstyle

Chapter 1: Introduction to Computers and Programming

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Bits, Words, and Integers

Copyright 2005 Department of Computer & Information Science

Last class: OS and Architecture. OS and Computer Architecture

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components

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

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8

Lecture C1 Data Representation. Computing and Art : Nature, Power, and Limits CC 3.12: Fall 2007

Computer Basics 1/24/13. Computer Organization. Computer systems consist of hardware and software.

CSc Introduc/on to Compu/ng. Lecture 17 Edgardo Molina Fall 2011 City College of New York

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Chapter 2. Data Representation in Computer Systems

EP241 Computer Programming

CHAPTER 1: INTRODUCTION TO COMPUTERS AND PROGRAMMING. 1 Muhalim Mohamed Amin Faculty of

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

Principles of Programming Languages. Lecture Outline

Topic 1: Programming concepts

Chapter 3: Arithmetic for Computers

CS112 Lecture: Primitive Types, Operators, Strings

Numerical Methods in Scientific Computation

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Transcription:

CSc 10200! Introduction to Computing Lecture 1 Edgardo Molina Fall 2013 City College of New York 1

Introduction to Computing Lectures: Tuesday and Thursday s (2-2:50 pm) Location: NAC 1/202 Recitation: Friday s Sec PP: 1 2:40 pm Sec PP2: 3 4:40 pm Location: NAC 7/107 2

Class Resources Class Website http://ccvcl.org/~molina/f13-cs102/ Lecture slides, homework, schedule will all be posted on the website. Textbook C++ for Engineers and Scientists Third or Fourth Edition By: Gary J. Bronson 3

C++ for Engineers and Scientists Third Edition Chapter 1 Preliminaries 4

Objectives Chapter 1: Software, hardware, and computer storage Software development Algorithms Common programming errors Review on your own Unit analysis Exponential and scientific notations C++ for Engineers and Scientists, Third Edition 5

A Closer Look: Software, Hardware, and Computer Storage Programming: Process of writing a program, or software Programming language: Set of instructions used to construct a program Comes in a variety of forms and types C++ for Engineers and Scientists, Third Edition 6

Machine Language Only programs that can actually be used to operate a computer Also referred to as executable programs (executables) Consists of a sequence of instructions composed of binary numbers Contains two parts: an instruction and an address C++ for Engineers and Scientists, Third Edition 7

Assembly Language Substitute word-like symbols, such as ADD, SUB, and MUL, for binary opcodes Use decimal numbers and labels for memory addresses Example: ADD 1, 2 Assemblers: Translate programs into machine language C++ for Engineers and Scientists, Third Edition 8

Assembly Language (continued) Figure 1.9 Assembly-language programs must be translated C++ for Engineers and Scientists, Third Edition 9

Low- and High-Level Languages Low-level languages: Languages that use instructions tied directly to one type of computer Examples: machine language, assembly language High-level languages: Instructions resemble written languages, such as English Can be run on a variety of computer types Examples: Visual Basic, C, C++, Java C++ for Engineers and Scientists, Second Edition 10

Low- and High-Level Languages ( continued ) Source code: The programs written in a high- or low-level language Source code must be translated to machine instructions in one of two ways: Interpreter: Each statement is translated individually and executed immediately after translation Compiler: All statements are translated and stored as an executable program, or object program; execution occurs later C++ is predominantly a compiled language C++ for Engineers and Scientists, Third Edition 11

Low- and High-Level Languages ( continued ) Large C++ programs may be stored in two or more separate program files due to: Use of previously written code Use of code provided by the compiler Modular design of the program (for reusability of ( components Linker: Combines all of the compiled code required for the program C++ for Engineers and Scientists, Third Edition 12

Procedural and Object Orientations Programs can also be classified by their orientation: Procedural: Available instructions are used to create self-contained units called procedures Object-oriented: Reusable objects, containing code and data, are manipulated Object-oriented languages support reusing existing code more easily C++ contains features of both C++ for Engineers and Scientists, Third Edition 13

Procedural and Object Orientations (continued) Figure 1.10 Creating an executable C++ program C++ for Engineers and Scientists, Third Edition 14

Application and System Software Application software: Programs written to perform particular tasks for users System software: Collection of programs to operate the computer system System software must be loaded first; called booting the system Bootstrap loader: A permanent, automatically executed component to start the boot process C++ for Engineers and Scientists, Third Edition 15

Application and System Software ( continued ) Operating system: The set of system programs used to operate and control a computer Also called OS Tasks performed by the OS include: Memory management Allocation of CPU time Control of input and output Management of secondary storage devices C++ for Engineers and Scientists, Third Edition 16

Application and System Software ( continued ) Multi-user system: A system that allows more than one user to run programs on the computer simultaneously Multitasking system: A system that allows each user to run multiple programs simultaneously Also called multiprogrammed system C++ for Engineers and Scientists, Third Edition 17

The Development of C++ The purpose of most application programs is to process data to produce specific results Figure 1.11 Basic procedural operations C++ for Engineers and Scientists, Third Edition 18

( continued ) The Development of C++ Early procedural languages included: FORTRAN: Formula Translation ALGOL: Algorithmic Language COBOL: Common Business Oriented Language BASIC: Beginners All-purpose Symbolic Instruction Code Pascal C Early object-oriented language: C++ C++ for Engineers and Scientists, Third Edition 19

Computer Hardware Computer hardware: Components that support the capabilities of the computer Figure 1.14 Basic hardware units of a computer C++ for Engineers and Scientists, Third Edition 20

( continued ) Computer Hardware Components include: Arithmetic and logic unit (ALU): Performs arithmetic and logic functions Control unit: Directs and monitors overall operations Memory unit: Stores instructions and data Input and output (I/O) unit: Interfaces to peripheral devices Secondary storage: Nonvolatile permanent storage such as hard disks C++ for Engineers and Scientists, Third Edition 21

( continued ) Computer Hardware Central processing unit (CPU): Also called microprocessor; combines the ALU and control unit on a single chip C++ for Engineers and Scientists, Third Edition 22

( continued ) Computer Hardware Figure 1.15 VLSI chip connections for a desktop computer C++ for Engineers and Scientists, Third Edition 23

Computer Storage Bit: Smallest unit of data; value of 0 or 1 Byte: Grouping of 8 bits representing a single character Character codes: Collection of patterns of 0s and 1s representing characters Examples: ASCII, EBCDIC C++ for Engineers and Scientists, Third Edition 24

( continued ) Computer Storage Number codes: Patterns used to store numbers Twos complement number code: Represents a decimal number as a binary number of 0s and 1s Determine with a value box Figure 1.17 Converting 10001101 to a base 10 number C++ for Engineers and Scientists, Third Edition 25

( continued ) Computer Storage Word: Grouping of one or more bytes Facilitates faster and more extensive data access Number of bytes in a word determines the maximum and minimum values that can be stored: Table 1.4 Word size and Integer Values C++ for Engineers and Scientists, Third Edition 26

Preliminary Three: Software Development Computer program: Self-contained set of instructions used to operate a computer to produce a specific result Also called software Solution developed to solve a particular problem, written in a form that can be executed on a computer Writing a program is almost the last step in a process that determines: The problem to be solved The method to be used in the solution C++ for Engineers and Scientists, Third Edition 27

Preliminary Three: Software Development (continued) Software development procedure: Helps developers understand the problem to be solved and create an effective, appropriate software solution Software engineering: Concerned with creating readable, efficient, reliable, and maintainable programs and systems Uses software development procedure to achieve this goal C++ for Engineers and Scientists, Third Edition 28

Preliminary Three: Software Development (continued) Figure 1.1 The three phases of program development C++ for Engineers and Scientists, Third Edition 29

Phase I: Development and Design Program requirement: request for a program or a statement of a problem After a program requirement is received, Phase I begins Phase I consists of four steps: Analysis Design Coding Testing C++ for Engineers and Scientists, Third Edition 30

Phase I: Development and Design (continued) Figure 1.2 The development and design steps C++ for Engineers and Scientists, Third Edition 31

Phase I: Development and Design (continued) Step 1: Analyze the Problem Determine and understand the output items the program must produce Determine the input items Both items referred to as the problem's input/output ( I/O ) C++ for Engineers and Scientists, Third Edition 32

Phase I: Development and Design (continued) Step 2: Develop a Solution Select the exact set of steps, called an algorithm, to be used to solve the problem Find the solution by a series of refinements Start with initial solution in the analysis step until you have an acceptable and complete solution Check solution Refine initial structure until the tasks in the boxes are completely defined C++ for Engineers and Scientists, Third Edition 33

Phase I: Development and Design (continued) Figure 1.3 A first-level structure diagram C++ for Engineers and Scientists, Third Edition 34

Phase I: Development and Design (continued) Step 2: Develop a Solution (continued) Example: a second-level structure diagram for an inventory tracking system with further refinements Figure 1.4 A second-level structure diagram C++ for Engineers and Scientists, Third Edition 35

Phase I: Development and Design (continued) Step 3: Code the Solution Consists of actually writing a C++ program that corresponds to the solution developed in Step 2 Program statements should conform to certain welldesigned patterns or structures that have been defined in solution step C++ for Engineers and Scientists, Third Edition 36

Phase I: Development and Design (continued) Step 3: Code the Solution (continued) Program should contain well-defined patterns or structures of the following types: Sequence Selection Iteration Invocation C++ for Engineers and Scientists, Third Edition 37

Phase I: Development and Design (continued) Step 3: Code the Solution (continued) Sequence: Defines the order in which instructions are executed Selection: Allows a choice between different operations, based on some condition Iteration: Allows the same operation to be repeated based on some condition Also called looping or repetition Invocation: Involves invoking a set of statements when needed C++ for Engineers and Scientists, Third Edition 38

Phase I: Development and Design (continued) Step 4: Test and Correct the Program Testing: Method to verify correctness and that requirements are met Bug: A program error Debugging: The process of locating an error, and correcting and verifying the correction Testing may reveal errors, but does not guarantee the absence of errors C++ for Engineers and Scientists, Third Edition 39

Phase I: Development and Design (continued) Step 4: Test and Correct the Program (continued) Table 1.3 lists the comparative amount of effort typically expended on each development and design step in large commercial programming projects Table 1.3 Effort Expended in Phase I C++ for Engineers and Scientists, Third Edition 40

Phase II: Documentation Five main documents for every problem solution: Program description Algorithm development and changes Well-commented program listing Sample test runs Users' manual C++ for Engineers and Scientists, Third Edition 41

Phase III: Maintenance Maintenance includes: Ongoing correction of newly discovered bugs Revisions to meet changing user needs Addition of new features Usually the longest phase May be the primary source of revenue Good documentation vital for effective maintenance C++ for Engineers and Scientists, Third Edition 42

Backup Process of making copies of program code and documentation on a regular basis Backup copies = insurance against loss or damage Consider using off-site storage for additional protection C++ for Engineers and Scientists, Third Edition 43

Preliminary Four: Algorithms Algorithm: Step-by-step sequence of instructions that: Must terminate Describe how the data is to be processed to produce the desired output C++ for Engineers and Scientists, Third Edition 44

Preliminary Four: Algorithms (continued) Pseudocode: English-like phrases used to describe the steps in an algorithm Formula: Mathematical equations Flowchart: Diagrams with symbols C++ for Engineers and Scientists, Third Edition 45

Preliminary Four: Algorithms ( continued ) Problem: Calculate the sum of all whole numbers from 1 through 100 Figure 1.5 Summing the numbers 1 to 100 C++ for Engineers and Scientists, Third Edition 46

Preliminary Four: Algorithms ( continued ) Figure 1.5 Summing the numbers 1 to 100 (continued) C++ for Engineers and Scientists, Third Edition 47

Preliminary Four: Algorithms ( continued ) Figure 1.5 Summing the numbers 1 to 100 (continued) C++ for Engineers and Scientists, Third Edition 48

Preliminary Four: Algorithms ( continued ) Figure 1.6 Flowchart symbols C++ for Engineers and Scientists, Third Edition 49

Preliminary Four: Algorithms ( continued ) Figure 1.6 Flowchart symbols (continued) C++ for Engineers and Scientists, Third Edition 50

Preliminary Four: Algorithms ( continued ) Figure 1.7 Flowchart for calculating the average of three numbers C++ for Engineers and Scientists, Third Edition 51

Common Programming Errors Common errors include: Forgetting to check that all units for numerical values used in a calculation are consistent Using an incorrect form of a conversion factor Rushing to write and run a program before fully understanding what s required Not backing up a program Not understanding that computers respond only to explicitly defined algorithms C++ for Engineers and Scientists, Third Edition 52

Hello World in C++ #include <iostream> using namespace std; int main() { cout << "Hello World!\n"; return 0; } 53

Summary To determine correct forms of a conversion factor, perform a unit analysis Software: Programs used to operate a computer Programming language types: Low-level languages Machine language (executable) programs Assembly languages High-level languages Compiler and interpreter languages C++ for Engineers and Scientists, Third Edition 54

( continued ) Summary Software engineering: discipline concerned with creating readable, efficient, reliable, and maintainable programs Three phases in software development: Program development and design Documentation Maintenance C++ for Engineers and Scientists, Third Edition 55

( continued ) Summary Four steps in program development and design: Analyze the problem Develop a solution Code the solution Test and correct the solution Algorithm: Step-by-step procedure that describes how a task is performed Computer program: Self-contained unit of instructions and data used to operate a computer to produce a desired result C++ for Engineers and Scientists, Third Edition 56

( continued ) Summary Four fundamental control structures used in coding: Sequence Selection Iteration Invocation C++ for Engineers and Scientists, Third Edition 57

Extra slides Fundamentals of Information Systems, Fifth Edition 58

Preliminary One: Unit Analysis Using consistent and correct units when making computations is crucial Performing a unit analysis Include only the units and conversion factors in an equation Cancel out corresponding units in the numerator and denominator C++ for Engineers and Scientists, Third Edition 59

Preliminary One: Unit Analysis (continued) Engineering and scientific units: English Engineering system and the International System ( SI ) are commonly used Apply one conversion factor at a time and cancel units as you go along to avoid multiplying or dividing by the wrong conversion factor If the final units do not yield the correct resulting units, then the resulting numerical answer must be incorrect C++ for Engineers and Scientists, Third Edition 60

Preliminary One: Unit Analysis (continued) Table 1.1 Commonly Used Physical Quantities C++ for Engineers and Scientists, Third Edition 61

Preliminary One: Unit Analysis (continued) Table 1.1 Commonly Used Physical Quantities (continued) C++ for Engineers and Scientists, Third Edition 62

Preliminary Two: Exponential and Scientific Notations Many engineering and scientific applications deal with extremely large and extremely small numbers Written in exponential notation to make entering the numbers in a computer program easier Written in scientific notation when performing hand calculations for verification purposes C++ for Engineers and Scientists, Third Edition 63

Preliminary Two: Exponential and Scientific Notations (continued) Examples of exponential and scientific notation: C++ for Engineers and Scientists, Third Edition 64

Using Scientific Notation Essential in understanding what formulas are to be used and verifying calculations, typically by hand Convenient for evaluating formulas that use very large or very small numbers Two basic exponential rules Rule 1: 10 n x 10 m = 10 n+m for any values, positive or negative, of n and m Rule 2: 1/10 -n = 10 n for any positive or negative value of n C++ for Engineers and Scientists, Third Edition 65

Using Scientific Notation (continued) If exponent is positive, it represents the actual number of zeros that follow the 1 If exponent is negative, it represents one less than the number of zeros after the decimal point and before the 1 Scientific notation can be used with any decimal number Not just powers of 10 C++ for Engineers and Scientists, Third Edition 66

Using Scientific Notation (continued) Common scientific notations have their own symbols Table 1.2 Scientific Notational Symbols C++ for Engineers and Scientists, Third Edition 67