1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
1
00:00:00,000 --> 00:00:01,500
>> [MUSIC PLAYING]

2
00:00:01,500 --> 00:00:11,000

3
00:00:11,000 --> 00:00:16,110
>> DAVID MALAN: All right this is CS50
and this is the end of week one.

4
00:00:16,110 --> 00:00:20,760
So I'd like to introduce my former
advisee, Andel Duff, who not only makes

5
00:00:20,760 --> 00:00:25,460
iPhone 5 stands, as well as this
lectern, he also makes cars.

6
00:00:25,460 --> 00:00:27,927

7
00:00:27,927 --> 00:00:29,510
ANSEL DUFF: How's it going, everybody?

8
00:00:29,510 --> 00:00:31,980
I just want to tell you a little
bit about Formula SAE, of which I

9
00:00:31,980 --> 00:00:32,604
am the captain.

10
00:00:32,604 --> 00:00:33,437
It's an MIT team.

11
00:00:33,437 --> 00:00:35,520
I just want to tell you
guys a little bit about it

12
00:00:35,520 --> 00:00:37,520
and hopefully generate some interest.

13
00:00:37,520 --> 00:00:41,590
>> So let me just run through a
couple things about our team.

14
00:00:41,590 --> 00:00:43,640
So we're completely
student run, wherein all

15
00:00:43,640 --> 00:00:47,300
of the members design, simulate,
test, and manufacturer a subsystem

16
00:00:47,300 --> 00:00:48,090
of the car.

17
00:00:48,090 --> 00:00:51,240
We have our own machine shop
and garages, and N52-- or sorry,

18
00:00:51,240 --> 00:00:54,140
N51-- which is the same building
as the MIT Science Museum.

19
00:00:54,140 --> 00:00:55,990
And we are the people
that drive the car.

20
00:00:55,990 --> 00:00:58,340
There's a national competition
in the beginning of the summer,

21
00:00:58,340 --> 00:01:01,215
and then there are smaller shootout
competitions throughout the year.

22
00:01:01,215 --> 00:01:04,400
And then we do driver training
days to get new members acquainted.

23
00:01:04,400 --> 00:01:08,280
>> Our build days are on
Saturdays from 11 AM to 8 PM.

24
00:01:08,280 --> 00:01:11,060
Lunch and dinner are taking care
of, from Bertucci's and Beantown

25
00:01:11,060 --> 00:01:12,130
respectively.

26
00:01:12,130 --> 00:01:15,260
We have a weekly meeting and
seminar, which is for course credit.

27
00:01:15,260 --> 00:01:18,560
Which is new as of this semester, and
it will also be for next semester,

28
00:01:18,560 --> 00:01:19,940
so you can cross-reg for that.

29
00:01:19,940 --> 00:01:22,960
And then we have designing, shop,
and CAD days during the week,

30
00:01:22,960 --> 00:01:26,870
whereas members will independently
CAD parts, order stock et cetera.

31
00:01:26,870 --> 00:01:29,200
>> So for electrical
engineering at the team

32
00:01:29,200 --> 00:01:31,110
we have our tractive,
high voltage system,

33
00:01:31,110 --> 00:01:33,390
which runs at a nominal
300 volts, which includes

34
00:01:33,390 --> 00:01:35,360
motors, motor controllers,
and battery packs.

35
00:01:35,360 --> 00:01:37,235
Then we have a low
voltage system, which runs

36
00:01:37,235 --> 00:01:40,180
at 12 volts, which includes
controls, CAN nodes, the brain

37
00:01:40,180 --> 00:01:41,570
box, and the dashboard.

38
00:01:41,570 --> 00:01:43,890
As far CS goes, we do
have website maintenance

39
00:01:43,890 --> 00:01:47,940
that we need done for events, membership
changes, new pictures, and PR material.

40
00:01:47,940 --> 00:01:51,540
And then we have code that controls the
car for our traction control, launch

41
00:01:51,540 --> 00:01:55,750
control, dash control, torque vectoring,
and regenerative braking systems, which

42
00:01:55,750 --> 00:01:59,170
run typically in MATLAB,
Simulink, and LabView.

43
00:01:59,170 --> 00:02:00,910
>> Tell you a little bit about the car.

44
00:02:00,910 --> 00:02:02,470
So it's about 500 pounds.

45
00:02:02,470 --> 00:02:04,285
It's rules limited to 85 kilowatts.

46
00:02:04,285 --> 00:02:08,310
It has 2 EMRAX 207 motors in the
back, one for each rear wheel.

47
00:02:08,310 --> 00:02:11,880
It has custom-built battery packs
from Prismatic A123 pouch cells,

48
00:02:11,880 --> 00:02:14,780
totaling 300 volts and
5.6 kilowatt hours.

49
00:02:14,780 --> 00:02:17,950
And it's direct drive with
a 2.64 to 1 drive ratio.

50
00:02:17,950 --> 00:02:20,970
Here are some pictures we
took of it at competition.

51
00:02:20,970 --> 00:02:25,820
Here's the back, nose cone,
and here are the motors,

52
00:02:25,820 --> 00:02:29,682
those big black disks
underneath the et mens manus.

53
00:02:29,682 --> 00:02:32,140
Here's a slide that I pulled
out of our competition scheme.

54
00:02:32,140 --> 00:02:35,389
And this is just comparing our car to a
couple of commercially available cars,

55
00:02:35,389 --> 00:02:38,380
like the KTM XBOW, Ariel
Atom, and Caterha M 7-280.

56
00:02:38,380 --> 00:02:42,110
If you're familiar with price, power
pull weight, dollars per horsepower,

57
00:02:42,110 --> 00:02:44,930
dollars per torque, and our car
blows them all out of the water.

58
00:02:44,930 --> 00:02:47,520
If you have any questions,
jot down this email address.

59
00:02:47,520 --> 00:02:50,800
Shoot us an email at fsae@mit.edu.

60
00:02:50,800 --> 00:02:53,350
>> We're happy to talk about
anything you'd like.

61
00:02:53,350 --> 00:02:55,600
Harvard students are kind
of the minority on the team.

62
00:02:55,600 --> 00:02:58,350
If you have any questions about
that please do shoot us an email,

63
00:02:58,350 --> 00:03:00,810
happy to talk, and I'm going
to head back over to David.

64
00:03:00,810 --> 00:03:01,550
Thanks.

65
00:03:01,550 --> 00:03:02,466
I appreciate it, guys.

66
00:03:02,466 --> 00:03:03,615
[APPLAUSE]

67
00:03:03,615 --> 00:03:07,080

68
00:03:07,080 --> 00:03:10,980
>> DAVID MALAN: Ansel spent the summer
working with us here on campus in CS50

69
00:03:10,980 --> 00:03:11,480
this summer.

70
00:03:11,480 --> 00:03:13,505
And in addition to working on
things like the binary bulbs,

71
00:03:13,505 --> 00:03:16,090
he actually really opened our
eyes-- and mine in particular--

72
00:03:16,090 --> 00:03:20,535
to what really the intersection of
not of hardware and software can be.

73
00:03:20,535 --> 00:03:23,410
In fact a lot of the things he just
toured you through are ultimately

74
00:03:23,410 --> 00:03:26,030
created first in software,
and then ultimately fabricated

75
00:03:26,030 --> 00:03:27,299
in the real world in hardware.

76
00:03:27,299 --> 00:03:29,590
So if you're interested in
exploring that intersection,

77
00:03:29,590 --> 00:03:31,430
perhaps take up that group.

78
00:03:31,430 --> 00:03:34,140
>> Now meanwhile, those of you
who are fans of technology,

79
00:03:34,140 --> 00:03:36,140
and Apple products in
particular know that there

80
00:03:36,140 --> 00:03:37,860
were a couple of
announcements yesterday.

81
00:03:37,860 --> 00:03:39,776
But we thought we'd show
you one that came out

82
00:03:39,776 --> 00:03:43,590
a few days prior that
you might not have seen.

83
00:03:43,590 --> 00:03:46,150
>> JORGEN EGHAMMER: You know,
once in awhile something

84
00:03:46,150 --> 00:03:49,540
comes along that
changes the way we live.

85
00:03:49,540 --> 00:03:53,479
A device so simple and intuitive
using it feels almost familiar.

86
00:03:53,479 --> 00:03:59,710

87
00:03:59,710 --> 00:04:04,138
Introducing 2015 IKEA catalogue.

88
00:04:04,138 --> 00:04:10,420
It's not a digital book or
an e-book, it's a book-book.

89
00:04:10,420 --> 00:04:14,440
>> The first thing to note is no
cables, not even a power cable.

90
00:04:14,440 --> 00:04:18,519
The 2015 IKEA catalogue
comes fully charged,

91
00:04:18,519 --> 00:04:20,550
and the battery life is eternal.

92
00:04:20,550 --> 00:04:27,300
The interface is 7.5 by 8 inches,
but can expand to 15 by 8 inches.

93
00:04:27,300 --> 00:04:32,410
The navigation is based on tactile touch
technology that you can actually feel.

94
00:04:32,410 --> 00:04:37,120
>> Content comes pre-installed
via 328 high-definition pages

95
00:04:37,120 --> 00:04:40,180
of inspiring home furnishing ideas.

96
00:04:40,180 --> 00:04:43,740
To start browsing,
simply touch and drag.

97
00:04:43,740 --> 00:04:50,870
Right to left to move forward,
left to right to move backwards.

98
00:04:50,870 --> 00:04:52,770
>> Notice something else?

99
00:04:52,770 --> 00:04:53,780
That's right.

100
00:04:53,780 --> 00:04:55,190
No lag.

101
00:04:55,190 --> 00:04:58,400
Each crystal clear page
loads instantaneously,

102
00:04:58,400 --> 00:05:00,586
no matter how fast you scroll.

103
00:05:00,586 --> 00:05:03,710
If you want to get a quick overview,
just hold it in the palm of your hand,

104
00:05:03,710 --> 00:05:06,816
and using just your thumb,
speed browse the content.

105
00:05:06,816 --> 00:05:10,930
>> If you find something you want to save
for later, you can simply bookmark it.

106
00:05:10,930 --> 00:05:17,620
And even if you close the application,
you can easily find the bookmark again.

107
00:05:17,620 --> 00:05:18,490
Amazing.

108
00:05:18,490 --> 00:05:20,434
>> [LAUGHTER]

109
00:05:20,434 --> 00:05:21,406
[APPLAUSE]

110
00:05:21,406 --> 00:05:26,760

111
00:05:26,760 --> 00:05:29,870
So that brings us to
the end of week one.

112
00:05:29,870 --> 00:05:31,760
A few announcements now.

113
00:05:31,760 --> 00:05:33,440
So sectioning is now in progress.

114
00:05:33,440 --> 00:05:36,860
Go to this URL here sometime
between now and Friday at noon

115
00:05:36,860 --> 00:05:39,960
to actually specify whether you are
among those less comfortable, more

116
00:05:39,960 --> 00:05:41,690
comfortable, or somewhere in between.

117
00:05:41,690 --> 00:05:44,511
>> This is typically one of those
things that you just kind of know.

118
00:05:44,511 --> 00:05:47,510
And in fact those of you who are less
comfortable probably know as much,

119
00:05:47,510 --> 00:05:49,634
those of you who are more
comfortable know as much,

120
00:05:49,634 --> 00:05:54,960
and again if you aren't quite sure which
of those buckets you fall into you're

121
00:05:54,960 --> 00:05:56,210
probably somewhere in between.

122
00:05:56,210 --> 00:05:59,810
But rest assured you can swap
after a couple of weeks if need be.

123
00:05:59,810 --> 00:06:02,620
>> Meanwhile, for the coming week
we don't start sections per se,

124
00:06:02,620 --> 00:06:04,760
but super sections, which
are open to all students.

125
00:06:04,760 --> 00:06:08,220
This coming Sunday at a location to
be announced on the course website

126
00:06:08,220 --> 00:06:10,190
we will have one for
those less comfortable,

127
00:06:10,190 --> 00:06:12,470
as well as one for
those more comfortable.

128
00:06:12,470 --> 00:06:15,460
And those somewhere in between
can choose which of those two,

129
00:06:15,460 --> 00:06:17,360
or both if you'd like, to sit-in on.

130
00:06:17,360 --> 00:06:19,630
And the focus of those
will be ultimately on C,

131
00:06:19,630 --> 00:06:22,440
which we'll continue our
conversation of today.

132
00:06:22,440 --> 00:06:25,070
>> Problem set 0 meanwhile is
hopefully in your hands.

133
00:06:25,070 --> 00:06:27,500
Officially due tomorrow,
Thursday, at noon.

134
00:06:27,500 --> 00:06:29,490
Unless you cash in one
of your 5 late days,

135
00:06:29,490 --> 00:06:31,780
which would bring it
until Friday at noon.

136
00:06:31,780 --> 00:06:34,420
Problem set 1 meanwhile will be
posted on the course's website.

137
00:06:34,420 --> 00:06:37,381
And this will be our first
foray as a class into C.

138
00:06:37,381 --> 00:06:40,630
And that problem set spec will walk you
through a lot of the mechanics of what

