Top Banner
Computer programming {week 01} Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.
16

Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Dec 30, 2015

Download

Documents

Roberta Lyons
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Computer programming{week 01}

Hudson Valley Community CollegeCISS-110 – Programming & Logic IDavid Goldschmidt, Ph.D.

Page 2: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Computer subsystems

Hardware consists of five key subsystems:

from Fluency with Information Technology, 4th edition by Lawrence Snyder, Addison-Wesley, 2010, ISBN 0-13-609182-2

Page 3: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Fetch/Execute cycle

Each instruction goes through this cycle:

from Fluency with Information Technology, 4th edition by Lawrence Snyder, Addison-Wesley, 2010, ISBN 0-13-609182-2

Page 4: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Example ADD instruction (i)

from Fluency with Information Technology, 4th edition by Lawrence Snyder, Addison-Wesley, 2010, ISBN 0-13-609182-2

Page 5: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Example ADD instruction (ii)

from Fluency with Information Technology, 4th edition by Lawrence Snyder, Addison-Wesley, 2010, ISBN 0-13-609182-2

Page 6: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Example ADD instruction (iii)

from Fluency with Information Technology, 4th edition by Lawrence Snyder, Addison-Wesley, 2010, ISBN 0-13-609182-2

Page 7: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Example ADD instruction (iv)

from Fluency with Information Technology, 4th edition by Lawrence Snyder, Addison-Wesley, 2010, ISBN 0-13-609182-2

Page 8: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Example ADD instruction (v)

from Fluency with Information Technology, 4th edition by Lawrence Snyder, Addison-Wesley, 2010, ISBN 0-13-609182-2

Page 9: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Example ADD instruction (vi)

from Fluency with Information Technology, 4th edition by Lawrence Snyder, Addison-Wesley, 2010, ISBN 0-13-609182-2

Page 10: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Even faster!

from Fluency with Information Technology, 4th edition by Lawrence Snyder, Addison-Wesley, 2010, ISBN 0-13-609182-2

Page 11: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Counting

We use ten symbols to count Digits: 0 1 2 3 4 5 6 7 8 9

Computers use two symbols to count Digits: 0 1 (why?)

What is the exact mechanism for counting? How do we count from 1 to 20?

Page 12: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Convert binary to decimal

The powers of 2 give us the decimal weights Convert 10011001 from binary to decimal:

10011001 in decimal is 128 + 16 + 8 + 1 = 153

powers of 2 27 26 25 24 23 22 21 20

decimal weights

128

64 32 16 8 4 2 1

binary digits 1 0 0 1 1 0 0 1

Page 13: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Hexadecimal

Hexadecimal is base 16 It uses 16 digits: 0 1 2 3 4 5 6 7 8 9 A B C D E F

Why use hex? Binary numbers are too long

What’s 2BAD in decimal?

decimal

binary

hexadecimal

0 0000 0

1 0001 1

2 0010 2

3 0011 3

4 0100 4

5 0101 5

6 0110 6

7 0111 7

8 1000 8

9 1001 9

10 1010 A

11 1011 B

12 1100 C

13 1101 D

14 1110 E

15 1111 F

Page 14: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

ASCII

Representprintableand specialcharacters

What aboutUnicode?

from Fluency with Information Technology, 4th edition by Lawrence Snyder, Addison-Wesley, 2010, ISBN 0-13-609182-2

Page 15: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

Java compilation and execution

public static void main( String[] args ){ float x;

System.out. println( "

...

Java source code

7A 56 789F FE F265 58 9976 6D 4E

intermediate code(byte code)

translation program

(compiler)

virtual machine

(JVM)

A6 65 5498 8F ABAE 33 388F DA 44

intermediate code ofprecompiled libraries

(java.util.Scanner byte code)

program execution

Page 16: Hudson Valley Community College CISS-110 – Programming & Logic I David Goldschmidt, Ph.D.

What next?

Read and study Chapter 1 Get Textpad up and running

Do Project #1: Given a 3-digit number: Generate output that shows each digit:

int num = 582;

The number is 582The hundreds column is 5The tens column is 8The ones column is 2