1 / 22

Today’s Class

Today’s Class. Introductions About the Course Fundamentals Computer Program - Sequence Parts of a computer Parts of a CPU Writing a really short program Homework. I love programming. 20 year career, then went into something else My dad HATED programming

sofia
Download Presentation

Today’s Class

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Today’s Class • Introductions • About the Course • Fundamentals • Computer • Program - Sequence • Parts of a computer • Parts of a CPU • Writing a really short program • Homework R. Smith - University of St Thomas - Minnesota

  2. I love programming • 20 year career, then went into something else • My dad HATED programming • My own kids never really tried it • Some people will find they love it • Some will hate it, and some are in the middle • The GOAL: to be capableat programming R. Smith - University of St Thomas - Minnesota

  3. Class Survey • Who is sitting next to you? • Their name? Major? • Why are they taking the course? • What computer skills do they bring to this class? R. Smith - University of St Thomas - Minnesota

  4. Class Schedule • I’ll arrive about 5 minutes early or so every day • “Lectures” start at 9:55 AM, Tue/Thu • Ends at 11:35 • “Lab” starts at 10:55 AM M-W-F • Ends at Noon • Both Lecture and Lab will usually start with a new technique R. Smith - University of St Thomas - Minnesota

  5. Syllabus • “Real” syllabus tomorrow • Learning C programming • The basic mechanics • Assignments and variables • Conditionals • Loops • Input/Output • Structure with multiple procedures • Arrays • Learning Matlab • Many of the same concepts • Built in features for mathematical problem solving • Lots and lots of programming R. Smith - University of St Thomas - Minnesota

  6. Grading • I do it “by the numbers” • It’s easy to earn an A-like grade: do the work • It’s easy to flunk: don’t do the work • In between grades: if you skip homework or mess up on exams • General outline of the grade • Part goes to homework • Part goes to exam (a similar weight) • Part goes to final project • I’ll hand out grade sheets with your grade • NO LATE WORK as a rule • Need bona fide reason for late work R. Smith - University of St Thomas - Minnesota

  7. How the class works • Memorization and programming • This is lots and lots of detail work • You work fast if you work from memory • Practice and remember “patterns” that work • Do the Reading! • It gives you another source for programming details • A different way of describing the same stuff • A place to go to answer questions • “Some” problem sets based on the reading • Labs = programming tasks to do • Try to finish DURING lab • If you don’t, then you have extra homework R. Smith - University of St Thomas - Minnesota

  8. Fundamentals • Computer • Program - Sequence • Parts of a computer • Note they are built hierarchically • Parts of a CPU R. Smith - University of St Thomas - Minnesota

  9. C Program • Always in a file • Always defines a ‘function’ to perform • Usually the function is named ‘main’ • We “compile” it to make it work R. Smith - University of St Thomas - Minnesota

  10. Sample C Program #include <stdio.h> int main (void) { printf("Hello, world\n"); return 0; } R. Smith - University of St Thomas - Minnesota

  11. Observations • Case sensitive: match cases “exactly” • Program is worked “in order” from start to end • “Sequences” are fundamental to computing • Curly braces mark “nested” components • “Hierarchies” are fundamental to computing • Learn the “patterns” of typical programming tasks • Setting up the program • Doing output R. Smith - University of St Thomas - Minnesota

  12. “Compiling” - the mechanics • “Command Line” compiling • Should work the same on PCs and Macs • You have to “compile” programs to run them $ gcc hello.c $ • You simply command the computer to run the program $ hello Hello, world! $ R. Smith - University of St Thomas - Minnesota

  13. Homework • Read Chapters 1 through 3 • Find a “C compiler” on a computer you can use • Already installed on 4th floor OSS • May be installed on other campus computers • You can download it and install it at home • For PC: use MinGW, that’s what’s installed here • Write a program that prints your name • Ideally, use your U: drive or a USB drive • Run it and see the result • Print the “C” file. Include an explanation of where you compiled and ran it, and note any problems you had. R. Smith - University of St Thomas - Minnesota

  14. What’s happening next? • A “history” of C • Overview of Statements and Variables • Simple types • Printing out text • The nuts and bolts of compiling programs R. Smith - University of St Thomas - Minnesota

  15. History of C • Interpreting expressions (1940s) • Sort/Merge Generator • A2 Compiler • Fortran • Algol • C R. Smith - University of St Thomas - Minnesota

  16. Statements and Variables • Statements we’ll use • “Function declarations” like main • Always followed by a pair of parentheses, • and then curly braces • Other statements are followed by a “;” • Variable declarations • Assignment statements • Variables • Storage cells in your program • Each one is like a spreadsheet cell, only dumber R. Smith - University of St Thomas - Minnesota

  17. Variable Naming • Naming Structure • First character: A-Z, a-z, _ or $ • Remaining: same plus digits • Style rules • Descriptive names • Usually start with lowercase letter • Camelback: use capitals to mark words • itemsOrdered, totalPayment • DO NOT USE $ to start a name R. Smith - University of St Thomas - Minnesota

  18. “Types” of variables • First use: you say the type • int = “integer” • signed, no decimal part, less than 2G • Examples int sampleInt = 12; sampleInt = 25; R. Smith - University of St Thomas - Minnesota

  19. Printing • The ‘printf()’ function • Syntax of ‘functions’ • Takes 1 or more ‘arguments’ or ‘parameters’ • First argument: “format string” • A string of characters to print • Embedded ‘signals’ to say what else to print (“%” character) • Each ‘signal’ corresponds to a subsequent parameter • Extra parameters • One per format signal R. Smith - University of St Thomas - Minnesota

  20. Blanks, newlines, tabs • “ “ • “Hello” “There” • “Hello There” • \n, \t R. Smith - University of St Thomas - Minnesota

  21. Compiling and Running • What is really happening? • How a program executes • Computer ‘Languages’ • Interpeting • Compiling • Running “real” instructions • What it looks like in RAM R. Smith - University of St Thomas - Minnesota

  22. Creative Commons License This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. R. Smith - University of St Thomas - Minnesota

More Related