139
00:06:40,630 --> 00:06:43,960
we started talking about on Monday,
and we'll continue talking about today.

140
00:06:43,960 --> 00:06:46,770
C, Linux, the CS50
appliance, all of that

141
00:06:46,770 --> 00:06:48,990
will await you in the specification.

142
00:06:48,990 --> 00:06:52,840
>> Office hours meanwhile are in progress,
in the undergraduate dining hall.

143
00:06:52,840 --> 00:06:56,240
Head to this URL here to see the
schedule for tonight and tomorrow,

144
00:06:56,240 --> 00:06:57,930
if you would like to partake.

145
00:06:57,930 --> 00:07:01,920
Questions meanwhile, so that you
have opportunities to ask questions

146
00:07:01,920 --> 00:07:05,860
asynchronously, 24/7, realize you're
not limited to sections and office

147
00:07:05,860 --> 00:07:09,530
hours, but rather this tool
here, CS50 Discuss at that URL

148
00:07:09,530 --> 00:07:12,150
will be the course's online
bulletin board software, via which

149
00:07:12,150 --> 00:07:15,030
you can ask questions of
classmates and also staff.

150
00:07:15,030 --> 00:07:18,492
So keep in mind that resource as well.

151
00:07:18,492 --> 00:07:20,200
Meanwhile a tradition
starts this Friday.

152
00:07:20,200 --> 00:07:23,200
As you may have glimpsed from
last Wednesday's teaser video,

153
00:07:23,200 --> 00:07:25,510
we have a tradition most
every Friday during term

154
00:07:25,510 --> 00:07:28,750
of taking some 50 students and
staff to a local restaurant called

155
00:07:28,750 --> 00:07:31,510
Fire and Ice, at which we're
typically joined by some alumni

156
00:07:31,510 --> 00:07:33,850
or friends from industry
to generally aspire

157
00:07:33,850 --> 00:07:35,780
to make a large class feel smaller.

158
00:07:35,780 --> 00:07:37,560
So it's a completely casual lunch.

159
00:07:37,560 --> 00:07:40,160
A bunch of us, the staff
especially, will play musical chairs

160
00:07:40,160 --> 00:07:43,360
and chat with students about
50, life outside of 50,

161
00:07:43,360 --> 00:07:46,510
life in the future, the real world,
I'm talking about job opportunities

162
00:07:46,510 --> 00:07:47,680
with friends in industry.

163
00:07:47,680 --> 00:07:51,110
>> So if you would like to join us
this Friday, head to this URL here.

164
00:07:51,110 --> 00:07:54,180
Space is limited, but we'll do this
recurringly throughout the term.

165
00:07:54,180 --> 00:07:57,380
Head there to cs50.harvard.edu/rsvp.

166
00:07:57,380 --> 00:07:59,380
And if you don't get in
this time, not to worry.

167
00:07:59,380 --> 00:08:02,390
We will do it again in
the coming weeks as well.

168
00:08:02,390 --> 00:08:05,434
>> So this is the picture
we painted last week,

169
00:08:05,434 --> 00:08:07,350
and you've probably been
dabbling in thus far.

170
00:08:07,350 --> 00:08:10,360
But let's try to connect this now
to what we're going to do today

171
00:08:10,360 --> 00:08:11,440
and onward.

172
00:08:11,440 --> 00:08:14,760
Could I have one volunteer?

173
00:08:14,760 --> 00:08:16,000
All right, or several.

174
00:08:16,000 --> 00:08:18,460
How about here on the
end, in the blue shirt.

175
00:08:18,460 --> 00:08:20,329
Come on up, what's your name?

176
00:08:20,329 --> 00:08:20,870
ALANA: Alana.

177
00:08:20,870 --> 00:08:21,661
DAVID MALAN: Alana.

178
00:08:21,661 --> 00:08:25,100
So Alana, for just a
moment-- nice to meet you--

179
00:08:25,100 --> 00:08:28,260
is going to play the role
of this function here.

180
00:08:28,260 --> 00:08:31,290
The purple block we've
called thus far a function.

181
00:08:31,290 --> 00:08:34,830
So what I'm going to go
ahead here and offer Alana

182
00:08:34,830 --> 00:08:38,380
is a little name tag, to make
clear what role you're playing.

183
00:08:38,380 --> 00:08:39,753
>> So you shall be the say block.

184
00:08:39,753 --> 00:08:41,419
If you want to go ahead and put that on.

185
00:08:41,419 --> 00:08:43,169
And we're going to
keep this super simple.

186
00:08:43,169 --> 00:08:46,180
If the goal at hand is simply
now to implement with Alana,

187
00:08:46,180 --> 00:08:49,710
this so-called say block,
here's how it's going to work.

188
00:08:49,710 --> 00:08:52,574
I have-- let's call it
an argument or parameter,

189
00:08:52,574 --> 00:08:54,240
it's really just a blank sheet of paper.

190
00:08:54,240 --> 00:08:57,239
And it's white to kind of be reminiscent
of the white box into which you

191
00:08:57,239 --> 00:08:58,080
can write words.

192
00:08:58,080 --> 00:09:00,660
>> Meanwhile I'm going to go here.

193
00:09:00,660 --> 00:09:06,560
I'm going to go ahead and
write H-E-L-L-O comma world.

194
00:09:06,560 --> 00:09:09,972
And now I, as say the programmer, don't
actually know how to say something.

195
00:09:09,972 --> 00:09:12,180
I can come up with the words,
but I don't necessarily

196
00:09:12,180 --> 00:09:15,220
know how to express myself
verbally or on the screen.

197
00:09:15,220 --> 00:09:17,280
And so what I'm going
to do is take this piece

198
00:09:17,280 --> 00:09:21,157
of functionality, whose input--
or argument, as we'll call it,

199
00:09:21,157 --> 00:09:23,990
I've written on this piece of paper--
and I'm going to outsource it.

200
00:09:23,990 --> 00:09:26,831
>> And indeed that's the role that
functions in a programming language

201
00:09:26,831 --> 00:09:27,330
can play.

202
00:09:27,330 --> 00:09:29,246
Something like the say
block can be outsourced

203
00:09:29,246 --> 00:09:32,074
to someone who really knows
what she or he is talking about.

204
00:09:32,074 --> 00:09:33,990
So if you'll step over
here for just a moment,

205
00:09:33,990 --> 00:09:40,092
I am going to pass this input to
Alana, and ask that you say this input.

206
00:09:40,092 --> 00:09:41,202
>> ALANA: Hello, world.

207
00:09:41,202 --> 00:09:42,160
DAVID MALAN: That's it.

208
00:09:42,160 --> 00:09:43,326
So that there is a function.

209
00:09:43,326 --> 00:09:46,556
Now we can take it a little more,
we can take a step forward here.

210
00:09:46,556 --> 00:09:48,180
Because that was clearly underwhelming.

211
00:09:48,180 --> 00:09:51,670
So let's now convert this to
something a little more sophisticated.

212
00:09:51,670 --> 00:09:53,630
>> So this of course is our C version.

213
00:09:53,630 --> 00:09:56,760
So now if you want to take that
one off, that name tag off,

214
00:09:56,760 --> 00:09:58,530
and let's have you put on a new name.

215
00:09:58,530 --> 00:10:00,850
But fundamentally you're
playing the same role,

216
00:10:00,850 --> 00:10:03,400
it just so happens to
be called printf now.

217
00:10:03,400 --> 00:10:06,930
>> The story is, of course,
going to be-- probably

218
00:10:06,930 --> 00:10:09,317
just as underwhelming-- is
going to be the following.

219
00:10:09,317 --> 00:10:10,650
You are now the function printf.

220
00:10:10,650 --> 00:10:13,300
I am the caller, or the
programmer, who wants

221
00:10:13,300 --> 00:10:15,745
to stand on the shoulders of
people in the past like you,

222
00:10:15,745 --> 00:10:18,670
who've already figured out how
to actually write something down.

223
00:10:18,670 --> 00:10:20,650
And so this time,
rather than say it let's

224
00:10:20,650 --> 00:10:22,255
actually use our screen over here.

225
00:10:22,255 --> 00:10:24,130
So if you'd like to step
over here, I'm going

226
00:10:24,130 --> 00:10:27,196
to pass again this as
input to my printf friend.

227
00:10:27,196 --> 00:10:29,320
If you could go ahead and
print that on the screen,

228
00:10:29,320 --> 00:10:31,611
simply by drawing with your
finger on the black screen.

229
00:10:31,611 --> 00:10:43,680

230
00:10:43,680 --> 00:10:44,180
Excellent.

231
00:10:44,180 --> 00:10:47,350
All right, so lots of suspense for
how that was going to play out.

232
00:10:47,350 --> 00:10:51,390
>> So now let's take things up one
final notch, if we could, as follows.

233
00:10:51,390 --> 00:10:53,980
So this is a C program
as we said last time.

234
00:10:53,980 --> 00:10:57,460
And this just does what you did, it
prints out to the screen, hello, world.

235
00:10:57,460 --> 00:11:00,290
Even though there's clearly a lot
of distracting stuff up there.

236
00:11:00,290 --> 00:11:03,630
But let's take things up a notch and
introduce this version, which recall

237
00:11:03,630 --> 00:11:06,160
was the third version that
we ended up with last time.

238
00:11:06,160 --> 00:11:09,120
>> And now there's clearly
two uses of printf.

239
00:11:09,120 --> 00:11:12,280
There's 2 calls to Alana
in this case for printf,

240
00:11:12,280 --> 00:11:14,740
but there's also a call
to another function.

241
00:11:14,740 --> 00:11:17,150
What's that function clearly?

242
00:11:17,150 --> 00:11:17,650
Getstring.

243
00:11:17,650 --> 00:11:18,980
>> Can we get one more volunteer?

244
00:11:18,980 --> 00:11:20,980
OK, come on up.

245
00:11:20,980 --> 00:11:21,805
What's your name?

246
00:11:21,805 --> 00:11:22,990
>> JAVIER: Javier.

247
00:11:22,990 --> 00:11:24,750
>> DAVID MALAN: Javier, come on up.

248
00:11:24,750 --> 00:11:27,270
So Javier's role is on
this piece of paper.

249
00:11:27,270 --> 00:11:28,860
Which I'm going to call generically s.

250
00:11:28,860 --> 00:11:32,250
Now this is a variable, it's
of type string, as implied

251
00:11:32,250 --> 00:11:34,290
by that second line in the middle there.

252
00:11:34,290 --> 00:11:36,540
And I'd like you to go get me a string.

253
00:11:36,540 --> 00:11:40,120
Specifically head down to the orchestra
section and get me the name of someone,

254
00:11:40,120 --> 00:11:43,142
and come back with a variable
containing that value.

255
00:11:43,142 --> 00:11:44,225
It can be anyone you want.

256
00:11:44,225 --> 00:11:47,590

257
00:11:47,590 --> 00:11:48,520
>> Here we go.

258
00:11:48,520 --> 00:11:53,620

259
00:11:53,620 --> 00:11:55,960
All right, Javier is
writing down the name.

260
00:11:55,960 --> 00:12:02,210

261
00:12:02,210 --> 00:12:03,280
All right.

262
00:12:03,280 --> 00:12:05,740
We can all probably guess how
this is going to play out.

263
00:12:05,740 --> 00:12:07,489
We're perhaps belaboring
the point of what

264
00:12:07,489 --> 00:12:10,320
a function is doing, but
nonetheless thank you very much.

265
00:12:10,320 --> 00:12:13,890
>> So Javier has returned this string
here, which, can't quite see,

266
00:12:13,890 --> 00:12:15,800
Jonathan is the string
that we've gotten.

267
00:12:15,800 --> 00:12:18,330
So now what I'm actually going
to provide to Alana though

268
00:12:18,330 --> 00:12:20,150
is something a little different.

269
00:12:20,150 --> 00:12:23,800
Because in this version of the
program, first there's state your name.

270
00:12:23,800 --> 00:12:26,160
So the very first argument
I need to provide Alana

271
00:12:26,160 --> 00:12:33,030
with is going to be
literally state your name.

272
00:12:33,030 --> 00:12:35,280
All right, so simple as that
I would hand this to you.

273
00:12:35,280 --> 00:12:36,730
And as I write up the
next argument, if you

274
00:12:36,730 --> 00:12:39,230
want to go ahead and write this
on the board, let's go ahead

275
00:12:39,230 --> 00:12:42,659
and do the final example here to make
clear what's ultimately got to happen.

276
00:12:42,659 --> 00:12:44,450
So state your name,
write it toward the top

277
00:12:44,450 --> 00:12:47,220
if you don't mind, just so that
we have room for one second line.

278
00:12:47,220 --> 00:12:52,890
Because the last thing I'm going
to now provide you with is not one,

279
00:12:52,890 --> 00:12:57,220
but two pieces of paper.

280
00:12:57,220 --> 00:12:58,074
>> All right.

281
00:12:58,074 --> 00:13:01,920
H-E-L-L-O comma and then a blank line.

282
00:13:01,920 --> 00:13:04,780
So what I'm about to hand Alana now
is something a little different.

283
00:13:04,780 --> 00:13:08,600
Not only is she getting this,
where fill in the blank represents

