Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12COSC 181 – Foundations of Computer ProgrammingClass 21 – Test Review2Test ReviewSame Basic FormatShort Answer or Multiple Choice SectionCode TracingFind the ErrorsWriting CodeSyntax matters!3Previously Covered MaterialPreviously covered materialChapters 1-4Intro to Computers, Internet and the WWWIntroduction to C++ ProgrammingIntroduction to Classes and ObjectsDefining ClassesName, Return type, ParameterControl Structures Part 1If … else, while (counter, sentinel), assignment operators, etc.4Key topics from beforeObjects and their relation to classesBasic kinds of errorsInput and Output StreamsIncluding library filesEscape SequencesVariable Declaration and AssignmentBasic operatorsRequirements SpecificationUse Case, Class, and Activity DiagramsClassesWriting Classes (syntax)Private vs. PublicConstructorsUsing Strings5Key topics from before (con’t)How to use a header fileSeperating functionality from interfaceDifference between functionality and interfaceTypes of Control Structures/ Combining Control StructuresTop-down, step-wise refinementNow, as it relates to Divide and ConquerCastingUsing for loopsCounter initializationLoop Continuation ConditionCounter updateBe able to tell how the looping works given a for statement6New Key TopicsOutput formatting commands/functionsNot StickySetw(2)Stickyfixedsetprecision (3)do…while statementLooping structure (how different)Syntax (how different)71 // Fig. 5.7: f ig05_07.cpp2 / / do. . .while repet it io n statement.3 #inc lude <iostream>4 us ing std::cout;5 us ing std::endl;67 int main()8 {9 int counter = 1; // initialize counter1011 do 12 { 13 cout << counter << " "; // display counter14 counter++; // increment counter 15 } while ( counter <= 10 ); // end do...while 1617 cout << endl; // output a newline18 return 0; // indicate successful termination19 } // end main1 2 3 4 5 6 7 8 9 10Outlinefig05_07.cpp(1 of 1)Declare and initialize control variable counter do…while loop displays counter’s value before testing for counter’s final value8New Key Topics (con’t)switch statementHow do case labels and break statements workdefault labelAssociated activity diagramcin.get()static_cast< int >( character )EOFASCIIThe role of “break” and “continue”9New Key Topics (con’t)Logical Operators•&& (logical AND)•|| (logical OR)•! (logical NOT)Truth Tables for eachShort-circuit evaluationStructured Programming10Chapter 6 – Key Concepts Divide and ConquerFunctionsWhat 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 work3 ways that functions may returnDeclaration vs DefinitionParameter CoercionGlobal functionsFunctions with multiple parametersC++ Standard Library Functionspow(x,y)sqrt(x)How do you use, must include <cmath>What is the C++ Standard Library?11Chapter 6 – Key ConceptsRandom Numbers<cstdlib>rand vs srandWhat is a seed?What happens if we don’t use srand?How do we achieve a desired range of random numbers? (syntax)Enumerations12Student FeedbackAny questions from you?Anything you need
View Full Document