Professor John CarelliKutztown University Computer Science Department Computer Science I CSC 135.

Slides:



Advertisements
Similar presentations
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Advertisements

Lecture 1: Overview of Computers & Programming
Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Fundamentals and a Brief History of Computer Systems.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
Chapter 1: An Overview of Computers and Programming Languages
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
Introduction to C++ Programming CS 117 Section 2 and KNET Sections Spring 2001 MWF 1:40-2:30.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Topic 1: Introduction to Computers and Programming
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
CIS 260 Computer Programming I in C Prof. Timothy Arndt.
COS120 Software Development Using C++ AUBG Fall semester 2010
CS 115 Chapter 1 Overview of Programming and Problem Solving.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
CS 161 INTRO TO PROGRAMMING I Dr. Blaise W. Liffick Fall
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers, Problem Solving, and Programming Problem.
Chapter Introduction to Computers and Programming 1.
Introduction to Programming Dr Masitah Ghazali Programming Techniques I SCJ1013.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
BACS 287 Basics of Programming BACS 287.
Topics Introduction Hardware and Software How Computers Store Data
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
CISC105 General Computer Science Class 1 – 6/5/2006.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Introduction Lecture 01.
Introduction to Computers, Problem Solving, and Programming Chapter 1.
CPS120: Introduction to Computer Science Introduction to Computers.
Chapter 1 – Computing Fundamentals. History of Electronic Computers u First computer –ABC (Atanasoff Berry Computer) at Iowa State U. –1930’s –Solved.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Mrs. Ulshafer August, 2013 Java Programming Chapter 1.
Computer Architecture
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Chapter 1 : Overview of Computer and Programming By Suraya Alias
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
A.Abhari CPS1251 Topic 1: Introduction to Computers Computer Hardware Computer components Connecting Computers Computer Software Operating System (OS)
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Chapter 1 An Overview of Computers and Programming Languages.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming
Chapter 1: Introduction to Computers, Problem Solving, and Programming
Introduction to Computers
Java Programming: From the Ground Up
BASIC PROGRAMMING C SCP1103 (02)
Chapter 1: An Overview of Computers and Programming Languages
Engineering Problem Solving With C An Object Based Approach
Topics Introduction Hardware and Software How Computers Store Data
Chapter 1: An Overview of Computers and Programming Languages
BASIC PROGRAMMING C SCP1103 (02)
Overview of Computers and Programming Chapter 1
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
Computer System and Programming
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
IB Computer Science Topic 2.1.1
UNIV 103 CS Majors Seminar Dr. Blaise W. Liffick Fall 2017.
Computer Science I CSC 135.
Computers: Hardware and Software
Topics Introduction Hardware and Software How Computers Store Data
Introduction to Computer Programming
CS 330 Programming Languages
ICS103 Programming in C 1: Overview of Computers And Programming
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Professor John CarelliKutztown University Computer Science Department Computer Science I CSC 135

Professor John CarelliKutztown University Computer Science Department Introduction to Computer Science What’s a computer? A device that simplifies the tasks of: Performing difficult mathematical calculations Making decisions (conditional logic) Computers have become ubiquitous Business, personal, entertainment, … Desktop, laptop, tablets, phones, calculators, as well as built into other devices

Professor John CarelliKutztown University Computer Science Department Early Computing Mechanical Devices Abacus, adding machines Difference Engine, Analytical Engine (Charles Babbage, 1820’s) Contained many of the features of modern computers Electrical/Electromechanical Devices Z1 (Konrad Zuse, 1937) – electromechanical (binary) ABC (Atanasoff Berry Computer, 1937), Iowa State, vacuum tube Eniac (Eckert, Mauchley, von Neumann, 1940’s), UPenn, vacuum tube

Professor John CarelliKutztown University Computer Science Department Modern computer, basic architecture Inputs Keyboard, mouse,... Outputs Monitor, printer,... Secondary Storage Disk drive, USB stick,... (permanent/long term) * shared program/data memory (Von Neumann) InputsOutputs Central Processing Unit (CPU) Control Unit (CU) Arithmetic/Logic Unit (ALU) Internal Memory Registers Main Memory* Program Data Secondary Storage

Professor John CarelliKutztown University Computer Science Department H Modern Computer Hard Drive DRAM CPU

Professor John CarelliKutztown University Computer Science Department Modern computers use binary coding What is binary? Binary is base 2 coding (vs. Decimal, which is base 10) Base 10 has 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Base 2 has only 2 “bits”: 0, 1 Bits is short for “binary digits” All instructions, computations, and storage is in binary Why? Because it is easier to make circuits with 2 states rather than 10 Circuit only has to “off” for zero or “on” for one – basically, a switch! Works well with transistors (also with vacuum tubes or relays) Counting in Binary

Professor John CarelliKutztown University Computer Science Department Memory Used to store both data and programs Innovation generally attributed to John von Neumann “Programs” refers to either the operating system or user applications Volatile memory stored information is lost when power is shut off But – it can be made faster and denser, so… Used by the computer during normal operation RAM (random access memory) on the motherboard or in the microprocessor Non-volatile memory Used for long term storage Generally slower, but higher capacity Disk drives, CD/DVD, USB sticks, …