284
00:13:08,600 --> 00:13:12,050
that percent-- what was the
placeholder we've been using?

285
00:13:12,050 --> 00:13:13,890
Yeah, so percent s.

286
00:13:13,890 --> 00:13:16,530
Meanwhile I'm going to pass
her in a second argument, which

287
00:13:16,530 --> 00:13:19,290
is precisely what Javier
retrieved from Jonathan.

288
00:13:19,290 --> 00:13:20,534
>> So let me give you these two.

289
00:13:20,534 --> 00:13:22,575
If you'd like to, go ahead
and print that effect.

290
00:13:22,575 --> 00:13:25,660

291
00:13:25,660 --> 00:13:28,130
What's ultimately happening
now is, Alana again

292
00:13:28,130 --> 00:13:29,410
is playing the role of printf.

293
00:13:29,410 --> 00:13:32,160
Javier was playing
the role of GetString.

294
00:13:32,160 --> 00:13:34,700
So that will be your souvenir.

295
00:13:34,700 --> 00:13:39,910
And ultimately what's happening, despite
this hello-- yep go ahead and comma.

296
00:13:39,910 --> 00:13:41,410
ALANA: Did I receive this yet or no?

297
00:13:41,410 --> 00:13:43,451
DAVID MALAN: Yep, you
received them both at once.

298
00:13:43,451 --> 00:13:45,740
So the idea is that you
can now flip the page

299
00:13:45,740 --> 00:13:50,000
to handle the second
of those two inputs.

300
00:13:50,000 --> 00:13:53,280
So this is only to hammer home the
point that whereas Alana executed

301
00:13:53,280 --> 00:13:55,830
this green line here, and then
Javier did this one for us

302
00:13:55,830 --> 00:13:57,820
and return to me something
we'll call s, but it was really

303
00:13:57,820 --> 00:13:59,520
just that piece of paper of his own.

304
00:13:59,520 --> 00:14:02,320
And now Alana has done this third line.

305
00:14:02,320 --> 00:14:06,010
>> And even though all of this looks
so incredibly cryptic perhaps

306
00:14:06,010 --> 00:14:08,870
at first glance, it really
is as simple as that.

307
00:14:08,870 --> 00:14:11,390
Passing inputs around,
getting outputs, either

308
00:14:11,390 --> 00:14:14,560
being physically handed back something,
or seeing a side effect like this.

309
00:14:14,560 --> 00:14:17,170
Something visually
written on the screen.

310
00:14:17,170 --> 00:14:19,990
So let's go ahead and
thank Alana and Javier,

311
00:14:19,990 --> 00:14:25,012
who was down here, for
joining us up here.

312
00:14:25,012 --> 00:14:25,934
>> [APPLAUSE]

313
00:14:25,934 --> 00:14:29,360

314
00:14:29,360 --> 00:14:33,480
>> So now let's take for granted just how
straightforward all of that might be.

315
00:14:33,480 --> 00:14:36,775
And let's proceed to actually
do something in actual code.

316
00:14:36,775 --> 00:14:40,620
So up on the screen here is a screenshot
of the so-called CS50 appliance.

317
00:14:40,620 --> 00:14:43,980
And if you had to at, as a
2:00 PM on Wednesday afternoon,

318
00:14:43,980 --> 00:14:46,602
explain to some friend
what the CS50 appliance is,

319
00:14:46,602 --> 00:14:48,185
how would you define it in a sentence?

320
00:14:48,185 --> 00:14:52,160

321
00:14:52,160 --> 00:14:53,240
Any one sentence?

322
00:14:53,240 --> 00:14:54,876
Yeah?

323
00:14:54,876 --> 00:14:57,334
STUDENT: It's like a program
that makes everyone's computer

324
00:14:57,334 --> 00:14:58,460
run with the same system.

325
00:14:58,460 --> 00:14:59,210
DAVID MALAN: Good!

326
00:14:59,210 --> 00:15:02,810
It's a program that enables everyone's
computer to run with the same system.

327
00:15:02,810 --> 00:15:04,920
It's sort of your own
copy of an operating

328
00:15:04,920 --> 00:15:07,540
system that happens to
be called Ubuntu Linux.

329
00:15:07,540 --> 00:15:11,070
And it runs effectively inside of
a window on your own Mac or PC,

330
00:15:11,070 --> 00:15:15,080
so that this way right out of the gate
in week 1, everyone here in the class

331
00:15:15,080 --> 00:15:17,590
has access to the same tools,
the same configuration,

332
00:15:17,590 --> 00:15:21,250
and there's no learning curve specific
to a Mac or a PC in particular.

333
00:15:21,250 --> 00:15:25,620
>> Now we opened up, inside of the CS50
appliance on Monday, this program here.

334
00:15:25,620 --> 00:15:27,040
It happens to be called gedit.

335
00:15:27,040 --> 00:15:29,050
But that's really just
a graphical editor.

336
00:15:29,050 --> 00:15:33,170
It's something like Notepad or Text
Edit on Windows or Mac OS respectively.

337
00:15:33,170 --> 00:15:36,720
And I proposed that there were really
three important parts to this screen.

338
00:15:36,720 --> 00:15:39,560
The top side is where you
would write your code.

339
00:15:39,560 --> 00:15:44,080
And that's where we spent much of our
three examples in Monday's lecture.

340
00:15:44,080 --> 00:15:47,650
The bottom we called what,
this black window, yeah?

341
00:15:47,650 --> 00:15:48,640
>> STUDENT: Compiler?

342
00:15:48,640 --> 00:15:51,500
>> DAVID MALAN: Compiler we
accessed by way of that window.

343
00:15:51,500 --> 00:15:53,040
But more generally.

344
00:15:53,040 --> 00:15:54,540
Yeah, it was just a terminal window.

345
00:15:54,540 --> 00:15:57,780
This is an age old term that just
describes essentially a blinking

346
00:15:57,780 --> 00:16:01,910
prompt, that years ago used to be on
one of those big CRT style monitors.

347
00:16:01,910 --> 00:16:04,300
But nowadays it's sort
of virtual in software.

348
00:16:04,300 --> 00:16:06,710
And the terminal windows
let's us type commands.

349
00:16:06,710 --> 00:16:11,750
It sort of the simplified version
of the user interface or UI.

350
00:16:11,750 --> 00:16:14,060
It's not a graphical
user interface or GUI,

351
00:16:14,060 --> 00:16:17,250
it's a text-based interface
or a command line interface.

352
00:16:17,250 --> 00:16:20,770
>> And indeed that's where ultimately
I was able to write some code.

353
00:16:20,770 --> 00:16:24,200
Once I had written some code though,
recall that I used this command.

354
00:16:24,200 --> 00:16:26,210
And as it the name
kind of suggests, this

355
00:16:26,210 --> 00:16:29,860
allows me to make a
program called Hello.

356
00:16:29,860 --> 00:16:33,400
But what was it really doing?

357
00:16:33,400 --> 00:16:36,180
Well make was taking my
input, my source code,

358
00:16:36,180 --> 00:16:39,380
and converting it to what, ultimately?

359
00:16:39,380 --> 00:16:40,060
>> Object code.

360
00:16:40,060 --> 00:16:42,790
And object code is just a fancy
way of saying zeros and ones.

361
00:16:42,790 --> 00:16:46,420
And then once I wanted
to run that object code,

362
00:16:46,420 --> 00:16:50,940
once I wanted to pass as input those
zeros and ones into my computer's

363
00:16:50,940 --> 00:16:54,430
brain, the so-called CPU
or central processing unit,

364
00:16:54,430 --> 00:16:55,730
I had to run the program.

365
00:16:55,730 --> 00:16:59,042
But it wasn't quite a simple on Monday
as just double clicking some icon.

366
00:16:59,042 --> 00:17:01,375
What instead did I have to
do in order to run a program?

367
00:17:01,375 --> 00:17:04,130

368
00:17:04,130 --> 00:17:07,890
>> What was that second command?

369
00:17:07,890 --> 00:17:09,619
I'm hearing a little slashes?

370
00:17:09,619 --> 00:17:10,544
Yes, yeah?

371
00:17:10,544 --> 00:17:12,474
>> STUDENT: Dot slash and
the program's name.

372
00:17:12,474 --> 00:17:13,349
DAVID MALAN: Exactly.

373
00:17:13,349 --> 00:17:15,030
Dot slash and the program's name.

374
00:17:15,030 --> 00:17:16,210
Now what did this mean?

375
00:17:16,210 --> 00:17:19,470
Well dot is just an arcane way
of saying current directory.

376
00:17:19,470 --> 00:17:23,440
Whatever folder you are in is
referenced as, is represented as dot.

377
00:17:23,440 --> 00:17:26,680
The slash is just what you've seen
in Mac OS and Windows for years,

378
00:17:26,680 --> 00:17:30,329
it's a separator between a directory
or folder and the rest of some name.

379
00:17:30,329 --> 00:17:32,620
In Windows it happens to go
backwards, in Linux and Mac

380
00:17:32,620 --> 00:17:34,210
OS it happens to go forwards.

381
00:17:34,210 --> 00:17:37,560
But it's just the separator, so it's
just an uninteresting syntactic detail.

382
00:17:37,560 --> 00:17:40,440
>> The juicy part of course is
the name of the program, Hello.

383
00:17:40,440 --> 00:17:42,650
And that's what make created for us.

384
00:17:42,650 --> 00:17:44,910
It outputted that file for us.

385
00:17:44,910 --> 00:17:46,700
But how did we get to that point?

386
00:17:46,700 --> 00:17:48,870
Let's now ask the
question, what was really

387
00:17:48,870 --> 00:17:52,470
going on here, at least with
regard to some of this syntax?

388
00:17:52,470 --> 00:17:57,000
>> So in an sentence or so,
how did we explain away

389
00:17:57,000 --> 00:17:59,020
this first line that's
highlighted in green?

390
00:17:59,020 --> 00:18:02,998
What was that first line doing,
with respect to my program?

391
00:18:02,998 --> 00:18:03,974
Yeah?

392
00:18:03,974 --> 00:18:05,067
>> STUDENT: [INAUDIBLE].

393
00:18:05,067 --> 00:18:06,150
DAVID MALAN: Say it again?

394
00:18:06,150 --> 00:18:08,734
STUDENT: Including and downloading
past functions [INAUDIBLE].

395
00:18:08,734 --> 00:18:09,483
DAVID MALAN: Good.

396
00:18:09,483 --> 00:18:11,900
Including, I won't say
downloading, but let's say

397
00:18:11,900 --> 00:18:15,500
including functions that people
have written in the past.

398
00:18:15,500 --> 00:18:18,260
And those functions are implemented
somewhere in my computer.

399
00:18:18,260 --> 00:18:20,470
Someone wrote a file
years ago, and that file

400
00:18:20,470 --> 00:18:23,490
is somewhere inside of the CS50
appliance, or on my hard drive

401
00:18:23,490 --> 00:18:24,480
more generally.

402
00:18:24,480 --> 00:18:27,810
And so this line is essentially saying,
go find that file, standard I/O dot

403
00:18:27,810 --> 00:18:31,740
h, and copy and paste its contents
right here on the top of my file

404
00:18:31,740 --> 00:18:33,860
so that I don't have to
do that manually myself.

405
00:18:33,860 --> 00:18:40,970
>> And among the juiciest pieces inside of
that file we claimed was what function?

406
00:18:40,970 --> 00:18:45,740
What function did we say was declared
or mentioned in standard I/O dot h

407
00:18:45,740 --> 00:18:47,120
most likely?

408
00:18:47,120 --> 00:18:47,900
Printf, right?

409
00:18:47,900 --> 00:18:50,797
We did not write printf on
Monday, it just existed.

410
00:18:50,797 --> 00:18:52,880
Much like Alana just came
up on stage and she just

411
00:18:52,880 --> 00:18:55,540
existed and knew how to draw
something on the screen,

412
00:18:55,540 --> 00:18:58,660
so does printf exist for many years.

413
00:18:58,660 --> 00:19:00,240
And so this is how we access it.

414
00:19:00,240 --> 00:19:03,280
Now if we move on here,
main was analogous we

415
00:19:03,280 --> 00:19:06,620
said to the puzzle piece
called when green flag clicked

416
00:19:06,620 --> 00:19:07,620
in the world of Scratch.

417
00:19:07,620 --> 00:19:10,130
It's just sort of the
default name that humans

418
00:19:10,130 --> 00:19:13,340
decided would represent the
default entry point to a program.

419
00:19:13,340 --> 00:19:16,540
The chunk of programming code
that gets executed first.

420
00:19:16,540 --> 00:19:19,700
>> Meanwhile these curly braces are
kind of like the curved shape

421
00:19:19,700 --> 00:19:21,410
of a lot of those yellow scratch pieces.

422
00:19:21,410 --> 00:19:24,860
They kind of encapsulate a whole
bunch of instructions together.

423
00:19:24,860 --> 00:19:28,350
So it just kind of binds together
some related functionality.

424
00:19:28,350 --> 00:19:33,750
printf of course is a function that
prints the screen, as we just did.

425
00:19:33,750 --> 00:19:35,190
>> What about these parentheses?

