CS110_01a_intro - EECS 110: 1a Intro Introduction to...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: EECS 110: 1a Intro Introduction to Computer Programming 1 Class Meeting Places MWF at 10:00AM Tech, M-177 (this room) Tues at 10:00AM Tech, M-177 DECIDE: ? How many have laptops? PC? Mac? Linux? ? Wireless Internet access OK here? ? Can we work on problems here, or Do we need a dedicated lab for it? 2 CS 110 Instructor Name: Jack Tumblin, EECS Dept, MEAS Office: Ford Design Center, Rm 3-341 E-mail: jet@cs.northwestern.edu Office Hours: Sigh. Check TAs? Discussion board? Well OK; let's talk after class, or make an appt. Phone: (847)-467-2129 (use very sparingly) Book: "Computer Science: A Structured Programming Approach using C" 3rd Edition, Forouzan & Gilberg 3 Resources Other instructor's webpage; http://www.cs.northwestern.edu/academ ics/courses/110/index.html I use Blackboard / CMS... Use to download class notes and assignments access helpful tutorials look up information about the class (e.g. policies) look up your grades 4 Resources Class `Discussion Board' Use Course Management System... Use to discuss class material, ask questions on the material or the assignments (but NEVER post assignment solutions!) Share ideas / strategies for interesting projects... 5 What is a Calculator? What is a Computer? What's the difference? A very vague notion in our textbook-- But history makes it plain and clear... 6 What is a `Calculator'? Before 1940s & Manhattan Project: A meticulous person employed to make large series of numerical calculations. for fluid flow, ballistics, trig. tables, bombs, etc... Sometimes helped by using `mechanical calculating machines' See: http://www.lanl.gov/worldview/welcome/history/22_computers.html 7 What does a `Calculator' do? Before 1940s & Manhattan Project: (Women were consistently and by far the best calculators...) Teams of calculators would: Read card(s) with list(s) of numbers Follow step-by-step instructions to compute new numbers Write new numbers, arrange new cards Tabulate, print, or graph results. 8 What does a `Calculator' do? Before 1940s & Manhattan Project: (Women were consistently the best calculators by far...) Teams of calculators would: Read card(s) with list(s) of numbers Follow step-by-step instructions to compute new numbers "Input Data" "Process Data" Write new numbers, arrange new cards Tabulate, print, or graph results. "Output Data" 9 What is a `Calculator'? Answer: a reliable instruction follower for modifying numbers (`data'). "Input Data" "Process Data" "Output Data" Read Numbers Follow Fixed Instructions to make new numbers Write Numbers 10 What is `Data'? "Input Data" "Process Data" "Output Data" `Data': numbers with assigned meanings Numbers can mean anything! Alphabet letters: 41=A, 42=B, 43=C, ...(ASCII code) Colors: 0=Black, 128=Gray, 255=White... Decisions: 0=No, 1=Yes, 0.5=Maybe... Data formats? Can be *ANY* rules you define! 11 And what is `input and output'? Input/Output: conversion between meaningful things numbers Arm & finger moves (mouse, joystick, keyboard) Text, spelling, grammar, analogy, reasoning... Molecules, synapses, neural signalling, brains... Music, speech, noise, vibration, resonance... Image, picture, vision, sketch, light, shadow... Robotics, actuator movement, collision, routes... Fluid flow, compression, shock waves,... **AND MUCH MORE**, even abstract ideas! Computer programming: ideas instructions 12 What is an `Algorithm' ? A sequence of instructions that: are completely unambiguous & repeatable; Anyone can follow (even a machine); Create a useful answer/result (provably correct?) Algorithm Examples: Hokey-Pokey Construct Peanut-butter-and-Jelly Sandwich Compute a factorial (Recursion!) 13 What is a Computer? Now suppose that we have a calculator, PLUS: A stupendously vast list of changeable numbers (memory) Calculator buttons that read from/write to that list (I/O) An `ID#' for each and every calculator button: (instruction set) 10 = `add', 11 = `subtract', 12 = `equals', 13= `read'... A `button pusher': Use calculator answer as button ID#... ( (Instruction Sequencer) A `rule-follower' that can change its own rules! THIS is a computer! a "unified, stored program, stored data" device... 14 What is a `Computer' ? "Input Data" "Process Data" "Output Data" Read Numbers Long list of numbers "Instruction Follower" "Instructions" (numbers) ------------------"Data" (numbers) Write Numbers 15 Try again: What is a Computer? A "rule-following engine" that Converts any kind of `input data' to any kind of `output data' by following `instructions' that it can change, just like the data ! "A calculator that pushes its own buttons" Storage for lists of numbers (`memory'). numbered instructions ("10 means `add'...") ability to follow instructions stored as numbers 16 Why Bother with Computers? A computer is: A fast, tireless, rule-following machine An engine to mimic ANY rule-based system Is thinking a rule-based system? Biology? Music? Economics? Vision? Hearing? Carbon Nanotubes? Quantum Dots? Polymerization? Government? Tourism? Photography? Navigation? Good rule-based abstractions exist for almost ANY problem... (including `how can I write a good program') 17 Don't Panic: Programming == 8 Nested Parts All brilliant ideas are simple F=mA, `be nice to people',etc. Good Writing != (is not equal to) Keyboard Skills, Typesetting Mechanical Engineering != Metal-Shop skills Computer Science != Programming Example: C Programming == Just 4 kinds of instructions: "Read inputs, create outputs" "Do this list of steps" "If (A is true) , do that list of steps" "Repeat this list of steps until A is false". (I/0) (arithmetic, relational, logical, functions) (conditional) (loops, recursion) All the rest (entire book contents) are minor details, elaborations, and shortcuts to make things easier... 18 `Structured': How C is Organized Literals and Variables (with their `data types') Operators Expressions Statements Functions Libraries Programs `Systems' (e.g. OS-X, TCP/IP, Web) 19 What You Will Learn How to define and solve any finite problem by: writing orderly sets of rules (functions) that are applied to orderly sets of data (structures), and Re-using earlier solutions (libraries)--much less tedium. Core ideas found in ALL programming languages The Code::Blocks "programming environment"; one good, free tool among the many available (e.g. Xcode, Visual Studio, Eclipse, CoCo, DevC++, Eric, ...) 20 Conclusions Lets Get Started! As soon as you can, Read Chapter 1, start Chapter 2 of textbook Bring laptops to class we'll use them. Get, Install Code::Blocks ==Download from BLACKBOARD! Be nice -- don't overload the website http://www.codeblocks.org ==See Blackboard for step-by-step instructions ==We'll try it in class tomorrow, and write a few programs. 21 END END 22 What's a Compiler? A Linker? C is a compiled language; it is meant to be human-readable. `Compiler': a converter program; human-readable machine-executable Compile: C text file(s) Linking: object file(s) object file(s) .executable file 23 What is Programming? Program = A sequence of human-readable instructions. They tell a computer how to do a particular task or solve a particular problem. Programming = Designing, writing, and testing a computer program that works. [Good craftsmanship yields robust results] 24 Programming: Artful Common Sense 1) Analyze: Find the Core Problem (not how to solve it). Decide the specific inputs and outputs, and Define how to make outputs from inputs Break it down into sub-problems, 2) Implement: Write a rule set (a function) for each, 3) Debug: Test each function separately; link a few, test, link, test,... until it all works. 25 1. Analyze: Find the Core Problem House Example: Write a program that computes the square footage of a house, given the dimensions of each room. Input : The number of rooms (an integer) The dimensions of each room (real numbers) Output: The square footage of the house (real numbers) 26 1. Analyze: Find the Core Problem Be sure you really understand problem! Refine, simplify, clarify, think. Repeat. Decompose it into sub-problems First ideas are (almost) NEVER the best ones. House Example: subproblem 1: compute the area of a room subproblem 2: add up area of all rooms 27 2. Implement Translate your sets of rules into C language; (try not to garble it too much). We will learn how by exploring: Variables, Types, Statements, Expressions, Assignments, Conditionals and control flow constructs, functions, and more. 28 3.`Debug': Find & Fix Mistakes Write C Compile Does it compile? NO NO Run, repeat compiler says why. Modify C, try again analyze, modify, try again. YES. Does it work right? YES. But does it ALWAYS work right? (can you prove your analysis is robust?) 29 3. Debug Two Kinds of Programming Mistakes: Syntax Misteaks (easy to fix: compiler helps) Design Mistakes (harder: you must THINK) Computer Jargon: `bug'==mistake To `debug'== to find and fix your mistakes 30 END END 31 ...
View Full Document

Ask a homework question - tutors are online