Download presentation
Presentation is loading. Please wait.
Published byJasmine Christine Wheeler Modified over 9 years ago
1
March 2005 1R. Smith - University of St Thomas - Minnesota Today’s Class IntroductionsIntroductions About the CourseAbout the Course FundamentalsFundamentals –Computer –Program - Sequence –Parts of a computer –Parts of a CPU Writing a really short programWriting a really short program HomeworkHomework
2
March 2005 2R. Smith - University of St Thomas - Minnesota I love programming 20 year career, then went into something else20 year career, then went into something else My dad HATED programmingMy dad HATED programming My own kids never really tried itMy own kids never really tried it Some people will find they love itSome people will find they love it Some will hate it, and some are in the middleSome will hate it, and some are in the middle The GOAL: to be capable at programmingThe GOAL: to be capable at programming
3
March 2005 3R. Smith - University of St Thomas - Minnesota Class Survey Who is sitting next to you?Who is sitting next to you? Their name? Major?Their name? Major? Why are they taking the course?Why are they taking the course? What computer skills do they bring to this class?What computer skills do they bring to this class?
4
March 2005 4R. Smith - University of St Thomas - Minnesota Class Schedule I’ll arrive about 5 minutes early or so every dayI’ll arrive about 5 minutes early or so every day “Lectures” start at 9:55 AM, Tue/Thu“Lectures” start at 9:55 AM, Tue/Thu –Ends at 11:35 “Lab” starts at 10:55 AM M-W-F“Lab” starts at 10:55 AM M-W-F –Ends at Noon Both Lecture and Lab will usually start with a new techniqueBoth Lecture and Lab will usually start with a new technique
5
March 2005 5R. Smith - University of St Thomas - Minnesota Syllabus “Real” syllabus tomorrow“Real” syllabus tomorrow Learning C programmingLearning C programming –The basic mechanics –Assignments and variables –Conditionals –Loops –Input/Output –Structure with multiple procedures –Arrays Learning MatlabLearning Matlab –Many of the same concepts –Built in features for mathematical problem solving Lots and lots of programmingLots and lots of programming
6
March 2005 6R. Smith - University of St Thomas - Minnesota Grading I do it “by the numbers”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 gradeGeneral 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 gradeI’ll hand out grade sheets with your grade NO LATE WORK as a ruleNO LATE WORK as a rule –Need bona fide reason for late work
7
March 2005 7R. Smith - University of St Thomas - Minnesota How the class works Memorization and programmingMemorization 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!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 doLabs = programming tasks to do –Try to finish DURING lab –If you don’t, then you have extra homework
8
March 2005 8R. Smith - University of St Thomas - Minnesota Fundamentals ComputerComputer Program - SequenceProgram - Sequence Parts of a computerParts of a computer –Note they are built hierarchically Parts of a CPUParts of a CPU
9
March 2005 9R. Smith - University of St Thomas - Minnesota C Program Always in a fileAlways in a file Always defines a ‘function’ to performAlways defines a ‘function’ to perform Usually the function is named ‘main’Usually the function is named ‘main’ We “compile” it to make it workWe “compile” it to make it work
10
March 2005 10R. Smith - University of St Thomas - Minnesota Sample C Program #include #include int main (void) { printf("Hello, world\n"); return 0; return 0;}
11
March 2005 11R. Smith - University of St Thomas - Minnesota Observations Case sensitive: match cases “exactly”Case sensitive: match cases “exactly” Program is worked “in order” from start to endProgram is worked “in order” from start to end –“Sequences” are fundamental to computing Curly braces mark “nested” componentsCurly braces mark “nested” components –“Hierarchies” are fundamental to computing Learn the “patterns” of typical programming tasksLearn the “patterns” of typical programming tasks –Setting up the program –Doing output
12
March 2005 12R. Smith - University of St Thomas - Minnesota “Compiling” - the mechanics “Command Line” compiling“Command Line” compiling Should work the same on PCs and MacsShould work the same on PCs and Macs You have to “compile” programs to run themYou have to “compile” programs to run them $ gcc hello.c $ You simply command the computer to run the programYou simply command the computer to run the program $ hello Hello, world! $
13
March 2005 13R. Smith - University of St Thomas - Minnesota Homework 1.Read Chapters 1 through 3 2.Find a “C compiler” on a computer you can use Already installed on 4th floor OSSAlready installed on 4th floor OSS May be installed on other campus computersMay be installed on other campus computers You can download it and install it at homeYou can download it and install it at home For PC: use MinGW, that’s what’s installed hereFor PC: use MinGW, that’s what’s installed here 3.Write a program that prints your name Ideally, use your U: drive or a USB driveIdeally, use your U: drive or a USB drive 4.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.Print the “C” file. Include an explanation of where you compiled and ran it, and note any problems you had.
14
March 2005 14R. Smith - University of St Thomas - Minnesota What’s happening next? A “history” of CA “history” of C Overview of Statements and VariablesOverview of Statements and Variables Simple typesSimple types Printing out textPrinting out text The nuts and bolts of compiling programsThe nuts and bolts of compiling programs
15
March 2005 15R. Smith - University of St Thomas - Minnesota History of C Interpreting expressions (1940s)Interpreting expressions (1940s) Sort/Merge GeneratorSort/Merge Generator A2 CompilerA2 Compiler FortranFortran AlgolAlgol C
16
March 2005 16R. Smith - University of St Thomas - Minnesota Statements and Variables Statements we’ll useStatements we’ll use –“Function declarations” like main Always followed by a pair of parentheses,Always followed by a pair of parentheses, and then curly bracesand then curly braces –Other statements are followed by a “;” –Variable declarations –Assignment statements VariablesVariables –Storage cells in your program –Each one is like a spreadsheet cell, only dumber
17
March 2005 17R. Smith - University of St Thomas - Minnesota Variable Naming Naming StructureNaming Structure First character: A-Z, a-z, _ or $First character: A-Z, a-z, _ or $ Remaining: same plus digitsRemaining: same plus digits Style rulesStyle rules Descriptive namesDescriptive names Usually start with lowercase letterUsually start with lowercase letter Camelback: use capitals to mark wordsCamelback: use capitals to mark words itemsOrdered, totalPaymentitemsOrdered, totalPayment DO NOT USE $ to start a nameDO NOT USE $ to start a name
18
March 2005 18R. Smith - University of St Thomas - Minnesota “Types” of variables First use: you say the typeFirst use: you say the type int = “integer”int = “integer” signed, no decimal part, less than 2Gsigned, no decimal part, less than 2G ExamplesExamples int sampleInt = 12; sampleInt = 25;
19
March 2005 19R. Smith - University of St Thomas - Minnesota Printing The ‘printf()’ functionThe ‘printf()’ function –Syntax of ‘functions’ –Takes 1 or more ‘arguments’ or ‘parameters’ First argument: “format string”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 parametersExtra parameters –One per format signal
20
March 2005 20R. Smith - University of St Thomas - Minnesota Blanks, newlines, tabs “ ““ “ “Hello” “There”“Hello” “There” “Hello There”“Hello There” \n, \t\n, \t
21
March 2005 21R. Smith - University of St Thomas - Minnesota Compiling and Running What is really happening?What is really happening? How a program executesHow a program executes Computer ‘Languages’Computer ‘Languages’ InterpetingInterpeting CompilingCompiling Running “real” instructionsRunning “real” instructions What it looks like in RAMWhat it looks like in RAM
22
March 2005 22R. Smith - University of St Thomas - Minnesota 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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.