426
00:19:35,190 --> 00:19:38,770
How would you define-- even if you've
never programmed before, but just based

427
00:19:38,770 --> 00:19:41,320
now on an increasing
hopefully intuition, what

428
00:19:41,320 --> 00:19:43,290
are the parentheses doing for us here?

429
00:19:43,290 --> 00:19:45,450
Or what are they surrounding?

430
00:19:45,450 --> 00:19:46,360
Yeah?

431
00:19:46,360 --> 00:19:49,360
>> STUDENT: They're saying what
you're going to print with printf.

432
00:19:49,360 --> 00:19:52,401
>> DAVID MALAN: Yeah, they're saying what
you're going to print with printf.

433
00:19:52,401 --> 00:19:56,260
Or more generally, they are
surrounding the inputs to the function.

434
00:19:56,260 --> 00:19:58,530
So you can almost think
of those parentheses

435
00:19:58,530 --> 00:20:01,620
as being like the metal
clip on this clipboard.

436
00:20:01,620 --> 00:20:05,940
It's what's holding, it's what's
going to be used to provide arguments

437
00:20:05,940 --> 00:20:08,500
into the function, which in
this case is called printf.

438
00:20:08,500 --> 00:20:12,390
>> So in general almost any
time we call a function,

439
00:20:12,390 --> 00:20:14,280
we are going to see a pair parentheses.

440
00:20:14,280 --> 00:20:17,000
Maybe with something in it,
like now, maybe nothing in it.

441
00:20:17,000 --> 00:20:19,770
But that's where you would put
the inputs or so-called arguments

442
00:20:19,770 --> 00:20:20,680
to a function.

443
00:20:20,680 --> 00:20:22,470
>> Here's one such argument.

444
00:20:22,470 --> 00:20:24,467
I've highlighted everything
between the quotes,

445
00:20:24,467 --> 00:20:26,300
because it turns out
in this language called

446
00:20:26,300 --> 00:20:29,950
C, when you want to represent a
string-- that is a word or a phrase

447
00:20:29,950 --> 00:20:33,470
or even a paragraph-- you have to
surround it with double quotes.

448
00:20:33,470 --> 00:20:35,420
Not single quotes, double quotes.

449
00:20:35,420 --> 00:20:37,460
And that's exactly what I've done here.

450
00:20:37,460 --> 00:20:39,900
>> Meanwhile there's a funky
symbol toward the end there.

451
00:20:39,900 --> 00:20:41,600
The backslash n.

452
00:20:41,600 --> 00:20:43,460
What did we say that represented?

453
00:20:43,460 --> 00:20:44,093
Yeah?

454
00:20:44,093 --> 00:20:44,980
>> STUDENT: A new line.

455
00:20:44,980 --> 00:20:45,896
>> DAVID MALAN: New line.

456
00:20:45,896 --> 00:20:47,910
Right, you don't
generally hit Enter when

457
00:20:47,910 --> 00:20:50,430
you want the program
to spit out a new line.

458
00:20:50,430 --> 00:20:54,210
Rather you tell it explicitly
with this admittedly arcane piece

459
00:20:54,210 --> 00:20:58,770
of syntax, backslash n, that
you want a new line to go there.

460
00:20:58,770 --> 00:20:59,810
Finally the semicolon.

461
00:20:59,810 --> 00:21:01,560
We didn't really talk
too much about this,

462
00:21:01,560 --> 00:21:04,893
and by far this will be the bane of some
of your existence for the first problem

463
00:21:04,893 --> 00:21:07,990
set, when you just failed to realize
you've forgotten something as stupid

464
00:21:07,990 --> 00:21:08,614
as a semicolon.

465
00:21:08,614 --> 00:21:11,600
And generally putting it
there will fix that problem.

466
00:21:11,600 --> 00:21:13,511
But what's it doing
for us, would you say?

467
00:21:13,511 --> 00:21:15,670
>> STUDENT: [INAUDIBLE].

468
00:21:15,670 --> 00:21:17,484
>> DAVID MALAN: Sorry?

469
00:21:17,484 --> 00:21:18,532
>> STUDENT: [INAUDIBLE].

470
00:21:18,532 --> 00:21:19,990
DAVID MALAN: Finishing a statement.

471
00:21:19,990 --> 00:21:22,770
It's sort of like the period at
the end of an English sentence,

472
00:21:22,770 --> 00:21:25,790
whereas in this language
C it's ending a statement.

473
00:21:25,790 --> 00:21:29,250
An instruction of programming
code that you just want to say,

474
00:21:29,250 --> 00:21:30,500
I'm done with this.

475
00:21:30,500 --> 00:21:32,240
Now notice that's the only one here.

476
00:21:32,240 --> 00:21:34,614
So you don't want to get in
a habit of putting semicolons

477
00:21:34,614 --> 00:21:36,190
after every closed parenthesis.

478
00:21:36,190 --> 00:21:38,610
For instance there's none
next to void, and we'll

479
00:21:38,610 --> 00:21:40,430
come back in the future
to what void means.

480
00:21:40,430 --> 00:21:44,080
But in this case your printf is a
function, or a statement being used,

481
00:21:44,080 --> 00:21:47,420
and so we want to have that
terminus at the very end of it.

482
00:21:47,420 --> 00:21:50,980
>> And I'm intentionally picking on C. And
frankly a lot of languages like C, C++,

483
00:21:50,980 --> 00:21:55,000
Java, JavaScript, and any number of
other languages have a lot of these

484
00:21:55,000 --> 00:21:56,730
sort of syntactic details.

485
00:21:56,730 --> 00:22:00,120
That certainly if you're new to
programming can genuinely trip you up.

486
00:22:00,120 --> 00:22:02,307
And you will, mark my
words, some of you will

487
00:22:02,307 --> 00:22:04,140
have this experience
in office hours or late

488
00:22:04,140 --> 00:22:07,554
at night working on some p-set, where
your damn program just doesn't compile,

489
00:22:07,554 --> 00:22:09,470
it doesn't run, you have
no idea what's wrong,

490
00:22:09,470 --> 00:22:11,513
it seems completely
logically correct to you.

491
00:22:11,513 --> 00:22:13,596
And it's because you forgot
something like hitting

492
00:22:13,596 --> 00:22:15,250
a semicolon at the end of some line.

493
00:22:15,250 --> 00:22:17,590
>> But these are the kinds of things you're
going to immediately learn to see.

494
00:22:17,590 --> 00:22:20,048
And indeed these are the things
that the CA's and TF's have

495
00:22:20,048 --> 00:22:23,210
been sort of trained to see
much more quickly than you.

496
00:22:23,210 --> 00:22:26,610
And so this is only to say, as you
dive into problem set 1 especially,

497
00:22:26,610 --> 00:22:28,217
don't get frustrated by this stuff.

498
00:22:28,217 --> 00:22:30,050
Once you sort of acclimate
to the world, you

499
00:22:30,050 --> 00:22:35,130
begin to see things that you might not
see at first glance this first week.

500
00:22:35,130 --> 00:22:37,440
>> So source code is something like that.

501
00:22:37,440 --> 00:22:40,370
We want to pass it into
the so-called compiler.

502
00:22:40,370 --> 00:22:42,850
And that compiler as
we said provides output

503
00:22:42,850 --> 00:22:45,660
known as object code, the
so-called zeros and ones.

504
00:22:45,660 --> 00:22:47,747
But from there, what does that give us?

505
00:22:47,747 --> 00:22:49,080
Well it gives us these patterns.

506
00:22:49,080 --> 00:22:52,020
And again your computer,
your Intel inside,

507
00:22:52,020 --> 00:22:54,350
understands these patterns
of zeros and ones.

508
00:22:54,350 --> 00:22:57,300
And sometimes the pattern
represents an actual decimal number

509
00:22:57,300 --> 00:22:59,770
as we saw last week, sometimes
it represents a letter

510
00:22:59,770 --> 00:23:02,730
like we saw last week, sometimes
it represents an instruction,

511
00:23:02,730 --> 00:23:05,460
like printing something to the screen.

512
00:23:05,460 --> 00:23:08,782
>> So printf for instance--
but rather, let me rewind.

513
00:23:08,782 --> 00:23:11,240
We've been taking for granted
that those zeros and ones are

514
00:23:11,240 --> 00:23:14,200
produced by this command make.

515
00:23:14,200 --> 00:23:16,050
But make is not a compiler.

516
00:23:16,050 --> 00:23:19,370
Make is not the thing in the middle
that's producing the zeros and ones.

517
00:23:19,370 --> 00:23:23,780
Rather make is just a very conveniently
named program whose purpose in life

518
00:23:23,780 --> 00:23:27,267
is essentially to figure out
how to compile your program.

519
00:23:27,267 --> 00:23:29,350
And we use it in these
first weeks because it just

520
00:23:29,350 --> 00:23:30,910
saves us a lot of trouble.

521
00:23:30,910 --> 00:23:34,080
>> But what make is really
doing when you compile hello,

522
00:23:34,080 --> 00:23:36,690
is, as we said last time, it's
looking on your hard drive

523
00:23:36,690 --> 00:23:40,620
or in the current folder, for
file called what, apparently?

524
00:23:40,620 --> 00:23:41,815
Hello.c, right?

525
00:23:41,815 --> 00:23:43,190
That's just kind of a convention.

526
00:23:43,190 --> 00:23:45,620
It's arbitrary, but
that's the way things are.

527
00:23:45,620 --> 00:23:48,620
Make, if you just specify the name
of a program that doesn't yet exist,

528
00:23:48,620 --> 00:23:52,200
it's going to look for the source code
in a file, by default means hello.c.

529
00:23:52,200 --> 00:23:53,530
And if it finds it, great.

530
00:23:53,530 --> 00:23:56,650
It's going to convert that source
code into object code for you.

531
00:23:56,650 --> 00:23:59,670
>> But every time I've hit Enter
after running make hello,

532
00:23:59,670 --> 00:24:03,560
do you recall seeing last time a
fairly long and cryptic sequence

533
00:24:03,560 --> 00:24:06,430
of other white letters and
characters on the screen?

534
00:24:06,430 --> 00:24:11,220
Well that was the actual command, the
actual compiler, that was running.

535
00:24:11,220 --> 00:24:15,500
So the actual compiler we'll use most of
the semester is something called clang.

536
00:24:15,500 --> 00:24:19,280
Some of you might have used
Visual Studio before, or GCC,

537
00:24:19,280 --> 00:24:21,340
or any number of other compilers.

538
00:24:21,340 --> 00:24:22,620
We'll use clang.

539
00:24:22,620 --> 00:24:26,950
>> And clang allows us to actually convert
that source code to object code.

540
00:24:26,950 --> 00:24:29,430
What does this actually
mean in practice?

541
00:24:29,430 --> 00:24:33,390
Well let me go into one of
my folders from last time.

542
00:24:33,390 --> 00:24:35,760
Inside of the CS50 appliance.

543
00:24:35,760 --> 00:24:42,080
And let me go ahead and create this
same file, include standard I/O dot h.

544
00:24:42,080 --> 00:24:42,875
Int main void.

545
00:24:42,875 --> 00:24:46,000
And we'll come back in the future as
to what int means and what void means.

546
00:24:46,000 --> 00:24:49,130
But for now let's do
hello world backslash n,

547
00:24:49,130 --> 00:24:50,500
just like we did on the board.

548
00:24:50,500 --> 00:24:53,930
>> Let me save this file called hello.c.

549
00:24:53,930 --> 00:24:58,280
And now if I want to compile this
I could-- let me zoom in-- run

550
00:24:58,280 --> 00:25:00,450
make hello enter.

551
00:25:00,450 --> 00:25:02,645
And this again was
that very cryptic line.

552
00:25:02,645 --> 00:25:05,120
But now at least one word
probably jumps out at you.

553
00:25:05,120 --> 00:25:07,087
Clang is that line we saw before.

554
00:25:07,087 --> 00:25:10,420
Now there's a lot of other stuff frankly
that we'll wave our hands at for today.

555
00:25:10,420 --> 00:25:14,020
But there's a few subsets,
a few characters in here

556
00:25:14,020 --> 00:25:14,907
that are of interest.

557
00:25:14,907 --> 00:25:16,490
But I'm going to go ahead and do this.

558
00:25:16,490 --> 00:25:18,281
I'm going to first run
hello, just to prove

559
00:25:18,281 --> 00:25:20,320
that this is working as it was Monday.

560
00:25:20,320 --> 00:25:22,330
But now I'm going to delete the program.

561
00:25:22,330 --> 00:25:25,870
And much like we had these
short names last time,

562
00:25:25,870 --> 00:25:29,787
the command for removing
something is rm, remove, enter.

563
00:25:29,787 --> 00:25:31,870
You're going to get some
fairly cryptic questions.

564
00:25:31,870 --> 00:25:35,210
Hard to believe that you can make
even this question hard to understand.

565
00:25:35,210 --> 00:25:38,100
But remove regular file hello just
means do you want to delete hello.

566
00:25:38,100 --> 00:25:42,650
>> And I can go ahead and type y for
yes, Enter, and now it's gone.

567
00:25:42,650 --> 00:25:45,130
What this means now,
if I clear my screen,

