Download
cps118 n.
Skip this Video
Loading SlideShow in 5 Seconds..
Lesson 1b: Computer Systems and Program Development PowerPoint Presentation
Download Presentation
Lesson 1b: Computer Systems and Program Development

Lesson 1b: Computer Systems and Program Development

344 Vues Download Presentation
Télécharger la présentation

Lesson 1b: Computer Systems and Program Development

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. CPS118 Lesson 1b: Computer Systems and Program Development

  2. Objectives • What Is a Computer? • What is an algorithm? • Computer Components • Binary number system • Software Development Method • problem solving

  3. Computer Systems • Computers are electronic systems that can transmit, store and manipulate information (data). • Data can be numeric, character, graphic and sound. • For beginner programmers, the two most important are character and numeric. • To manipulate data, a computer needs a set of instructions called a program. • To write such programs is the object of this course.

  4. Computer • An electronic machine that can receive, store, transform, and output data of all kinds numbers, text, images, graphics, and sound, to name a few.

  5. Algorithms • An algorithm is a series of instructions on how to solve the problem. • An algorithm is a finite set of instructions which, if followed, accomplish a particular task. • Computing definition: • A computable set of steps to achieve a desired result.

  6. Characteristics of algorithms • Algorithms have the following characteristics: • Precision • Uniqueness • Finiteness • Input • Output • Generality

  7. Criteria of algorithm • must satisfy the following: • input: • there are 0 or more quantities which are externally supplied; • output: • at least one quantity is produced; • definiteness: • each instruction must be clear and unambiguous; • finiteness: • for all cases the algorithm will terminate after a finite number of steps; • effectiveness: • every instruction must be sufficiently basic • it can in principle be carried out by a person using only pencil and paper.

  8. A friend come to visit you: • The taxi algorithm: • Go to the taxi stand. • Get in a taxi. • Give the driver my address. • The call-me algorithm: • When your plane arrives, call my cell phone. • Meet me outside baggage claim. • The rent-a-car algorithm: • Take the shuttle to the rental car place. • Rent a car. • Follow the directions to get to my house. • The bus algorithm: • Outside baggage claim, catch bus number 70. • Transfer to bus 14 on Main Street. • Get off on Elm street. • Walk two blocks north to my house.

  9. Algorithm Example • Input (what is needed by the program): n • Output (the value computed by the program): 1/1+1/2+...+1/n • 1. answer=0 (initialize the answer at 0) • 2. d=1 (start the denominator at 1) • 3. answer=answer+1/d (adding 1/d to the previous answer) • 4. d=d+1 (adding 1 to the denominator) • 5. repeat lines 3 and 4 until d is equal to n

  10. Computer Systems 3 types of computer systems: • Mainframes and minicomputers • Workstations • Personal computers • PCs • Laptops

  11. Components of a Computer

  12. Input & Output Devices Secondary Storage: monitor CD Central Processing Unit printer ALU CU zip disk scanner floppy disk keyboard Main Memory hard disk mouse Computer Components

  13. I/O 1 I/O 2 I/O n Bus CPU Memory Sec. Storage Computer System • CPU + Main Memory ~ “core” • Secondary Storage + I/O Devices ~ “peripherals” • Bus ~ communication between components

  14. Storage Types CPU Registers: Only a few cells on CPU Main memory (RAM): Millions of cells on circuits separate from CPU. Secondary storage: Billions of cells on disks or tapes. Secondary storage is not volatile.

  15. Internal representations Bit: Binary digit (0 or 1). Byte: A group of 8 bits. One character. Word: The width of a memory cell. Each byte of main memory has an address. All numbers are represented in binary.

  16. Integer numbers • NOTE: The following number representations are simplified. They do not represent the actual pattern inside most computers. All numbers are converted in binary: ex: 9 = 1001 In a computer system, the leftmost bit is the sign bit (0 is positive, 1 is negative). So 9 in a 32 bit system would be: 00000000000000000000000000001001

  17. Real numbers Real numbers in binary are expressed with a mantissa, a base and an exponent. For a real number , the mantissa is defined as the positivefractional part Suppose 9.0 in binary: In 32 bits a simple view is bit sign=0 base and exponent=16 (base=2, exponent=4). mantissa=9/16=0.5625 for 32 bit float number (8: exp, 23 mantissa): 0 00000100 10010000000000000000000

  18. 32 bit real number • 1: 0 00000001 10000000000000000000000 • 2: 0 00000010 10000000000000000000000 • 3: 0 00000010 11000000000000000000000 • 4: 0 00000011 10000000000000000000000 • 5: 0 00000011 10100000000000000000000 • 6: 0 00000011 11000000000000000000000 • 7: 0 00000011 11100000000000000000000 • 8: 0 00000100 10000000000000000000000 • 9: 0 00000100 10010000000000000000000

  19. 32 bit real number cont’d • 10:000000100 10100000000000000000000 • 11:0 0000010010110000000000000000000 • 12:0 0000010011000000000000000000000 • 13:0 0000010011010000000000000000000 • 14:0 0000010011100000000000000000000 • 15:0 0000010011110000000000000000000 • 16:0 000010001000000000000000000000

  20. Real numbers A double number is expressed in 64 bits: 52 bits for the mantissa, 11 bits for the exponent and 1 sign bit. Exponent: right to left, like an integer. Mantissa: left to right, 0.5, 0.25, 0.125, 0.0625,... and so on. 1 if needed, 0 if not. So 9.0 is: • 0000000001001001000000000000000000000000000000000000000000000000

  21. Characters Characters are expressed using the ASCII code: A = 65 = 01000001 g = 103 = 01100111 $ = 36 = 00100100 + = 43 = 00101011 See code here: http://www.asciitable.com/

  22. Programming Languages Generation 1: Machine languages (pure binary) 101011101010101010111010101011 Generation 2: Assembly languages (mnemonic codes) MV R1,R3 Generation 3: High-Level Languages (C, Fortran, Java)

  23. Solving Problems 1. Define the problem 2. Analyse the problem. 3. Design a solution. 4. Implement the solution. 5. Test the program. 6. Update and maintain the program.

  24. Implementation Here is a detail of step #4, implementation (actual programming): 4.1 Write the program source. 4.2 Compile the source code and check for errors. 4.3 Link the code with libraries and build the program. 4.4 Run the program.

  25. Why C? 1. It is portable. 2. It is efficient. 3. It is easy to learn. 4. It is modular. 5. It is widespread.

  26. Summary • Computer • algorithm • Computer Components • Binary number system • Software Development Method • problem solving

  27. End of lesson