CS 211:
Introduction to Computer Programming II
| Instructor: Brian M. Dennis | |
| Teaching Assistants: | |
| Tom Lechner, Bin Lin | |
| http://www.cs.northwestern.edu/~bmd/cs211/ | |
| #include <iostream> | |
| using namespace std; | |
| // HelloWorld programs originated with the | |
| // book “The C Programming Language” | |
| main() { | |
| cout << “Hello, World\n”; | |
| } | |
| ;; HelloWorld programs originated with the | |
| ;; book “The C Programming Language” | |
| (display “Hello World”) | |
| (newline) | |
| #include <iostream> | |
| using namespace std; | |
| main() { | |
| cout << “The answer to the universe\n” | |
| << 42; | |
| } |
| #include <iostream> | |
| using namespace std; | |
| main() { | |
| cout << “Pi is: “ << 3.14159f << “\n”; | |
| } |
| #include <iostream> | |
| using namespace std; | |
| main() { | |
| cout << “1 + 1 = “ << 1 + 1 << “\n”; | |
| cout << “2 * 2 = “ << 2 * 2 << “\n”; | |
| cout << “3 – 5 = “ << 3 – 5 << “\n”; | |
| cout << “11 / 2 = “ << 11 / 2 << “\n”; | |
| } |
| #include <iostream> | |
| using namespace std; | |
| main() { | |
| if ((10 % 2) == 0) | |
| cout << “10 is even\n”; | |
| if (5 % 2) | |
| cout << “5 is odd\n”; | |
| if ((5 % 2) != 0) | |
| cout << “5 is odd\n”; | |
| } |
| #include <iostream> | |
| using namespace std; | |
| main() { | |
| int integer_temp = 1 + 1; | |
| cout << “1 + 1 = “ << integer_temp << “\n”; | |
| float floating_point_temp; | |
| floating_point_temp = 1.414f; | |
| cout << “Root 2 = “ << floating_point_temp | |
| << “\n”; | |
| } |
| (let ((integer_temp (+ 1 1)) | |
| (floating_point_temp 1.414)) | |
| (display “1 + 1 = “) | |
| (display integer_temp) | |
| (newline) | |
| (display “Root 2 = “) | |
| (display floating_point_temp) | |
| (newline) | |
| ) |
| (let ((temp (+ 1 1))) | |
| (display “1 + 1 = “) | |
| (display temp) | |
| (newline) | |
| (set! temp 1.414) | |
| (display “Root 2 = “) | |
| (display temp) | |
| (newline) | |
| ) | |
| #include <iostream> | |
| using namespace std; | |
| main() { | |
| int temp = 1 + 1; | |
| cout << “1 + 1 = “ << temp << “\n”; | |
| temp = 1.414; | |
| cout << “Root 2 = “ << temp << “\n”; | |
| } |
| Reading | |||
| SICP | |||
| CH 1 | |||
| D&D Ch1 | |||
| 1.14, 1.19 – 1.25 | |||