568
00:25:45,130 --> 00:25:47,301
is that instead of
doing make hello-- you

569
00:25:47,301 --> 00:25:48,800
know what, I'm getting good at this.

570
00:25:48,800 --> 00:25:50,690
I'm going to run the compiler myself.

571
00:25:50,690 --> 00:25:53,330
I don't need some program to
figure out what my file is called.

572
00:25:53,330 --> 00:25:55,370
I wrote hello.c, I
know what it's called,

573
00:25:55,370 --> 00:25:57,640
I'm clearly capable of typing that.

574
00:25:57,640 --> 00:26:02,620
So I'm going to go ahead
and do clang hello.c Enter.

575
00:26:02,620 --> 00:26:03,264
>> Seems to work.

576
00:26:03,264 --> 00:26:05,930
And there's no additional output,
because clang is the compiler.

577
00:26:05,930 --> 00:26:08,590
It's what's converting the
source code to zeros and ones.

578
00:26:08,590 --> 00:26:12,870
So if I now do dot
slash hello Enter, hm.

579
00:26:12,870 --> 00:26:14,630
New error message today.

580
00:26:14,630 --> 00:26:17,610
So bash is just the name of the
blinking prompt that we're using.

581
00:26:17,610 --> 00:26:20,360
That's a gross oversimplification,
but for now that's all that is,

582
00:26:20,360 --> 00:26:21,401
it's the blinking prompt.

583
00:26:21,401 --> 00:26:22,880
And that's why it's yelling at us.

584
00:26:22,880 --> 00:26:25,690
>> No such file or directory is
a little more straightforward.

585
00:26:25,690 --> 00:26:28,190
But surely I made that object code.

586
00:26:28,190 --> 00:26:30,930
But the catch is, that
if I type the command

587
00:26:30,930 --> 00:26:34,650
to list the contents of this
directory, which is what?

588
00:26:34,650 --> 00:26:36,210
ls for list.

589
00:26:36,210 --> 00:26:39,332
There's a bunch of stuff in here,
some of which came with the appliance,

590
00:26:39,332 --> 00:26:42,040
like my Desktop folder, Downloads
folder, Dropbox folder, and all

591
00:26:42,040 --> 00:26:42,850
that stuff.

592
00:26:42,850 --> 00:26:45,410
But what is interesting
is hello.c, which

593
00:26:45,410 --> 00:26:47,286
I created a moment ago with gedit.

594
00:26:47,286 --> 00:26:49,160
And what's the weirdest
looking name in here,

595
00:26:49,160 --> 00:26:53,110
perhaps that we didn't
see last time at all?

596
00:26:53,110 --> 00:26:54,710
>> a.out, right?

597
00:26:54,710 --> 00:26:56,920
So back in the day, it
was just decided that when

598
00:26:56,920 --> 00:26:58,760
you compile a program
for the first time,

599
00:26:58,760 --> 00:27:02,360
and you don't specify the name
of a file, let's call it a.

600
00:27:02,360 --> 00:27:05,800
And a.out just means this was
the output of the compiler.

601
00:27:05,800 --> 00:27:07,790
So it's a horrible name for a program.

602
00:27:07,790 --> 00:27:12,820
But by that logic, dot slash for
current directory, slash a.out,

603
00:27:12,820 --> 00:27:16,102
should mean there's in fact
my hello world program.

604
00:27:16,102 --> 00:27:17,560
Now a little warm up exercise, too.

605
00:27:17,560 --> 00:27:20,420
If I want to rename this
file, turns out that you

606
00:27:20,420 --> 00:27:23,000
move a file from one name to another.

607
00:27:23,000 --> 00:27:28,750
So mv a.out, and then I
can call it hello Enter.

608
00:27:28,750 --> 00:27:30,940
So this is a Linux command.

609
00:27:30,940 --> 00:27:34,370
DOS had this years ago,
Windows has a terminal window

610
00:27:34,370 --> 00:27:36,460
of some sort that looks
like this, Linux and Mac

611
00:27:36,460 --> 00:27:38,140
computers have this blinking prompt.

612
00:27:38,140 --> 00:27:41,490
Even though most of us probably
rarely, if ever, use it.

613
00:27:41,490 --> 00:27:44,590
>> But what I've done is run a
program, whose name is mv,

614
00:27:44,590 --> 00:27:47,900
and I've provided it with
two arguments, so to speak.

615
00:27:47,900 --> 00:27:48,630
Two inputs.

616
00:27:48,630 --> 00:27:50,260
a.out is the original name.

617
00:27:50,260 --> 00:27:51,630
Hello is the new name.

618
00:27:51,630 --> 00:27:55,670
So if I now do dot slash
hello, Enter, that exists.

619
00:27:55,670 --> 00:28:00,770
And if I do dot slash a.out,
what do you expect I should see?

620
00:28:00,770 --> 00:28:02,250
>> Bash, no such file or directory.

621
00:28:02,250 --> 00:28:03,350
Because I just renamed it.

622
00:28:03,350 --> 00:28:04,975
So this takes a bit of getting used to.

623
00:28:04,975 --> 00:28:06,977
But the problem set 1
specification will truly

624
00:28:06,977 --> 00:28:08,810
hold your hand through
some of this minutae.

625
00:28:08,810 --> 00:28:11,050
Because this is a complete
intellectual distraction

626
00:28:11,050 --> 00:28:12,966
from the more interesting
ideas at hand, which

627
00:28:12,966 --> 00:28:15,310
is actually creating
something out of code.

628
00:28:15,310 --> 00:28:18,830
But let's do one modification
now to this program.

629
00:28:18,830 --> 00:28:23,150
>> Recall that last time I did something
like this, printf state your name.

630
00:28:23,150 --> 00:28:25,790
And indeed we just did this
on the big screen over there.

631
00:28:25,790 --> 00:28:30,640
And then I did string s gets
GetString open paren, close paren.

632
00:28:30,640 --> 00:28:33,430
And paren just shorthand
notation for parenthesis.

633
00:28:33,430 --> 00:28:36,460
So does GetString take any arguments?

634
00:28:36,460 --> 00:28:38,440
No inputs no, but it
needs the parentheses,

635
00:28:38,440 --> 00:28:41,830
because that's what demarcates
the calling of a function.

636
00:28:41,830 --> 00:28:46,440
>> So I'm going to go ahead and try to
run the compiler on this program now.

637
00:28:46,440 --> 00:28:50,774
Clang hello.c, because I
didn't change its name for now.

638
00:28:50,774 --> 00:28:51,940
And I got a bunch of errors.

639
00:28:51,940 --> 00:28:53,570
Let's zoom out here.

640
00:28:53,570 --> 00:28:55,420
If I scroll up again,
like I said last time,

641
00:28:55,420 --> 00:28:58,420
to the first, same error
that I got last time.

642
00:28:58,420 --> 00:29:04,210
On line 6 of hello.c I had an
undeclared identifier string,

643
00:29:04,210 --> 00:29:05,590
did I mean standard in?

644
00:29:05,590 --> 00:29:06,750
I didn't.

645
00:29:06,750 --> 00:29:10,050
Because what mistake have I made in this
program, if you recall from last time?

646
00:29:10,050 --> 00:29:13,219

647
00:29:13,219 --> 00:29:15,010
Yeah, we need the
so-called training wheels

648
00:29:15,010 --> 00:29:16,510
that we'll just use for a few weeks.

649
00:29:16,510 --> 00:29:19,480
But I need to specify that also,
somewhere inside of the appliance,

650
00:29:19,480 --> 00:29:22,720
is a file that we wrote
just a few years ago.

651
00:29:22,720 --> 00:29:26,500
Inside of which are functions
like apparently GetString.

652
00:29:26,500 --> 00:29:35,160
So now if I go back down here,
zoom in, and re-run clang hello.c.

653
00:29:35,160 --> 00:29:36,500
Damn, another error.

654
00:29:36,500 --> 00:29:38,590
But we haven't seen this one before.

655
00:29:38,590 --> 00:29:41,900
>> This one's a little more
esoteric to figure out.

656
00:29:41,900 --> 00:29:46,910
But this is deliberately on the screen,
because we wanted to tell this story.

657
00:29:46,910 --> 00:29:51,280
When you compile hello.c, just as
the picture from before suggested,

658
00:29:51,280 --> 00:29:54,650
you're only converting that
source code to zeros and ones.

659
00:29:54,650 --> 00:30:00,340
Now CS50 staff a few years ago wrote
CS50.h, and a corresponding file,

660
00:30:00,340 --> 00:30:01,640
CS50.c.

661
00:30:01,640 --> 00:30:04,490
And we, a few years ago,
compiled those files

662
00:30:04,490 --> 00:30:07,290
into a file that happens
to be called CS50.o.

663
00:30:07,290 --> 00:30:09,180
>> Or it can be renamed a
few different things.

664
00:30:09,180 --> 00:30:11,054
But that's a simple way
of thinking about it.

665
00:30:11,054 --> 00:30:14,960
So we compiled CS50's
library into zeros and ones.

666
00:30:14,960 --> 00:30:20,340
But nowhere have I specified
that I want to combine my zeroes

667
00:30:20,340 --> 00:30:24,030
and ones for my hello world
program with the zeros and ones

668
00:30:24,030 --> 00:30:29,760
that CS50 staff created a few years
ago into one complete program.

669
00:30:29,760 --> 00:30:34,100
All I've specified by writing
clang hello.c is compile hello.c.

670
00:30:34,100 --> 00:30:38,380
>> I've not told clang to
link in the zeros and ones

671
00:30:38,380 --> 00:30:41,650
that CS50 staff created
for you some time ago.

672
00:30:41,650 --> 00:30:48,280
So it's an easy fix,
dash l for link, CS50.

673
00:30:48,280 --> 00:30:52,600
And we'll again see this
before long again and again.

674
00:30:52,600 --> 00:30:54,420
But notice now there was no complaints.

675
00:30:54,420 --> 00:30:59,770
So now if I run dot slash
hello, now it's working.

676
00:30:59,770 --> 00:31:03,840
Although that's a bit misleading
since I just recreated what file?

677
00:31:03,840 --> 00:31:05,880
a.out.

678
00:31:05,880 --> 00:31:07,930
>> So let me rewind for just a moment.

679
00:31:07,930 --> 00:31:10,900
The program we just compiled
has the three lines of code.

680
00:31:10,900 --> 00:31:14,710
When I ran hello world, hello a moment
ago, I didn't see state your name.

681
00:31:14,710 --> 00:31:17,080
And that's because I ran the
old version of the program.

682
00:31:17,080 --> 00:31:22,700
But if I do indeed run dot slash a.out
Enter, state your name, Rob, hello,

683
00:31:22,700 --> 00:31:23,370
world.

684
00:31:23,370 --> 00:31:23,870
Hm.

685
00:31:23,870 --> 00:31:26,110
That's kind of a bug.

686
00:31:26,110 --> 00:31:28,560
Probably meant to say Rob, right?

687
00:31:28,560 --> 00:31:30,997
So what's the fix here in code.

688
00:31:30,997 --> 00:31:31,872
STUDENT: [INAUDIBLE].

689
00:31:31,872 --> 00:31:38,415

690
00:31:38,415 --> 00:31:39,290
DAVID MALAN: Exactly.

691
00:31:39,290 --> 00:31:43,160
So I just need to make that final tweak
so that I'm passing in a placeholder,

692
00:31:43,160 --> 00:31:45,690
like a fill in the blank,
like we did a moment ago.

693
00:31:45,690 --> 00:31:47,870
But percent s is now
that fill in the blank.

694
00:31:47,870 --> 00:31:52,100
So lastly let's reveal one last
detail so that there's no magic.

695
00:31:52,100 --> 00:31:54,090
I'm going to go ahead
and get rid of hellow.

696
00:31:54,090 --> 00:31:56,070
I'm going to go ahead
and get rid of a.out.

697
00:31:56,070 --> 00:31:58,410
So now I have no programs,
just my source code.

698
00:31:58,410 --> 00:32:01,100
And I'm going to run a
slightly longer command, clang

699
00:32:01,100 --> 00:32:05,650
dash o hello hello.c dash LCS50.

700
00:32:05,650 --> 00:32:08,700
>> Now this is starting to sort of go
in one ear and out the other perhaps.

701
00:32:08,700 --> 00:32:10,366
But just tease apart what this is doing.

702
00:32:10,366 --> 00:32:14,910
Clang is the compiler, dash LCS50
deliberately at the very end

703
00:32:14,910 --> 00:32:18,330
does what in a sentence?

704
00:32:18,330 --> 00:32:19,607
Links to the CS50 library.

705
00:32:19,607 --> 00:32:21,440
Grabs the zeros and
ones that the staff made

706
00:32:21,440 --> 00:32:23,310
and crams them into my own program.

707
00:32:23,310 --> 00:32:27,040
So the last question at hand is,
what is dash o hello probably

708
00:32:27,040 --> 00:32:30,530
doing, even if you've never
seen this syntax before?

709
00:32:30,530 --> 00:32:34,920
>> Outputting a program that's
not named the default a.out.

710
00:32:34,920 --> 00:32:37,330
Rather it's named hello.

711
00:32:37,330 --> 00:32:39,460
So now there is no a.out.

