Computing Technology
reading levels
One fish. Two fish. Red fish. Blue fish.
Before Grade 1
Congratulations! Today is your day. You're off to Great
Places! You're off and away!
Grade 3
It was a bright cold day in April, and the clocks were
striking thirteen. Winston Smith, his chin nuzzled into his
breast in an effort to escape the vile wind, slipped quickly
through the glass doors of Victory Mansions, though not
quickly enough to prevent a swirl of gritty dust from
entering along with him.
Grade 10
reading levels
cryptography
U I J T J T D T 5 0
T H I S I S C S 5 0
source code → compiler → machine code
#include <stdio.h>
int main(void)
{
printf("hello, world\
n");
}
01000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000
11010000 00010011 00000000 00000000 00000000 00000000 00000000
00000000
00000000 00000000 00000000 00000000 01000000 00000000 00111000
00000000
00001001 00000000 01000000 00000000 00100100 00000000 00100001
00000000
00000110 00000000 00000000 00000000 00000101 00000000 00000000
00000000
01000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000
01000000 00000000 01000000 00000000 00000000 00000000 00000000
00000000
01000000 00000000 01000000 00000000 00000000 00000000 00000000
00000000
11111000 00000001 00000000 00000000 00000000 00000000 00000000
00000000
11111000 00000001 00000000 00000000 00000000 00000000 00000000
make hello
./hello
clang hello.c
./a.out
clang -o hello hello.c
./hello
#include <stdio.h>
int main(void)
{
printf("hello, world\n");
}
#include <cs50.h>
#include <stdio.h>
int main(void)
{
string name = get_string("What's your name? ");
printf("hello, %s\n", name);
}
clang -o hello hello.c -lcs50
./hello
make hello
./hello
compiling
preprocessing
compiling
assembling
linking
preprocessing
compiling
assembling
linking
#include <stdio.h>
void meow(void);
int main(void)
{
for (int i = 0; i < 3; i++)
{
meow();
}
}
void meow(void)
{
printf("meow\n");
}
#include <stdio.h>
void meow(void);
int main(void)
{
for (int i = 0; i < 3; i++)
{
meow();
}
}
void meow(void)
{
printf("meow\n");
}
#include <cs50.h>
#include <stdio.h>
int main(void)
{
string name = get_string("What's your name? ");
printf("hello, %s\n", name);
}
#include <cs50.h>
#include <stdio.h>
int main(void)
{
string name = get_string("What's your name? ");
printf("hello, %s\n", name);
}
string get_string(string prompt);
#include <stdio.h>
int main(void)
{
string name = get_string("What's your name? ");
printf("hello, %s\n", name);
}
string get_string(string prompt);
#include <stdio.h>
int main(void)
{
string name = get_string("What's your name? ");
printf("hello, %s\n", name);
}
string get_string(string prompt);
int printf(string format, ...);
int main(void)
{
string name = get_string("What's your name? ");
printf("hello, %s\n", name);
}
preprocessing
compiling
assembling
linking
string get_string(string prompt);
int printf(string format, ...);
int main(void)
{
string name = get_string("What's your name? ");
printf("hello, %s\n", name);
}
...
main: # @main
.cfi_startproc
# BB#0:
pushq %rbp
.Ltmp0:
.cfi_def_cfa_offset 16
.Ltmp1:
.cfi_offset %rbp, -16
movq %rsp, %rbp
.Ltmp2:
.cfi_def_cfa_register %rbp
subq $16, %rsp
xorl %eax, %eax
movl %eax, %edi
movabsq $.L.str, %rsi
movb $0, %al
callq get_string
movabsq $.L.str.1, %rdi
movq %rax, -8(%rbp)
movq -8(%rbp), %rsi
movb $0, %al
callq printf
...
...
main: # @main
.cfi_startproc
# BB#0:
pushq %rbp
.Ltmp0:
.cfi_def_cfa_offset 16
.Ltmp1:
.cfi_offset %rbp, -16
movq %rsp, %rbp
.Ltmp2:
.cfi_def_cfa_register %rbp
subq $16, %rsp
xorl %eax, %eax
movl %eax, %edi
movabsq $.L.str, %rsi
movb $0, %al
callq get_string
movabsq $.L.str.1, %rdi
movq %rax, -8(%rbp)
movq -8(%rbp), %rsi
movb $0, %al
callq printf
...
...
main: # @main
.cfi_startproc
# BB#0:
pushq %rbp
.Ltmp0:
.cfi_def_cfa_offset 16
.Ltmp1:
.cfi_offset %rbp, -16
movq %rsp, %rbp
.Ltmp2:
.cfi_def_cfa_register %rbp
subq $16, %rsp
xorl %eax, %eax
movl %eax, %edi
movabsq $.L.str, %rsi
movb $0, %al
callq get_string
movabsq $.L.str.1, %rdi
movq %rax, -8(%rbp)
movq -8(%rbp), %rsi
movb $0, %al
callq printf
...
preprocessing
compiling
assembling
linking
...
main: # @main
.cfi_startproc
# BB#0:
pushq %rbp
.Ltmp0:
.cfi_def_cfa_offset 16
.Ltmp1:
.cfi_offset %rbp, -16
movq %rsp, %rbp
.Ltmp2:
.cfi_def_cfa_register %rbp
subq $16, %rsp
xorl %eax, %eax
movl %eax, %edi
movabsq $.L.str, %rsi
movb $0, %al
callq get_string
movabsq $.L.str.1, %rdi
movq %rax, -8(%rbp)
movq -8(%rbp), %rsi
movb $0, %al
callq printf
...
00000000000000000000000000000
000
00000000000000000000000000000
000
00000000000000000000000000000
000
00000000000000000000000000000
000
10100000000000100000000000000
000
00000000000000000000000000000
000
00000000000000000000000000000
000
01000000000000000000000000000
000
00000000000000000100000000000
000
00001010000000000000000100000
000
01010101010010001000100111100
101
01001000100000111110110000010
000
00110001110000001000100111000
111
01001000101111100000000000000
000
preprocessing
compiling
assembling
linking
#include <cs50.h>
#include <stdio.h>
int main(void)
{
string name = get_string("What's your name? ");
printf("hello, %s\n", name);
}
hello.c
hello.c cs50.c
hello.c cs50.c stdio.c
00000000000000000000000000000
000
00000000000000000000000000000
000
00000000000000000000000000000
000
00000000000000000000000000000
000
10100000000000100000000000000
000
00000000000000000000000000000
000
00000000000000000000000000000
000
01000000000000000000000000000 cs50.c stdio.c
000
00000000000000000100000000000
000
00001010000000000000000100000
000
01010101010010001000100111100
101
01001000100000111110110000010
000
00110001110000001000100111000
111
01001000101111100000000000000
000
00000000000000000000000000000 11000000000011110000000000000
000 000
00000000000000000000000000000 00000000000000000000000000000
000 000
00000000000000000000000000000 01000000000000000000000000000
000 000
00000000000000000000000000000 00000000000000000000000000000
000 000
10100000000000100000000000000 00101000001100100000000000000
000 000
00000000000000000000000000000 00000000000000000000000000000
000 000
00000000000000000000000000000 00000000000000000000000000000
000 000
01000000000000000000000000000 01000000000000000011100000000 stdio.c
000 000
00000000000000000100000000000 00000111000000000100000000000
000 000
00001010000000000000000100000 00011100000000000001100100000
000 000
01010101010010001000100111100 00000001000000000000000000000
101 000
01001000100000111110110000010 00000101000000000000000000000
000 000
00110001110000001000100111000 00000000000000000000000000000
111 000
01001000101111100000000000000 00000000000000000000000000000
000 000
00000000000000000000000000000 11000000000011110000000000000 00110110001101000010110101101
000 000 100
00000000000000000000000000000 00000000000000000000000000000 01101001011011100111010101111
000 000 000
00000000000000000000000000000 01000000000000000000000000000 00101101011001110110111001110
000 000 101
00000000000000000000000000000 00000000000000000000000000000 00101111011011000110100101100
000 000 010
10100000000000100000000000000 00101000001100100000000000000 01100011010111110110111001101
000 000 111
00000000000000000000000000000 00000000000000000000000000000 01101110011100110110100001100
000 000 001
00000000000000000000000000000 00000000000000000000000000000 01110010011001010110010000101
000 000 110
01000000000000000000000000000 01000000000000000011100000000 01100001001000000010000001000
000 000 001
00000000000000000100000000000 00000111000000000100000000000 01010011010111110100111001000
000 000 101
00001010000000000000000100000 00011100000000000001100100000 01000101010001000100010101000
000 000 100
01010101010010001000100111100 00000001000000000000000000000 00100000001010000010000000101
101 000 111
01001000100000111110110000010 00000101000000000000000000000 01101100011010010110001000101
000 000 111
00110001110000001000100111000 00000000000000000000000000000 01111000001110000011011001011
111 000 111
01001000101111100000000000000 00000000000000000000000000000 00110110001101000010110101101
000 000 100
011111110100010101001100010001100000001000000001000000010000000000000000000000000000000000000
000000000000000000000000000000000000000000100000000001111100000000000000001000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000001010000000000010000000000000000000000000000000000000
000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000
100000000000000000010100000000000000001000000000101010101001000100010011110010101001000100000
111110110000010000001100011100000010001001110001110100100010111110000000000000000000000000000
000000000000000000000000000000000000010110000000000001110100000000000000000000000000000000000
0100100010111111000000000000000000000000000000000000000000000000000000000000000001001000...01
111111010001010100110001000110000000100000000100000001000000000000000000000000000000000000000
000000000000000000000000000000000000000110000000000111110000000000000000100000000000000000000
000011000000000011110000000000000000000000000000000000000000000000000100000000000000000000000
000000000000000000000000000000000000000001010000011001000000000000000000000000000000000000000
000000000000000000000000000000000000000000010000000000000000111000000000000000011100000000010
000000000000000011100000000000001100100000000000000010000000000000000000000000000010100000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000101110000100101000000000000000000000000000000000000000000000000...0010
111101101100011010010110001001100011001011100111001101101111001011100011011000100000001011110
111010101110011011100100010111101101100011010010110001000101111011110000011100000110110010111
110011011000110100001011010110110001101001011011100111010101111000001011010110011101101110011
101010010111101101100011010010110001001100011010111110110111001101111011011100111001101101000
011000010111001001100101011001000010111001100001001000000010000001000001010100110101111101001
110010001010100010101000100010001010100010000100000001010000010000000101111011011000110100101
100010001011110111100000111000001101100101111100110110001101000010110101101100011010010110111
001110101011110000010110101100111011011100111010100101111011011000110010000101101011011000110
100101101110011101010111100000101101011110000011100000110110001011010011011000110100...
preprocessing
compiling
assembling
linking
compiling
decompiling
reverse engineering
011111110100010101001100010001100000001000000001000000010000000000000000000000000000000000000
000000000000000000000000000000000000000000100000000001111100000000000000001000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000001010000000000010000000000000000000000000000000000000
000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000
100000000000000000010100000000000000001000000000101010101001000100010011110010101001000100000
111110110000010000001100011100000010001001110001110100100010111110000000000000000000000000000
000000000000000000000000000000000000010110000000000001110100000000000000000000000000000000000
0100100010111111000000000000000000000000000000000000000000000000000000000000000001001000...01
111111010001010100110001000110000000100000000100000001000000000000000000000000000000000000000
000000000000000000000000000000000000000110000000000111110000000000000000100000000000000000000
000011000000000011110000000000000000000000000000000000000000000000000100000000000000000000000
000000000000000000000000000000000000000001010000011001000000000000000000000000000000000000000
000000000000000000000000000000000000000000010000000000000000111000000000000000011100000000010
000000000000000011100000000000001100100000000000000010000000000000000000000000000010100000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000101110000100101000000000000000000000000000000000000000000000000...0010
111101101100011010010110001001100011001011100111001101101111001011100011011000100000001011110
111010101110011011100100010111101101100011010010110001000101111011110000011100000110110010111
110011011000110100001011010110110001101001011011100111010101111000001011010110011101101110011
101010010111101101100011010010110001001100011010111110110111001101111011011100111001101101000
011000010111001001100101011001000010111001100001001000000010000001000001010100110101111101001
110010001010100010101000100010001010100010000100000001010000010000000101111011011000110100101
100010001011110111100000111000001101100101111100110110001101000010110101101100011010010110111
001110101011110000010110101100111011011100111010100101111011011000110010000101101011011000110
100101101110011101010111100000101101011110000011100000110110001011010011011000110100...
debugging
CS50 Duck
cs50.ai
printf
printf
debug50
printf
debug50
rubber duck
types
bool
int
long
float
double
char
string
...
bool 1 byte
int 4 bytes
long 8 bytes
float 4 bytes
double 8 bytes
char 1 byte
string ? bytes
...
int score1 = 72;
int score2 = 73;
int score3 = 33;
72
score1
72 73
score1 score2
72 73
score1 score2
33
score3
000000000000000000000000010010 000000000000000000000000010010
00 01
score1 score2
000000000000000000000000001000
01
score3
int score1 = 72;
int score2 = 73;
int score3 = 33;
arrays
int scores[3];
int scores[3];
scores[0] = 72;
scores[1] = 73;
scores[2] = 33;
72 73
scores[0] scores[1]
33
scores[2]
char c1 = 'H';
char c2 = 'I';
char c3 = '!';
H I !
c1 c2 c3
72 73 33
c1 c2 c3
0100100 0100100 0010000
0 1 1
c1 c2 c3
string
string s = "HI!";
H I !
s
H I !
s[0] s[1] s[2]
0000000
H I ! 0
s[0] s[1] s[2] s[3]
H I ! 0
s[0] s[1] s[2] s[3]
H I ! \0 s[3]
s[0] s[1] s[2]
72 73 33 0 s[3]
s[0] s[1] s[2]
H I ! \0
s
NUL
string s = "HI!";
string t = "BYE!";
H I ! \0
s
H I ! \0 B Y E !
s t
\0
H I ! \0 B Y E !
s[0] s[1] s[2] s[3] t[0] t[1] t[2] t[3]
\0
t[4]
string words[2];
words[0] = "HI!";
words[1] = "BYE!";
H I ! \0 B Y E !
words[0] words[1]
\0
H
words[0]
I
words[0]
! \0 B
words[0] words[0] words[1]
Y
words[1]
E
words[1]
!
words[1]
[0] [1] [2] [3] [0] [1] [2] [3]
\0
words[1]
[4]
string
string.h
manual.cs50.io/#string.h
strlen
ctype.h
manual.cs50.io/#ctype.h
command-line arguments
#include <stdio.h>
int main(void)
{
...
}
#include <stdio.h>
int main(void)
{
...
}
#include <stdio.h>
int main(int argc, string argv[])
{
...
}
ASCII art
cowsay
exit status
#include <stdio.h>
int main(int argc, string argv[])
{
...
}
#include <stdio.h>
int main(int argc, string argv[])
{
...
}
#include <stdio.h>
int main(void)
{
...
}
echo $?
cryptography
encryption
input → → output
plaintext → → ciphertext
plaintext → cipher → ciphertext
key →
plaintext → cipher → ciphertext
1 →
HI! →
1 →
HI! → → IJ!
13 →
HI! → → UV!
13 →
I LOVE YOU → →V YBIR LBH
26 →
I LOVE YOU →
26 →
I LOVE YOU → →I LOVE YOU
decryption
-1 →
UIJT XBT GVO!
→
U I J T X B T G V O
!
T I J T X B T G V O
!
T H J T X B T G V O
!
T H I T X B T G V O
!
T H I S X B T G V O
!
T H I S W B T G V O
!
T H I S W A T G V O
!
T H I S W A S G V O
!
T H I S W A S F V O
!
T H I S W A S F U O
!
T H I S W A S F U N
!
Computing Technology