Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Professor John CarelliKutztown University Computer Science Department Computer Science I CSC 135."— Presentation transcript:

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

2 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

3 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

4 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

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

6 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 00 11 210 311 4100 5101 6110 7111 81000 91001 101010

7 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, …

8 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 00000000 (0)00000101 (5) 00000001 (1)00000011 (3) 00000010 (2)01110100 (J) 00000011 (3)00111101 (=) 00000100 (4)10010111 (a) 00000101 (5)00000111 (7) 00000110 (6)01100111 (C) 00000111 (7)00001001 (9) 00001000 (8)00110101 (#) 00101101 … 10110110 Byte Word Bit

9 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

10 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”)

11 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

12 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, …

13 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

14 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)

15 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

16 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

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

18 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

19 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

20 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

21 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

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

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

24 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

25 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

26 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

27 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

28 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 = 1.609 kilometers 28

29 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 1.609 the distance in miles Desk check! 29

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

31 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

32 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 16.09 kilometers 32

33 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


Download ppt "Professor John CarelliKutztown University Computer Science Department Computer Science I CSC 135."

Similar presentations


Ads by Google