712
00:32:39,460 --> 00:32:42,660
No such file or directory,
because I explicitly said

713
00:32:42,660 --> 00:32:46,720
call this program hello, so that
I can now type in a name like that

714
00:32:46,720 --> 00:32:47,790
and have it behave.

715
00:32:47,790 --> 00:32:50,180
>> Now frankly, boy is that
uninteresting to have

716
00:32:50,180 --> 00:32:52,170
to remember all of that
little minutia, right?

717
00:32:52,170 --> 00:32:54,180
So let's go ahead and
get rid of hello again.

718
00:32:54,180 --> 00:32:57,880
And let's now return to a world in
which it suffices to say make hello.

719
00:32:57,880 --> 00:33:00,410
But that's the magic that
make is doing for you,

720
00:33:00,410 --> 00:33:02,320
that's the tedium that
it's doing for you.

721
00:33:02,320 --> 00:33:04,630
And as our programs and
problems get more complex,

722
00:33:04,630 --> 00:33:06,142
make will truly be your friend.

723
00:33:06,142 --> 00:33:07,850
Because not too long
from now we're going

724
00:33:07,850 --> 00:33:11,150
to have programs that are written
not with one file, but several files,

725
00:33:11,150 --> 00:33:16,310
and make will automate the process of
compiling all of that for us together.

726
00:33:16,310 --> 00:33:20,620
>> So now print.

727
00:33:20,620 --> 00:33:24,960
printf is inside of this file, standard
I/O dot h, that we've seen before,

728
00:33:24,960 --> 00:33:26,980
but there's more to printf than that.

729
00:33:26,980 --> 00:33:30,482
There's backslash n, but there's also
a bunch of other escape sequences.

730
00:33:30,482 --> 00:33:32,940
And escape sequence is just a
fancy way of saying something

731
00:33:32,940 --> 00:33:35,990
that starts with a backslash,
not a forward slash, a backslash,

732
00:33:35,990 --> 00:33:37,920
and does some special thing.

733
00:33:37,920 --> 00:33:43,770
And we won't dwell on most of these,
but why is there backslash double quote,

734
00:33:43,770 --> 00:33:44,830
do you think?

735
00:33:44,830 --> 00:33:48,010
Why is there this weird sequence of
characters, backslash double quote,

736
00:33:48,010 --> 00:33:50,505
why might that be useful?

737
00:33:50,505 --> 00:33:51,380
STUDENT: [INAUDIBLE].

738
00:33:51,380 --> 00:33:56,594

739
00:33:56,594 --> 00:33:57,760
DAVID MALAN: Exactly, right?

740
00:33:57,760 --> 00:34:01,830
Think back to our hello world program
that we've seen quite a few times now,

741
00:34:01,830 --> 00:34:05,880
every time we've seen that hello world
program we've had double quotes inside

742
00:34:05,880 --> 00:34:08,210
of which is hello comma
world backslash n.

743
00:34:08,210 --> 00:34:10,070
But think to yourself,
what if you actually

744
00:34:10,070 --> 00:34:12,520
wanted to print out a quotation mark?

745
00:34:12,520 --> 00:34:16,100
Your first instinct might be, I don't
know why I might want to do-- here,

746
00:34:16,100 --> 00:34:18,780
we can be a little passive
aggressive, hello friend.

747
00:34:18,780 --> 00:34:21,350
We might want to do something like that.

748
00:34:21,350 --> 00:34:25,230
>> But why is this now problematic?

749
00:34:25,230 --> 00:34:28,730
Ignoring the curly quotes aside that
keynote made for us automatically.

750
00:34:28,730 --> 00:34:29,730
Why is this problematic?

751
00:34:29,730 --> 00:34:36,719

752
00:34:36,719 --> 00:34:37,270
>> Exactly.

753
00:34:37,270 --> 00:34:39,022
Because we have like 4 quotation marks.

754
00:34:39,022 --> 00:34:41,230
Well the first one probably
goes with the second one,

755
00:34:41,230 --> 00:34:43,271
and maybe the fourth one
goes with the third one,

756
00:34:43,271 --> 00:34:46,170
or, I mean I'm not even sure,
nor is the computer going to be.

757
00:34:46,170 --> 00:34:48,352
Computers again, compilers
again, are fairly dumb.

758
00:34:48,352 --> 00:34:50,060
They'll only do what
you tell them to do.

759
00:34:50,060 --> 00:34:54,270
And if you're not unambiguous they
are probably going to throw an error.

760
00:34:54,270 --> 00:34:57,700
>> If you're not unambiguous as to how to
make a peanut butter and jelly sandwich

761
00:34:57,700 --> 00:34:59,510
strange things might arrive.

762
00:34:59,510 --> 00:35:00,580
It's the same idea.

763
00:35:00,580 --> 00:35:03,100
Now suffice it to say there's
some other escape sequences,

764
00:35:03,100 --> 00:35:04,820
but we'll come to those before long.

765
00:35:04,820 --> 00:35:07,410
Essentially these escape
sequences represent something

766
00:35:07,410 --> 00:35:10,480
that you might not be able
too easily at the keyboard,

767
00:35:10,480 --> 00:35:12,010
without confusing the computer.

768
00:35:12,010 --> 00:35:15,733
>> Now meanwhile we have
placeholders in printf.

769
00:35:15,733 --> 00:35:19,630
Percent d, which can also be written
in almost all cases as percent i,

770
00:35:19,630 --> 00:35:21,610
is a placeholder for what type of data?

771
00:35:21,610 --> 00:35:23,920
What type of value?

772
00:35:23,920 --> 00:35:24,920
A decimal number.

773
00:35:24,920 --> 00:35:27,234
So actually we'll start
using percent i because it's

774
00:35:27,234 --> 00:35:28,650
a little simpler, like an integer.

775
00:35:28,650 --> 00:35:29,550
Percent i.

776
00:35:29,550 --> 00:35:31,320
An integer that happens to be decimal.

777
00:35:31,320 --> 00:35:35,690
>> Percent s we already said was
a placeholder for a string.

778
00:35:35,690 --> 00:35:38,630
Which is just a word, a phrase,
a paragraph, an essay, whatever.

779
00:35:38,630 --> 00:35:40,830
It's a sequence of
characters of some length.

780
00:35:40,830 --> 00:35:42,820
And we'll see before long
some of these others.

781
00:35:42,820 --> 00:35:45,950
But percent c is for a single character.

782
00:35:45,950 --> 00:35:48,500
Percent f is for a
floating point number,

783
00:35:48,500 --> 00:35:50,860
like a real number that has
a decimal point in it, which

784
00:35:50,860 --> 00:35:52,550
is of course not an integer.

785
00:35:52,550 --> 00:35:54,670
And there's a whole
bunch of others as well.

786
00:35:54,670 --> 00:35:56,990
>> Meanwhile in C, and
in a lot of languages,

787
00:35:56,990 --> 00:35:58,650
we have different data types.

788
00:35:58,650 --> 00:36:00,650
Different types of
glass bowls if you will.

789
00:36:00,650 --> 00:36:03,830
The bowl I used last time
was for ping pong balls,

790
00:36:03,830 --> 00:36:06,990
but we can also store different
values like chars and strings

791
00:36:06,990 --> 00:36:10,820
and integers in a container,
like a variable, and C has these.

792
00:36:10,820 --> 00:36:14,020
Char is the type of data,
the type of variable,

793
00:36:14,020 --> 00:36:15,700
in which you can store a character.

794
00:36:15,700 --> 00:36:19,560
Float is a type of variable in
which you can store a real number.

795
00:36:19,560 --> 00:36:21,220
>> Int is of course for an int.

796
00:36:21,220 --> 00:36:23,760
And rather ridiculously
named a long long

797
00:36:23,760 --> 00:36:26,830
is where you can store essentially
a really long number, with even

798
00:36:26,830 --> 00:36:29,930
more digits then a
typical int might store.

799
00:36:29,930 --> 00:36:32,420
But we'll come back to that before long.

800
00:36:32,420 --> 00:36:35,520
>> In CS50 dot h meanwhile
the other header file

801
00:36:35,520 --> 00:36:37,630
that we've seen a couple
times in use, there's

802
00:36:37,630 --> 00:36:41,350
two other data types that
don't exist in C typically.

803
00:36:41,350 --> 00:36:45,000
One is string, and we'll see in
a few weeks what strings really

804
00:36:45,000 --> 00:36:46,610
are underneath the hood.

805
00:36:46,610 --> 00:36:47,950
And one is bool.

806
00:36:47,950 --> 00:36:51,650
And a bool is a variable that
can only take on certain values.

807
00:36:51,650 --> 00:36:54,370
And just based on last week's
explanation of Scratch,

808
00:36:54,370 --> 00:36:56,680
and more recently C,
what would you guess

809
00:36:56,680 --> 00:37:01,770
are the two possible values for
some container that is of type bool?

810
00:37:01,770 --> 00:37:02,860
>> Yes and no.

811
00:37:02,860 --> 00:37:03,870
One and zero.

812
00:37:03,870 --> 00:37:04,502
True or false.

813
00:37:04,502 --> 00:37:07,460
And indeed it's the last that tends
to be conventional in a programming

814
00:37:07,460 --> 00:37:10,030
language, saying something
like true or false.

815
00:37:10,030 --> 00:37:13,160
>> Meanwhile the CS50 library comes
with a bunch of functionality

816
00:37:13,160 --> 00:37:16,640
that the staff wrote for you,
besides just getting a string.

817
00:37:16,640 --> 00:37:20,910
We wrote in advance functions that
can get an integer from the user,

818
00:37:20,910 --> 00:37:22,990
get a single character,
get a float, that

819
00:37:22,990 --> 00:37:25,160
is just a number with the decimal point.

820
00:37:25,160 --> 00:37:28,290
Get a long long, a really
big value from the user.

821
00:37:28,290 --> 00:37:30,930
So we've only seen this in
action in the form of GetString.

822
00:37:30,930 --> 00:37:33,230
But via these functions
will soon be able to write

823
00:37:33,230 --> 00:37:36,070
programs that get input from the user.

824
00:37:36,070 --> 00:37:39,230
>> Meanwhile consider this
program, and consider

825
00:37:39,230 --> 00:37:42,600
how we might now start to add
to it with new constructs.

826
00:37:42,600 --> 00:37:44,530
A quick whirlwind tour
and then we'll look

827
00:37:44,530 --> 00:37:47,340
at some writing some
programs manually ourselves.

828
00:37:47,340 --> 00:37:49,700
Henceforth if we want to
implement a condition,

829
00:37:49,700 --> 00:37:52,790
it's not going to look like a
nice little pretty puzzle piece.

830
00:37:52,790 --> 00:37:54,460
It's going to look a little more arcane.

831
00:37:54,460 --> 00:37:57,620
But this is the canonical
structure of a condition in C.

832
00:37:57,620 --> 00:38:00,380
>> The word if, two
parentheses, inside of which

833
00:38:00,380 --> 00:38:02,590
is going to be some kind
of Boolean expression.

834
00:38:02,590 --> 00:38:04,999
Now the slash slash
in the middle, this is

835
00:38:04,999 --> 00:38:07,290
at the moment sort of like
pseudocode code placeholder.

836
00:38:07,290 --> 00:38:11,576
But more properly, any line of code
in C that starts with slash slash

837
00:38:11,576 --> 00:38:12,850
is a comment.

838
00:38:12,850 --> 00:38:15,920
>> It's like a sticky note that you might
put on an essay, printed on paper.

839
00:38:15,920 --> 00:38:17,290
It's a note to yourself.

840
00:38:17,290 --> 00:38:20,100
It has no functional
impact on the program.

841
00:38:20,100 --> 00:38:23,580
It's sort of a reminder, it's your own
documentation as to what's going on.

842
00:38:23,580 --> 00:38:25,720
So do this at the moment
is sort of a placeholder

843
00:38:25,720 --> 00:38:27,560
for whatever's inside
of those curly braces

844
00:38:27,560 --> 00:38:29,810
eventually is going to do something.

845
00:38:29,810 --> 00:38:35,160
>> Meanwhile you have two forks in the
road, an if else construct like this.

846
00:38:35,160 --> 00:38:37,024
You can if, elseif, else.

847
00:38:37,024 --> 00:38:39,690
Now it's worth noting, especially
if you've been Googling around

848
00:38:39,690 --> 00:38:42,480
online for resources out of
curiosity, or if you pick up

849
00:38:42,480 --> 00:38:44,575
one of the course's
recommended books on C,

850
00:38:44,575 --> 00:38:48,430
you will see that humans have lots
of different preferences for how

851
00:38:48,430 --> 00:38:50,510
to express themselves in code.

852
00:38:50,510 --> 00:38:53,800
Some people like to put the
curly braces as I've done here.

853
00:38:53,800 --> 00:38:57,760
Some people like to put the curly
braces for instance up here.

854
00:38:57,760 --> 00:39:01,700
>> Some people like to put the elses
up here and then this over here.

855
00:39:01,700 --> 00:39:05,120
There's any number of ways to
write code, and none of them

856
00:39:05,120 --> 00:39:06,566
are right per se.

