Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 151COSC 181 – Foundations of Computer ProgrammingClass 31- Test Review2Next TestMon., Apr 20th•Comprehensive•Focusing on Material since last test•Chapter 6 and Chapter 73Test ReviewSame Basic Format•Short Answer or Multiple Choice Section•Code Tracing•Find the Errors•Writing Code•Syntax matters!4Previously Covered MaterialPreviously covered material•Chapters 1-4•Intro to Computers, Internet and the WWW•Introduction to C++ Programming•Introduction to Classes and Objects•Defining Classes•Name, Return type, Parameter•Control Structures Part 1•If … else, while (counter, sentinel), assignment operators, etc.5Key topics from beforeObjects and their relation to classesBasic kinds of errorsInput and Output StreamsIncluding library filesEscape SequencesVariable Declaration and Assignment•Basic operatorsRequirements Specification•Use Case, Class, and Activity DiagramsClasses•Writing Classes (syntax)•Private vs. Public•ConstructorsUsing Strings6Key topics from before (con’t)How to use a header file•Seperating functionality from interface•Difference between functionality and interfaceTypes of Control Structures/ Combining Control StructuresTop-down, step-wise refinement•Now, as it relates to Divide and ConquerCastingUsing for loops•Counter initialization•Loop Continuation Condition•Counter update•Be able to tell how the looping works given a for statement7Previously covered material•Chapters 5 – 6 (first half)•Control Statements Part 2•for statement•do…while loop•switch•break and continue•Logical operators•EOF and ASCII •Introduction to functions8 1 // Fig. 5.7: fig05_07.cpp 2 // do...while repetition statement. 3 #include <iostream> 4 using std::cout; 5 using std::endl; 6 7 int main() 8 { 9 int counter = 1; // initialize counter 10 11 do 12 { 13 cout << counter << " "; // display counter 14 counter++; // increment counter 15 } while ( counter <= 10 ); // end do...while 16 17 cout << endl; // output a newline 18 return 0; // indicate successful termination 19 } // end main 1 2 3 4 5 6 7 8 9 10 Outlinefig05_07.cpp(1 of 1)Declare and initialize control variable counter do…while loop displays counter’s value before testing for counter’s final value9New Key Topics (con’t)Logical Operators•&& (logical AND)•|| (logical OR)•! (logical NOT)•Truth Tables for each•Short-circuit evaluationStructured Programming10Chapter 6 (First Part) – Key Concepts Divide and ConquerFunctions•What are they, why are they important?•How do we write them / use them?•Ways to tell if your function is too complex?•How function calls work•3 ways that functions may return•Declaration vs Definition•Parameter Coercion•Global functions•Functions with multiple parametersC++ Standard Library Functions•pow(x,y)•sqrt(x)•How do you use, must include <cmath>What is the C++ Standard Library?Using Random Numbers11Chapter 6 (Second Part) – Key ConceptsIdentifier attributes•Name, Type, Size, and Value•Scope •Storage Classes•automatic vs static variables•Note: global variables are static by defaultPrinciple of Least PrivilegeScope Rules (Rules for each of the following)•Function scope•File scope•Block scope•Function-prototype scopeFunction call stack and activation records•Pushing, Popping, LIFO•Parts of an activation record•Stack Overflow12Pass by Reference vs. Pass by Value•Understand the conceptual difference•Understand the syntactical differenceUsing references outside of parameter listsDefault arguments•Syntax•Must have all the right-most elements be defaultedUnary scope resolution operatorOverloaded functionsFunction Templates•How used •template <class T, class S>•Proper syntax13Recursion •When a function calls itself•2 items needed to successfully recurse•Review the ExamplesPros and Cons of Recursion14Chapter 7Arrays•How declared•Initialization (several methods)•How to use for loops with arrays•What are “magic numbers”•Why are they bad•Study the examples that we gave15Student FeedbackAny questions from you?•Anything you need
View Full Document