Professional Documents
Culture Documents
How do we communication
CS 50 Binary System
4 2 1
0 0 0
1 = yes electricity
0 = no electricity
0 = 000
1 = 010
010 = 2 (2 + 0)
011 = 3 (2+1)
100 = 4 (4+0+0)
111 = 7 (4+2+1)
1000 = 8
1 byte = 8 bit
bit bit bit bit bit bit bit bit
128 64 32 16 8 4 2 1
50 = 32+16+2 = 00110010
13 = 8+4+1 = 00001101
65 = 64 + 1 = 01000001
ASCII
“Just a fancy way of saying that”
H I !
72 73 33
RGB
How much Red, Green, Blue to use
72 73 33 = a shade of yellow
(instead of hi!)
Input = digits
Pseudo Code
1 Pick up phone book
2 Open to the middle of phone book
3 Look at the page
4 If Smith is on page
5 Call Mike
6Else if Smith is earlier in book
7 Open to the middle of the left half of the book
8 Go back to line 3
9 Else if Smith is later in book
10 Open to the middle of the left half of the book
11 Go back to line 3
12 Else
13 Quit
Scratch.mit.lab.edu
Better design:
Defining a function:
Week 1
Name this hello.c
Where to find the blocks (function)? #include <stdio.h>
When flag clicked int main(void)
Say Hello {printf(“hello\n”);
}
Commands:
ls list out files in directory, and see which one can be executed e.g.
rm remove files in directory e.g. rm a.out
“-l” = link, cs50 = name of the directory to get the functions “string”
“combine my code and CS50’s code into a piece of programme that can run”
“Make” = a programme that comes with mac, windows, linux, unix, etc.
Summary
Make = convert to machine code
./ = run