857
00:39:06,566 --> 00:39:08,440
Although there's a few
that are pretty wrong.

858
00:39:08,440 --> 00:39:11,315
But there are no-- if this is
ultimately a very religious debate.

859
00:39:11,315 --> 00:39:13,940
In fact, one of the most annoying
things about computer science

860
00:39:13,940 --> 00:39:16,310
is how opinionated
computer scientists can be.

861
00:39:16,310 --> 00:39:19,880
And you will find over time that
even you develop personal preferences

862
00:39:19,880 --> 00:39:22,130
as to how your code should look.

863
00:39:22,130 --> 00:39:27,162
>> Not just behave, not just create output,
but how it should look aesthetically.

864
00:39:27,162 --> 00:39:30,120
So what we will do is guide you along
the way toward, for now at least,

865
00:39:30,120 --> 00:39:34,825
a standard CS50 style that at least
keeps things uniform and easy to read.

866
00:39:34,825 --> 00:39:37,330
But more on those
distinctions before long.

867
00:39:37,330 --> 00:39:41,830
>> A Boolean expression in C, if you
wanted to say if this condition is true

868
00:39:41,830 --> 00:39:44,650
and this other condition is
true, you don't write the word

869
00:39:44,650 --> 00:39:46,610
and, as you would in English.

870
00:39:46,610 --> 00:39:50,580
You instead use ampersand ampersand,
for reasons we'll come back to.

871
00:39:50,580 --> 00:39:54,520
If you want to say or you use two
vertical bars, which on a US keyboard

872
00:39:54,520 --> 00:39:57,650
is generally above the Enter
key next to the backslash.

873
00:39:57,650 --> 00:40:03,080
And this just means if this condition
or this other condition is true do this.

874
00:40:03,080 --> 00:40:05,210
>> Meanwhile there's this
crazy thing, which

875
00:40:05,210 --> 00:40:07,760
you'll have occasion
to use once in awhile.

876
00:40:07,760 --> 00:40:10,390
But it's just an alternative
way to express yourself.

877
00:40:10,390 --> 00:40:12,400
This, for now, let's
stipulate, it's just

878
00:40:12,400 --> 00:40:16,880
another funky way of expressing
if, elseif, elseif, elseif, elseif.

879
00:40:16,880 --> 00:40:19,720
It's just formatted in terms
of cases, where you literally

880
00:40:19,720 --> 00:40:23,420
enumerate the values that
you might want to check for.

881
00:40:23,420 --> 00:40:24,410
>> Meanwhile loops.

882
00:40:24,410 --> 00:40:26,842
We saw a comparison of
Scratch with a loop.

883
00:40:26,842 --> 00:40:29,550
And I'm going to wave my hand at
what each of these things means.

884
00:40:29,550 --> 00:40:33,520
But notice that a loop will very
often start with the keyword for.

885
00:40:33,520 --> 00:40:36,350
Or it will start with the keyword while.

886
00:40:36,350 --> 00:40:41,360
Or it will start with the keyword
do, and end with the keyword while.

887
00:40:41,360 --> 00:40:43,920
>> But what we're about to see
is things more like this.

888
00:40:43,920 --> 00:40:47,950
Here is, in general in C, how you might
declare a variable and give it a value.

889
00:40:47,950 --> 00:40:50,610
In C it doesn't suffice,
like in Scratch, you just

890
00:40:50,610 --> 00:40:52,810
say give me a variable called something.

891
00:40:52,810 --> 00:40:55,960
You have to tell C, and tell
your compiler, more specifically,

892
00:40:55,960 --> 00:40:58,680
what type of value do you
want to put in the glass bowl.

893
00:40:58,680 --> 00:40:59,610
>> Is it an integer?

894
00:40:59,610 --> 00:41:02,210
If so, you have to
literally say int and then

895
00:41:02,210 --> 00:41:04,220
the name of the variable,
then a semicolon.

896
00:41:04,220 --> 00:41:08,050
If you instead wanted string and called
it s like I did my code here today,

897
00:41:08,050 --> 00:41:10,920
you would say string s semicolon.

898
00:41:10,920 --> 00:41:14,200
Once you want to give it a value
you can then use the equal sign,

899
00:41:14,200 --> 00:41:16,211
otherwise known as the
assignment operator.

900
00:41:16,211 --> 00:41:17,960
And notice how each
of these lines of code

901
00:41:17,960 --> 00:41:20,650
has the semicolon at the end of it.

902
00:41:20,650 --> 00:41:22,550
>> But frankly this just
looks a little ugly.

903
00:41:22,550 --> 00:41:26,580
Why can't I say to the computer, give
me a variable and initialize it to zero.

904
00:41:26,580 --> 00:41:28,380
That is, give me an empty glass bowl.

905
00:41:28,380 --> 00:41:28,980
While you can.

906
00:41:28,980 --> 00:41:32,250
And so one of the judgment calls you'll
have to make stylistically over time

907
00:41:32,250 --> 00:41:36,290
is, do you write your code like this, or
do you kind of clean it up and impress

908
00:41:36,290 --> 00:41:39,040
people by writing two lines as just one.

909
00:41:39,040 --> 00:41:41,830
And this would be considered
generally a more elegant way

910
00:41:41,830 --> 00:41:43,870
of writing your code stylistically.

911
00:41:43,870 --> 00:41:45,200
>> Functions we're of course seen.

912
00:41:45,200 --> 00:41:46,340
They're going to take this format.

913
00:41:46,340 --> 00:41:48,881
The name of a function, some
parentheses, and then maybe some

914
00:41:48,881 --> 00:41:49,910
stuff inside.

915
00:41:49,910 --> 00:41:52,540
Or you might see uses of
multiple functions side

916
00:41:52,540 --> 00:41:55,980
by side, like something like this.

917
00:41:55,980 --> 00:41:59,390
Now as a tangent, does
this joke now make sense?

918
00:41:59,390 --> 00:42:03,566

919
00:42:03,566 --> 00:42:04,960
>> [LAUGHTER]

920
00:42:04,960 --> 00:42:09,360
It doesn't mean it's funny, but it
does perhaps make a little more sense.

921
00:42:09,360 --> 00:42:12,140
So now let's go into the
CS50 appliance for a moment.

922
00:42:12,140 --> 00:42:14,640
And let me open up one teaser here.

923
00:42:14,640 --> 00:42:17,470
>> And indeed one of the reasons
for introducing IKEA catalog

924
00:42:17,470 --> 00:42:20,080
and flashing the picture
of the iPhone a bit ago

925
00:42:20,080 --> 00:42:24,700
was to actually tie in together the
fact that just a few years ago, in 2007,

926
00:42:24,700 --> 00:42:26,540
this piece of code was
released, which was

927
00:42:26,540 --> 00:42:29,820
one of the very first implementation
of a piece of software

928
00:42:29,820 --> 00:42:31,494
that does what's called jailbreaking.

929
00:42:31,494 --> 00:42:34,410
For those unfamiliar, jailbreaking
something like a phone or an iPhone

930
00:42:34,410 --> 00:42:37,680
means essentially figuring
out how to do things

931
00:42:37,680 --> 00:42:39,864
with it that the company
who made it didn't intend.

932
00:42:39,864 --> 00:42:42,780
Like you want to install certain
software that's not in the app store,

933
00:42:42,780 --> 00:42:45,405
jailbreaking your phone which
you do things like that and more.

934
00:42:45,405 --> 00:42:47,447
But what was fun in
2007-- and there's been

935
00:42:47,447 --> 00:42:49,780
dozens of different versions
of these things since then,

936
00:42:49,780 --> 00:42:53,540
in all sorts of languages-- is that
this program here, called iUnlock,

937
00:42:53,540 --> 00:42:57,036
was actually written in C. And so I
pulled up the source code for this,

938
00:42:57,036 --> 00:42:59,910
just to kind of show you some of
the similarities with the constructs

939
00:42:59,910 --> 00:43:01,450
we've been discussing thus far.

940
00:43:01,450 --> 00:43:05,150
Now there's way more complexity here
than we've seen already in class.

941
00:43:05,150 --> 00:43:07,160
Let me scroll up just a little bit here.

942
00:43:07,160 --> 00:43:11,520
>> But notice these-- well we notice a few
things-- but notice these lines here,

943
00:43:11,520 --> 00:43:14,090
including standard I/O dot h.

944
00:43:14,090 --> 00:43:17,660
And all-- line 24, please--
notice standard I/O

945
00:43:17,660 --> 00:43:21,380
dot h and a whole bunch of other
files that apparently other people

946
00:43:21,380 --> 00:43:22,160
have written.

947
00:43:22,160 --> 00:43:24,850
And if we scroll down through
this, little arbitrarily,

948
00:43:24,850 --> 00:43:27,910
notice I don't know how to write
all of this myself necessarily yet,

949
00:43:27,910 --> 00:43:28,880
but there's if.

950
00:43:28,880 --> 00:43:30,400
So apparently this has a branch.

951
00:43:30,400 --> 00:43:33,210
>> And if I scroll down a little
further there's another if.

952
00:43:33,210 --> 00:43:38,210
If I scroll up, I think
around line 100 I saw for.

953
00:43:38,210 --> 00:43:40,020
So I'm not quite sure
how this works yet,

954
00:43:40,020 --> 00:43:43,180
but this is a for loop that's going to
let me iterate some number of times.

955
00:43:43,180 --> 00:43:45,230
And if I scroll all
the way to the bottom

956
00:43:45,230 --> 00:43:51,020
I see that there's a
function down here called

957
00:43:51,020 --> 00:43:54,570
main, and some additional credits
for your reading pleasure.

958
00:43:54,570 --> 00:43:57,830
>> So this is only to say-- and we'll put
this online among the course's source

959
00:43:57,830 --> 00:44:01,480
code today-- that even some of these
devices that we take for granted,

960
00:44:01,480 --> 00:44:05,130
at the end of the day you're still
using these basic constructs that we've

961
00:44:05,130 --> 00:44:07,430
been introducing already thus far.

962
00:44:07,430 --> 00:44:08,620
That's enough of that one.

963
00:44:08,620 --> 00:44:11,480
All right, so now let's
actually build something.

964
00:44:11,480 --> 00:44:15,640
>> Let's go beyond something like
hello.c, and open up this,

965
00:44:15,640 --> 00:44:17,170
let's write this program here.

966
00:44:17,170 --> 00:44:19,850
I'm going to go ahead and
write a program called adder.c,

967
00:44:19,850 --> 00:44:23,310
whose purpose in life is going to be
like my first super simple calculator

968
00:44:23,310 --> 00:44:24,840
that just adds a couple of numbers.

969
00:44:24,840 --> 00:44:27,050
Not because that's a hard
problem, but because it

970
00:44:27,050 --> 00:44:29,390
allows me to now tie
together a few things.

971
00:44:29,390 --> 00:44:33,100
So I'm going to go ahead and include
standard I/O dot h and CS50 dot h.

972
00:44:33,100 --> 00:44:34,670
I'm going to say int main void.

973
00:44:34,670 --> 00:44:36,545
And again in the future
we'll come back to it

974
00:44:36,545 --> 00:44:38,560
into in this context and void means.

975
00:44:38,560 --> 00:44:43,340
>> And now I'm going to say something
like printf, give me an integer.

976
00:44:43,340 --> 00:44:47,610
And now on my second line,
how do I express myself such

977
00:44:47,610 --> 00:44:50,980
that I want to declare a variable
that's going to store an int?

978
00:44:50,980 --> 00:44:55,470
Literally what do I type if I want to
create a variable that stores an int

979
00:44:55,470 --> 00:44:58,270
would you say?

980
00:44:58,270 --> 00:44:59,650
int a equals getint.

981
00:44:59,650 --> 00:45:00,485
Sure, so that works.

982
00:45:00,485 --> 00:45:02,360
And just for consistency
with the code you'll

983
00:45:02,360 --> 00:45:04,485
see online, let me change
this to x, just because x

984
00:45:04,485 --> 00:45:06,830
is a common variable name
to use, at least in algebra.

985
00:45:06,830 --> 00:45:08,720
Now let me go ahead and do printf again.

986
00:45:08,720 --> 00:45:10,692
Give me another integer.

987
00:45:10,692 --> 00:45:12,900
And now I'm going to kind
of learn from that pattern,

988
00:45:12,900 --> 00:45:14,490
I'm going to say int y gets to GetInt.

989
00:45:14,490 --> 00:45:16,340
>> And we've not used
GetInt before, but just

990
00:45:16,340 --> 00:45:19,860
like GetString goes and gets a string,
like Javier did from the audience,

991
00:45:19,860 --> 00:45:22,780
similarly does GetInt
start blinking the prompt.

992
00:45:22,780 --> 00:45:26,750
And effectively waiting for the user
to give it an integer, by typing it in

993
00:45:26,750 --> 00:45:27,900
and hitting Enter.

994
00:45:27,900 --> 00:45:30,850
Now lastly I'm going to do
this, printf the sum of--

995
00:45:30,850 --> 00:45:36,080
and let me get fancy now--
percent i and percent i is present

996
00:45:36,080 --> 00:45:39,270
i exclamation point backslash n.

997
00:45:39,270 --> 00:45:42,750
And what do you think I'm going to
put in now as the additional inputs

