starting with scratch

Upload: ashvini-kumar

Post on 01-Mar-2016

225 views

Category:

Documents


0 download

DESCRIPTION

fd ghgd d

TRANSCRIPT

  • zThis is CS 50.

    COMPUTER SCIENCE 50Harvard Colleges Introduction to Computer Science I

    1

    DAVID J. MALAN [email protected]

    WEEK 0

  • z

    2

    Algorithms1 let socks_on_feet = 02 while socks_on_feet != 23 open sock drawer4 look for sock5 if you find a sock then6 put on sock7 socks_on_feet++8 look for matching sock9 if you find a matching sock then10 put on matching sock11 socks_on_feet++12 close sock drawer13 else14 remove first sock from foot15 socks_on_feet--16 else17 do laundry and replenish sock drawer

  • z

    3

    #include

    intmain(int argc, char *argv[]){ printf("O hai, world!\n");}

    O hai, C!hai.c

  • z

    4

    O hai, C!

    10000011 00000001 00010001 00000000 00111101 11111100 01110100 0011110100000000 01000000 00000000 00000000 00000000 00000000 00000000 0000000010010000 00000000 00000000 00000000 01010000 00000000 00000111 0011000000001011 00000001 00001011 00000011 00001010 00000000 00000000 0000000000000000 00100000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00100000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000001110000 00010000 00000000 00100000 00000001 00000000 00000000 0000000000000000 00000000 00000000 00100000 00000001 00000000 00000000 0000000000000000 00000000 00000000 01000000 00000001 00000000 00000000 0000000000000000 00100000 00000000 01000000 00000001 00000000 00000000 0000000011111111 11111111 11111111 11111111 11111111 11111111 11111111 1111111110010000 10000000 00000000 01000000 00000001 00000000 00000000 0000000000101110 01100100 01111001 01101110 01100001 01101101 01101001 0110001110110000 00000100 00000000 00100000 00000001 00000000 00000000 0000000010110000 00000100 00000000 00100000 00000001 00000000 00000000 0000000010100000 00000001 00000000 00000000 00000000 00000000 00000000 0000000010110000 00000100 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00100000 00000000 00000000

    [...]

    #include

    intmain(int argc, char *argv[]){ printf("O hai, world!\n");}

  • z

    5

    O hai, Scratch!Hai1.sb

  • z

    6

    Statements

    ...

  • z

    7

    StatementsHai{2,3}.sb

  • z

    8

    Boolean Expressions

    ...

  • z

    9

    Conditions

    ...

  • z

    10

    ConditionsHai{4,5}.sb

  • z

    11

    Loops

  • z

    12

    LoopsHai{6,7,8}.sb

  • z

    13

    VariablesCount{1,2}.sb

  • z

    14

    Arrays

  • z

    15

    ArraysFruitcraftRPG.sb

  • z

    16

    ThreadsMove1.sb

  • z

    17

    ThreadsMove2.sb

  • z

    18

    ThreadsHai10.sb

  • z

    19

    ThreadsDavid.sb

  • z

    20

    EventsMarco.sb

  • z

    21

    Sensorssinger.sb, Masquerade.sb, davidwu.sb

  • z

    22

    OscartimeOscartime.sb

  • z

    23

    OscartimeDisplaying the instructions

  • z

    24

    OscartimeMaking trash fall

  • z

    25

    OscartimeImplementing dragging

  • z

    26

    OscartimeImposing a time limit

  • z

    27

    OscartimeKeeping score

  • z

    28

    OscartimeRaising Oscars lid

  • z

    29

    intmain(int argc, char * argv[]){ printf("O hai, world!\n");}

    Scratch Meets C

  • z

    30

    printf("O hai, world!\n");

    StatementsScratch v. C

  • z

    31

    (x < y)((x < y) && (y < z))

    Boolean ExpressionsScratch v. C

  • z

    32

    if (x < y){ printf("x is less than y\n");}else if (x > y){ printf("x is greater than y\n"); }else{ printf("x is equal to y\n");}

    ConditionsScratch v. C

  • z

    33

    while (1){ printf("O hai!\n");}

    for (int i = 0; i < 10; i++){ printf("O hai!\n");}

    LoopsScratch v. C

  • z

    34

    int counter = 0;while (1){ printf("%d\n", counter); counter++;}

    VariablesScratch v. C

  • z

    35

    char *inventory[SIZE];inventory[i] = "Orange";

    ArraysScratch v. C

  • 36

    kthxbai