Professor John CarelliKutztown University Computer Science Department Memory Storage Every memory location has a numerical (binary) address Contents are coded and stored in binary format (ex: ascii) Organization Bit – one binary digit Byte – 8 bits Word – “N” bytes N=8 (bytes) on a 64 bit machine AddressContents (0) (5) (1) (3) (2) (J) (3) (=) (4) (a) (5) (7) (6) (C) (7) (9) (8) (#) … Byte Word Bit

Professor John CarelliKutztown University Computer Science Department Basic Operation of a Computer Both programs and data are stored in memory CPU performs operations on data according to program instructions CPU retrieves instructions and data from memory Operations have binary codes called machine language Operations are things like: Add two numbers together Move data from one memory location to another etc. … using special internal registers Instruction register contains currently executing instruction Program counter holds memory address of next instruction Steps through the program

Professor John CarelliKutztown University Computer Science Department Assembly Language * From Problem Solving, Abstraction, and Design using C++ (Pearson Addison-Wesley) Assembly Language maps binary code to simple, intuitive, mnemonics But! – like machine language, it’s still dependent on specific machine/processor/CPU architecture Program Counter steps through program instructions (using a “clock”)

Professor John CarelliKutztown University Computer Science Department High Level Languages Issues with Assembly Language Machine dependent Low level (many steps to accomplish simple tasks) Arcane Led to development of higher level languages C, C++, FORTRAN, Basic, Java, … Portable (same on any machine architecture) User friendly, intuitive -> A=A+B But, needs to be translated (compiled) into machine code Used extensively for application software development

Professor John CarelliKutztown University Computer Science Department Operating Systems Designed for high level operation – two primary goals… Handles general computer management tasks Resource allocation (use of memory, CPU, …) Implements a file system and manages secondary storage (disks) Provides a friendly interface for human interaction Command based or Graphical User Interface (GUI) Communication via keyboard, mouse, monitor, etc. OS must be “booted-up” to start operation Examples Windows, Mac OS, Android, Unix/Linux, …

Professor John CarelliKutztown University Computer Science Department Operating Systems, Windows and Unix Microsoft™ Windows Standard OS for PC’s GUI based, (originally built on DOS) Unix (used in this course) Command based Originally developed at Bell Labs™, written in C Used extensively in science, engineering, networking Linux is a PC based variant

Professor John CarelliKutztown University Computer Science Department User Interaction Built-in OS programs Allow a user to perform useful tasks like: Open, save, move, copy a file Print information Application programs Special programs installed on the computer to accomplish specific tasks Examples: Word processors, spreadsheets, presentations Design/illustration programs Internet access Developed independently (not part of OS)

Professor John CarelliKutztown University Computer Science Department Programming on a modern computer Analyze the task/problem, develop a strategy to address it Translate the strategy into an algorithm (recipe) Write the program Using the computer resources including OS and programming aids (IDE or simple text editor) Use a high-level language like C or C++ C++ is an “object oriented” programming language C is a “procedural” programming language for “structured” programming Test/run the program

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Object Oriented Programming C++ derived from C by Bjarne Stroustrup Popular because of reuse –Classes –Objects –Methods Organized in a Hierarchy –Super Classes –Sub Classes 16

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 17

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Object Oriented Design Abstraction –Extract the relevant properties of an object while ignoring inessential details Encapsulation –Breaking down an object into parts, hiding and protecting its essential information, and supplying an interface to modify the information in a controlled and useful manner 18

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1.4 Processing a High-Level Language Program Set of programs used to develop software A key component is a translator –Compiler Examples –g++, Borland C++ ®, Microsoft Visual C++ ® Other programs needed –Editor –Linker –Loader 19

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Processing a Program Editor used to enter the program –Like minimal word processor –Creates source program file Compiler translates the source program –Displays syntax errors –Creates (usually) temporary object code file Linker/Loader to combine object file with other object files and execute program –Creates final executable program 20

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Executing a Program CPU –examines each program instruction in memory –sends out command signals required to carry out the instruction Special instructions used to –input data into memory for the program to use –output data to display or printer (or other device) 21

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Figure 1.11 Entering, Translating, and Running a High-Level Language Program 1-22

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Figure 1.12 Flow of Information During Program Execution 1-23

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1.5 Software Development Method Problem Analysis –Identify data objects –Determine Input / Output data –Constraints on the problem Design –Decompose into smaller problems –Top-down design (divide and conquer) –Develop Algorithm (Desk check) Algorithm refinement 24

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Software Development Method Implementation –Converting the algorithm into programming language Testing –Verify the program meets requirements –System and Unit test Maintenance –All programs undergo change over time 25

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1.6 Applying the Software Development Method Case Study: Converting Miles to Kilometers –Problem Your summer surveying job requires you to study some maps that give distances in kilometers and some that use miles. You and your coworkers prefer to deal in metric measurements. Write a program that performs the necessary conversion. 26

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Case Study –Analysis The first step in solving this problem is to determine what you are asked to do. You must convert from one system of measurement to another, but are you supposed to convert from kilometers to miles, or vice versa? The problem states that you prefer to deal in metric measurements, so you must convert distance measurements in miles to kilometers. 27

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Data Requirements Problem Input milesdistance in miles Problem Output kmsthe distance in kilometers Relevant Formula 1 mile = kilometers 28

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Design Formulate the algorithm that solves the problem. Algorithm 1. Get the distance in miles. 2. Convert the distance to kilometers. 3. Display the distance in kilometers. Algorithm Refinement 2.1 The distance in kilometers is the distance in miles Desk check! 29

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Listing 1.2 Miles to kilometers 30

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Implementation #include using namespace std; int main( ) { const float KM_PER_MILE = 1.609; float miles, kms; cout << “Enter the distance in miles: “; cin >> miles; kms = KM_PER_MILE * miles; cout << “The distance in kilometers is “ << kms << endl; return 0; } 31

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Testing Test with input data for which you can easily determine the expected results E.g. 10 miles should convert to kilometers 32

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1.7 Professional Ethics for Computer Programmers Privacy and Misuse of Data Computer Hacking Plagiarism and Software Piracy Misuse of a Computer Resource 33