998
00:45:42,750 --> 00:45:44,620
to printf?

999
00:45:44,620 --> 00:45:47,380
>> I don't want to say
literally quote unquote x.

1000
00:45:47,380 --> 00:45:52,210
I want to class in x and
then, and now let's get fancy

1001
00:45:52,210 --> 00:45:54,420
and let's just assume
we can do what we want.

1002
00:45:54,420 --> 00:45:56,330
What you want to say next?

1003
00:45:56,330 --> 00:45:57,070
x plus y.

1004
00:45:57,070 --> 00:45:58,520
And indeed that will work.

1005
00:45:58,520 --> 00:46:01,760
It's minimally programming languages
do understand basic arithmetic,

1006
00:46:01,760 --> 00:46:03,500
and so this should in fact work.

1007
00:46:03,500 --> 00:46:06,730
>> So let me go ahead and do make
adder in my black and white window

1008
00:46:06,730 --> 00:46:08,090
down here, Enter.

1009
00:46:08,090 --> 00:46:10,830
Cryptic line but no error
message, so that's good.

1010
00:46:10,830 --> 00:46:14,410
Dot slash adder, give me an integer, 1.

1011
00:46:14,410 --> 00:46:16,230
Give me another integer, 2.

1012
00:46:16,230 --> 00:46:18,770
The sum of 1 and 2 is 3.

1013
00:46:18,770 --> 00:46:21,730
>> All right, so a pretty trivial
program, but what's it done?

1014
00:46:21,730 --> 00:46:25,680
It's allowed me to use a function
call here, call another function here,

1015
00:46:25,680 --> 00:46:29,260
two calls to GetInt, a
third call to printf,

1016
00:46:29,260 --> 00:46:30,720
and then using these placeholders.

1017
00:46:30,720 --> 00:46:33,160
So it's a little more
sophisticated than last time.

1018
00:46:33,160 --> 00:46:35,260
But what if I want to
get a little fancier?

1019
00:46:35,260 --> 00:46:38,900
>> Let me go ahead and now do this.

1020
00:46:38,900 --> 00:46:42,890
Let me go ahead and create a
new file called conditions zero.

1021
00:46:42,890 --> 00:46:44,890
And I'm going to save
some time for classes sake

1022
00:46:44,890 --> 00:46:48,260
and just paste in that
code as a starting point.

1023
00:46:48,260 --> 00:46:51,510
And now I'm just going to put
something new here in the middle.

1024
00:46:51,510 --> 00:46:55,889
So printf I'd like an integer please.

1025
00:46:55,889 --> 00:46:58,180
And all this code is available
on the course's website,

1026
00:46:58,180 --> 00:47:00,556
you needn't type it all out
in class if you'd rather not.

1027
00:47:00,556 --> 00:47:02,638
int, and now I'm going to
use, instead of x and y,

1028
00:47:02,638 --> 00:47:05,270
I'm going to use n, which is
probably the most common name

1029
00:47:05,270 --> 00:47:09,220
for an integer in a computer program.

1030
00:47:09,220 --> 00:47:12,060
And now I want to do a
little judgment here.

1031
00:47:12,060 --> 00:47:15,460
I'm going to see if n
is greater than 0, then

1032
00:47:15,460 --> 00:47:23,670
I'm going to say printf-- whoops,
printf-- you picked a positive number,

1033
00:47:23,670 --> 00:47:25,370
exclamation point backslash n.

1034
00:47:25,370 --> 00:47:26,460
Close that.

1035
00:47:26,460 --> 00:47:33,150
Else I'm going to print out printf
you picked a negative number.

1036
00:47:33,150 --> 00:47:35,377
>> Now before you yell at me,
let's run this program.

1037
00:47:35,377 --> 00:47:36,210
Let me go down here.

1038
00:47:36,210 --> 00:47:40,730
And how do I compile a program
called conditions dash 0?

1039
00:47:40,730 --> 00:47:42,300
Make conditions dash 0.

1040
00:47:42,300 --> 00:47:45,560
Kind of a stupid name, but-- dammit.

1041
00:47:45,560 --> 00:47:47,560
OK, good teaching moment.

1042
00:47:47,560 --> 00:47:48,410
Why did that break?

1043
00:47:48,410 --> 00:47:51,360

1044
00:47:51,360 --> 00:47:54,710
>> What did I accidentally call this file?

1045
00:47:54,710 --> 00:47:56,876
You can kind of infer
from the tab up here.

1046
00:47:56,876 --> 00:47:58,750
So it's not bad that I
did this, because this

1047
00:47:58,750 --> 00:48:00,208
will happen perhaps to some of you.

1048
00:48:00,208 --> 00:48:03,880
So I accidentally named my
source code condition 0.

1049
00:48:03,880 --> 00:48:09,950
But my source code by convention should
be in a file called condition 0 dash c,

1050
00:48:09,950 --> 00:48:11,720
or whatever dot c.

1051
00:48:11,720 --> 00:48:12,610
>> So let me fix this.

1052
00:48:12,610 --> 00:48:16,880
Just like Microsoft Word I can go up
to Save As and do condition 0 dot c.

1053
00:48:16,880 --> 00:48:20,100
Now just to be tidy I'm
going to go ahead and remove

1054
00:48:20,100 --> 00:48:23,020
condition 0, which was my old version.

1055
00:48:23,020 --> 00:48:26,550
And now let's do make
condition 0, Enter.

1056
00:48:26,550 --> 00:48:27,870
OK, seems good.

1057
00:48:27,870 --> 00:48:29,510
>> Condition 0, Enter.

1058
00:48:29,510 --> 00:48:33,530
I'd like an integer please, 50,
you picked a positive number.

1059
00:48:33,530 --> 00:48:35,390
Now how about negative 50?

1060
00:48:35,390 --> 00:48:37,660
You picked a negative number.

1061
00:48:37,660 --> 00:48:39,605
How about now, 0.

1062
00:48:39,605 --> 00:48:42,250

1063
00:48:42,250 --> 00:48:45,350
Pretty sure 0's not negative.

1064
00:48:45,350 --> 00:48:47,780
>> So this is kind of a logical bug.

1065
00:48:47,780 --> 00:48:50,680
How do I fix this?

1066
00:48:50,680 --> 00:48:57,260
Else if n is less than 0, do this, else
we can have a three way branch here,

1067
00:48:57,260 --> 00:49:01,740
printf you picked 0.

1068
00:49:01,740 --> 00:49:06,150
So now if I rerun this
program, after compiling it

1069
00:49:06,150 --> 00:49:10,790
again with make, and now rerun
condition 0, what I'll see here

1070
00:49:10,790 --> 00:49:14,570
is 0 gives me that output.

1071
00:49:14,570 --> 00:49:16,280
So where are we going with this?

1072
00:49:16,280 --> 00:49:18,930
>> Well it's very easy to lose sight
of the forest for the trees.

1073
00:49:18,930 --> 00:49:23,590
And so allow us to conclude
with this 2 and 1/2 minute video

1074
00:49:23,590 --> 00:49:25,710
that ultimately is a bit
of an ad from Google,

1075
00:49:25,710 --> 00:49:28,850
but that really is testament to
what even using these basic building

1076
00:49:28,850 --> 00:49:33,020
blocks we can ultimately do once
we have a bit of programming

1077
00:49:33,020 --> 00:49:34,463
savvy under our belts.

1078
00:49:34,463 --> 00:49:35,150
>> [MUSIC PLAYING]

1079
00:49:35,150 --> 00:49:38,370

1080
00:49:38,370 --> 00:49:40,540
>> SAROO BRIERLEY (VOICEOVER):
It was 26 years ago,

1081
00:49:40,540 --> 00:49:42,470
and I was just about to turn 5.

1082
00:49:42,470 --> 00:49:45,465
We got to the train station and
we boarded our train together.

1083
00:49:45,465 --> 00:49:48,010
My brother just said I'll
stay here, and I'll come back.

1084
00:49:48,010 --> 00:49:51,140
And I just thought, well you know,
I might as well just go to sleep

1085
00:49:51,140 --> 00:49:52,690
and he'll just wake me up.

1086
00:49:52,690 --> 00:49:55,145
And when I woke up the next
day, the whole carriage

1087
00:49:55,145 --> 00:49:59,125
was empty on a runaway train, a ghost
train taking me I don't know where.

1088
00:49:59,125 --> 00:50:01,980

1089
00:50:01,980 --> 00:50:06,280
>> I was adopted out to Australia,
to an Australian family.

1090
00:50:06,280 --> 00:50:09,710
And mom had decorated my
room with the map of India,

1091
00:50:09,710 --> 00:50:11,950
which she put next to my bedside.

1092
00:50:11,950 --> 00:50:15,830
I woke up every morning
seeing that map, and hence

1093
00:50:15,830 --> 00:50:18,530
it sort of kept the memories alive.

1094
00:50:18,530 --> 00:50:20,530
People would say, you're
trying to find a needle

1095
00:50:20,530 --> 00:50:23,560
in a haystack, Saroo
you'll never find it.

1096
00:50:23,560 --> 00:50:28,540
>> I'd have flashed of the places that I
used to go, the flashes of my family

1097
00:50:28,540 --> 00:50:29,890
faces.

1098
00:50:29,890 --> 00:50:34,060
There was the image of my mother,
sitting down with her legs crossed,

1099
00:50:34,060 --> 00:50:35,740
just watching her cry.

1100
00:50:35,740 --> 00:50:38,160
Life is just so hard.

1101
00:50:38,160 --> 00:50:41,237
That was my treasure.

1102
00:50:41,237 --> 00:50:44,320
And I was looking at Google Map and
realized there's Google Earth as well.

1103
00:50:44,320 --> 00:50:48,140
In a world where you could zoom into,
I started to have all of these thoughts

1104
00:50:48,140 --> 00:50:51,500
and what possibilities
that this could do for me.

1105
00:50:51,500 --> 00:50:54,890
I said to myself, you know, you've
got all those photographic memories

1106
00:50:54,890 --> 00:50:58,590
and landmarks where you're from, and
you know what the town looks like.

1107
00:50:58,590 --> 00:51:03,060
This could be an application that
you can use to find your way back.

1108
00:51:03,060 --> 00:51:06,720
>> I thought, well I'll put a
dot on Calcutta train station,

1109
00:51:06,720 --> 00:51:10,890
and a radius line, you know, that you
should be searching around this area.

1110
00:51:10,890 --> 00:51:13,750
I sort of came across
these train tracks.

1111
00:51:13,750 --> 00:51:18,160
And I started following it, and
I came to a train station which

1112
00:51:18,160 --> 00:51:22,228
reflected the same image
that was in my memories.

1113
00:51:22,228 --> 00:51:23,707
Everything matched.

1114
00:51:23,707 --> 00:51:27,950
I just thought yep, I
know where I'm going.

1115
00:51:27,950 --> 00:51:30,116
I'm just going to let the
map that I have in my head

1116
00:51:30,116 --> 00:51:33,080
lead me and take me back to my hometown.

1117
00:51:33,080 --> 00:51:36,420
>> I came to the doorstep of
the house that I was born.

1118
00:51:36,420 --> 00:51:39,140
And walked around about 15
meters around the corner,

1119
00:51:39,140 --> 00:51:42,980
there was three ladies standing
outside, adjacent to each other.

1120
00:51:42,980 --> 00:51:47,830
And the middle one stepped forward, and
I just thought, this is your mother.

1121
00:51:47,830 --> 00:51:53,450
She came forward, she hugged me, and
we were there for about five minutes.

1122
00:51:53,450 --> 00:51:56,530

1123
00:51:56,530 --> 00:51:59,000
>> She grabbed my hand and
she took me to the house

1124
00:51:59,000 --> 00:52:02,450
and got on the phone, where she
rang my sister and my brother

1125
00:52:02,450 --> 00:52:05,600
to say that, you know,
your brother has just

1126
00:52:05,600 --> 00:52:09,340
all of sudden appeared like a ghost.

1127
00:52:09,340 --> 00:52:12,440
And then the family was reunited again.

1128
00:52:12,440 --> 00:52:15,110
Everything's all good,
I helped my mother out,

1129
00:52:15,110 --> 00:52:17,110
she doesn't have to be slaving away.

1130
00:52:17,110 --> 00:52:19,555
She can live the rest
of her life in peace.

1131
00:52:19,555 --> 00:52:23,460
>> It was a needle in a haystack,
but the needle was there.

1132
00:52:23,460 --> 00:52:24,400
Everything's there.

1133
00:52:24,400 --> 00:52:28,260
Everything we have in the world
is at the tap of a button.

1134
00:52:28,260 --> 00:52:32,010
But you've got to have the will and
the determination to wanting it.

1135
00:52:32,010 --> 00:52:32,950
>> [MUSIC PLAYING]

1136
00:52:32,950 --> 00:52:36,420

1137
00:52:36,420 --> 00:52:38,170
DAVID MALAN: Wonderfully
sweet testimonial

1138
00:52:38,170 --> 00:52:40,540
to just what you can
now do with technology.

1139
00:52:40,540 --> 00:52:43,390
We will see you next week.

1140
00:52:43,390 --> 00:52:44,374