# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

8 Pages

### lecture05_controlstructure

Course: ECE 206, Fall 2009
School: Tennessee
Rating:

Word Count: 466

#### Document Preview

- ECE206 Programming Lecture 5 Control Structure (II) 09/06/07 Recap Sequence structure Selection structure if/ifelse/ifelse if ladder/nested ifs Conditional expressions Switchcase/controlling expression Dangling else problem Repetition structure 2 1 Why repetition? int number1, number2, number3; float avg; No Calculate sum cout &lt;&lt; Please input 3 integer numbers:\n cin &gt;&gt;...

Register Now

#### Unformatted Document Excerpt

Coursehero >> Tennessee >> Tennessee >> ECE 206

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
- ECE206 Programming Lecture 5 Control Structure (II) 09/06/07 Recap Sequence structure Selection structure if/ifelse/ifelse if ladder/nested ifs Conditional expressions Switchcase/controlling expression Dangling else problem Repetition structure 2 1 Why repetition? int number1, number2, number3; float avg; No Calculate sum cout << Please input 3 integer numbers:\n cin >> number1 >> number2 >> number3; avg = (number1+nubmer2+number3)/3.0; cout << The average is << avg << endl; 1000th number? Yes Calculate avg. What about 1000 numbers? 3 Key components in repetition Where to start and when to stop Counter-controlled Sentinel-controlled Task-controlled Controlling expression What action to perform How to jump out from repetition 4 2 for loop 1 2 3 4 for (initialization; expression; increment) { statement sequence; } Initialization expression true? True Statement sequence increment 5 False Example 1 for for (i=10; i>=-10; i=i-5) { cout << i << ; } for (i=0; i<5; i++) { cout << i << ; } for (i=0; i!=10; i++) { cout << i << ; } for (char i=A; i<F; ++i) { cout << i << ; } Calculate the sum of all even numbers less than 1000. C++: int total = 0; for ( int even=2; even<1000; even=even+2 ) total += even; 6 3 Exploring - for loop The infinite loop for ( ; ; ) { // } How to stop infinite loop? Time delay loops for (x=0; x<1000; x++); for (x=0; x<1000; x++) for (y=0; y<1000; y++); ;? 7 while loop initialization while (condition) { statements; } expression true? False True statements ;? Find the smallest power of 2 greater than 1000. C++: int product = 1; while ( product <= 1000 ) product = 2 * product; 8 4 Example 2 while /* This program displays all printable characters. * * Notes: ch Since is an unsigned character, it can only hold * the values from 0 to 255. When it holds the value 255 and is then * incremented, its value will "wrap around" to zero. */ #include <iostream> using namespace std; //introduces namespace std int main( void ) { unsigned char ch; ch = 32; while (ch) { cout << (char)ch; ch++; } return 0; } 9 do while loop ;? do { statements; } while (expression); statements expression true? False True Find the smallest power of 2 greater than 1000. C++: int product = 1; do { product = 2 * product; }while ( product <= 1000 ); 10 5 Examples 3 - while and do..while x = 10; while (x > 0) { x--; cout << x; } x = 10; do { x--; cout << x; } while (x>0); The difference lies in the order of execution: in do..while, the statement is executed first, then the condition; in while, the condition is executed first, then the statement if condition is satisfied 11 Example 4 the jump structure continue: to force an early iteration of a loop to bypass the loops normal control structure break: to force an immediate exit from ...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Tennessee - ECE - 206
ECE206 - ProgrammingLecture 10 Operator Overloading10/30/07RecapClass definition, object instantiation Separate interface from implementation Access specifier (public, private) Constructors and destructors Memberwise copy and copy constructor A
Tennessee - ECE - 206
ECE206 - ProgrammingLecture 11 Inheritance and Polymorphism11/06/07Function parameter list and return typeA function that calculates the maximum of three floating numbers A function that finds the largest and the second largest integer numbers
Tennessee - ECE - 206
ECE206 - ProgrammingLecture 7 Array09/20/07What is an array?An array is a collection of data elements or objects of the same type. Arrays are static entities because they remain the same size throughout program execution. When declaring an arra
Tennessee - ECE - 206
ECE206 - ProgrammingLecture 14 Final Review11/27/07Review questions computerWhat are the basic components of a von-Neumann machine? Whats the difference between memory and register? Can you give examples of system software and application soft
Tennessee - ECE - 206
ECE206 - ProgrammingLecture 12 Function (Advanced Features)11/13/07What do you need to knowFundamentals Function declaration Forward prototype Forward definition Call-by-value vs. callby-reference Command-line arguments Storage class Advanced t
Tennessee - ECE - 206
Questionnaire ECE206 (Fall 2007)1. Name: Department: Major: Email: Level (freshman or sophomore): 2. Which of the following programming languages have you HEARD of? Please circle. (a) C (b) C+ (c) Java (d) Basic (e) C# (f) Pascal3. Which of the
Tennessee - ECE - 206
ECE206 - ProgrammingMidterm Review10/4/07Computer Architecture and programming environmentWhat is a computer? What are the basic components of a von-Neumann machine? What does a compiler do? What does a linker do?What does a loader do? What is
Tennessee - ECE - 206
ECE206 - ProgrammingLecture 3 Operators and Data Type08/30/07RecapProgramming environmentPre-complied lib 000110101 011111000 001010101 *.cpp int main() complier { cout &lt; } *.o 001001010 010010100 010010010 010100101 *.exe 001001010 linker 010
Stanford - ECON - 310
Aggregate Implications of Lumpy Investment: New Evidence and a DSGE ModelRuediger BachmannRicardo J. CaballeroEduardo M.R.A. EngelJune 11, 2008Abstract The sensitivity of U.S. aggregate investment to shocks is procyclical: the initial respo
Stanford - ECON - 310
Risk Matters: The Real Eects of Volatility ShocksJess Fernndez-Villaverde University of Pennsylvania, NBER, and CEPR Pablo Guerrn-Quintana North Carolina State University Juan F. Rubio-Ramrez Duke University and Federal Reserve Bank of Atlanta Martn
W. Alabama - GIMO - 141
1Sonata a Mandolino solo e BassoGiovanni Battista Gervasio (c.1725-c.1785)Gimo 141Allegro4710 1013 1316 1620 20Public Domain224 2428 282 42 432 3235 3538 3841 4144 4447 47Mutopia-2003/06/24-326350 5053
W. Alabama - GIMO - 142
1Sonata Per Camera di Mandolino e BassoGiovanni Battista Gervasio (c.1725-c.1785)Gimo 142Allegro4710 106613 136666 6 6 66 6 66616 16666666 666666619 19666SimilePublic Domain224
W. Alabama - GIMO - 142
1Sonata Per Camera di Mandolino e BassoGiovanni Battista Gervasio (c.1725-c.1785)Gimo 142Allegro4710 106613 136666 6 6 66 6 66616 16666666 666666619 19666SimilePublic Domain224
Indiana - MUSIC - 100
2003-05 SCHOOL OF MUSIC BULLETINThe Artist Diploma is a program for outstanding performers who intend to pursue a career in performance. The program provides for concentrated study in appropriate repertoire. This sheet is for use as an aid in unders
Southern Utah - MUS - 316
Claude Debussy (1862-1918) Influences Music French predecessors / contemporaries, e.g. Franck, Saint-Sans (late Romantic, conservative in style) Wagner - orchestration, chromaticism Russians - e.g. Musorgskys alternative tonal structures Asian mu
W. Alabama - GIMO - 144
1Sonata per Camera di Mandolino e BassoGiovanni Battista Gervasio (c.1725-c.1785)Gimo 144Allegro maestoso4812 1215 1518 18Simi:22 2226 26d.fffPublic Domain230 3034 34d.38 3841 4144 44347 47d.51 51
Indiana - MUSIC - 100
SUMMER MUSIC CLINIC APPLICATION FORM (JUNE 7 - 13, 2009)S tu d e n t G e n e r a l In fo r m a tio n N a m e (L a s t, F ir s t, M id d le ) H om e Phone E -m a il A d d r e s s H o m e A d d re ss C u rre n t A ge N a m e o f R e q u e s te d R o o
USF - EEL - 3394
EEL 3394 Exam 1 Key 1. Fill in the blank with the name of the atomic bond (8 pts). a.) Ionic another. b.) Covalent form when electrons from one atom are transferred to form when electrons are shared between atoms.c.) Metallic form when there is a c
USF - EEL - 3394
EEL 3394 Exam 2 1. Label the band diagrams below (10 pts)a.) Reverse biasb.)Equilibriumc.) Forward bias2. True or False (10 pts) a.) F When a semi-conductor is exposed to light or heat, the resistance will increase. b.) T c.) F d.) F e.) T
USF - EEL - 3394
EEL 3394: Electronic MaterialsInstructor: Office: Phone: E- mail: T A: Office Hours: Course Text: Prerequisites: Course Objective: Stephen E. Saddow, Ph.D. ENB 243 974-4773 saddow@ieee.org Suzie Harvey sharvey4@eng.usf.edu By appointment O NLY S.O.
Indiana - MUSIC - 100
School of Music Indiana UniversityFor students entering the D.M. program in the School of Music: Fall 2003 through Summer 2005Requirements for:Doctor Of Music GuitarCurrent students may obtain an up-to-date degree audit using INSITE, http:/insi
Indiana - MUSIC - 100
School of Music Indiana UniversityFor students entering the D.M. program in the School of Music: Fall 2003 through Summer 2005Requirements for:Doctor Of Music Trumpet and CornetCurrent students may obtain an up-to-date degree audit using INSITE
Indiana - MUSIC - 100
School of Music Indiana UniversityFor students entering the D.M. program in the School of Music: Fall 2001 through Summer 2003Requirements for:Doctor Of Music Woodwinds (5 Instruments)Current students may obtain an up-to-date degree audit using
Indiana - MUSIC - 100
School of Music Indiana UniversityFor students entering the D.M. program in the School of Music: Fall 2006 through Summer 2007Requirements for:Doctor Of Music Woodwinds (5 Instruments)Current students may obtain an up-to-date degree audit using
Indiana - MUSIC - 100
Jacobs School of Music Indiana UniversityFor students entering the D.M. program in the Jacobs School of Music: Fall 2007 through Summer 2009Requirements for:Doctor Of Music HornCurrent students may obtain an up-to-date degree audit using OneSta
Indiana - MUSIC - 100
School of Music Indiana UniversityFor students entering the D.M. program in the School of Music: Fall 2001 through Summer 2003Requirements for:Doctor Of Music Brass Pedagogy (Trombone)Current students may obtain an up-to-date degree audit using
Indiana - MUSIC - 100
School of Music Indiana UniversityFor students entering the D.M. program in the School of Music: Fall 2005 through Summer 2007Requirements for:Doctor Of Music FluteCurrent students may obtain an up-to-date degree audit using OneStart, http:/one
Indiana - MUSIC - 100
School of Music Indiana UniversityFor students entering the D.M. program in the School of Music: Fall 2005 through Summer 2007Requirements for:Doctor Of Music ViolaCurrent students may obtain an up-to-date degree audit using OneStart, http:/one
Ohio State - EE - 351
EE 351 Lecture Packet #1OutlineIntroductionSignals and systemsExample systemsSystem modelsClassication of signalsImportant signalsSystem propertiesCopyright 1998-2003, L.C. Potter The Ohio State UniversityOHIO S ATE T
Indiana - MUSIC - 100
School of Music Indiana UniversityFor students entering the M.M. program in the School of Music: Fall 2005 through Summer 2007Requirements for:Master Of Music EuphoniumCurrent students may obtain an up-to-date degree audit using OneStart, http:
Indiana - MUSIC - 100
School of Music Indiana UniversityFor students entering the M.M. program in the School of Music: Fall 2005 through Summer 2007Requirements for:Master Of Music TromboneCurrent students may obtain an up-to-date degree audit using OneStart, http:/
Indiana - MUSIC - 100
School of Music Indiana UniversityFor students entering the M.M. program in the School of Music: Summer 2006 through Summer 2007Requirements for:Master Of Music Choral ConductingCurrent students may obtain an up-to-date degree audit using OneSt
Indiana - MUSIC - 100
School of Music Indiana UniversityFor students entering the M.M. program in the School of Music: Fall 2005 through Summer 2007Requirements for:Master Of Music Early Music Keyboard/Plucked Instrument EmphasisCurrent students may obtain an up-to
Indiana - MUSIC - 100
Jacobs School of Music Indiana UniversityFor students entering the M.M. program in the Jacobs School of Music: Fall 2007 through Summer 2009Requirements for:Master Of Music VioloncelloCurrent students may obtain an up-to-date degree audit using
Indiana - MUSIC - 100
General Education Requirements for BME majors Total - 27 credit hoursOral and Written Expression (9 credit hours)1. Oral Expression (3 credit hours) Select one of the following (grade of C or better required, can not betaken Pass/Fail or by corres
Southern Utah - ART - 210
Indiana - MUSIC - 100
Indiana University School of Music BME General - Singer 4 Year Year 1 Fall Year 1- Spring Ensemble 2 Ensemble 2 Performance Study 2 Performance Study 2 T151 Music Theory 3 T152 Music Theory 3 General Ed Elective 3 T132 Music Skills 1 General Ed Elec
Ohio State - ECE - 206
Winter 2005EE 206 Switching Circuits Laboratory Course SyllabusInstructor: Tim Hartley Office: DL 805 Office Hours: By appointment only. Email: hartleyt@ece.osu.edu Web Page: http:/www.ece.osu.edu/~hartleyt/ECE206/ Required Text: EE206 notes from
Washington - CEE - 404
TOTAL NORTHBOUND TRAFFIC (MAINLINE + EXPRESS LANES)Hourly directional traffic count 2007 DataThe following table shows the percentage of vehicle traffic occuring during each hour interval for each day of the week Hour of the day (starting at the n
Washington - CEE - 404
EASTBOUNDHourly directional traffic count SR 90, MP 82.7, Near Cle Elum 2007 Data (November and December numbers are from 2006) The following table shows the percentage of vehicle traffic occuring during each hour interval for each day of the week H
San Jose State - HS - 167
3: Summary StatisticsWays to measure distributional characteristicsTypes of Summary Statsp. 3.1P Central location&lt; Mean &lt; Median &lt; ModeP Spread&lt; Variance &amp; standard deviation &lt; Range &amp; inter-quartile rangeP Shape measures not often used
San Jose State - HS - 167
Biostatistics (HS167) Fall 2004 San Jose State University Dept. of Health Science Prerequisite Satisfactory completion of the GE Math (B4) requirement (undergraduates). Website Instructors www.sjsu.edu/biostat The website includes the schedule of top
San Jose State - HS - 167
9: Inference About a Proportionp. 9.1P Recall binomial random variables (Chap 4)&lt; n independent observations &lt; Each observation classified as success or failure (qualitative outcome) &lt; p = probability of success each observation ( parameter p) &lt; X
Cal Poly Pomona - ECE - 308
California State Polytechnic University, PomonaElectrical &amp; Computer Eng. Dr. Zekeriya AliyaziciogluECE 308 - 03 Introduction to Discrete Time Signals &amp; SystemsExam #1Solution Name:_1. Compute and sketch the convolution y(n) of the following si
El Paso CC - ART - 212
Handout 14 Art in the US before World War III. American art in 19th Century: initial predominance of Europe A. John Singer Sargent (1856-1925): Refined and flattering portraits of wealthy sitters. Much of career spent in Europe (especially London)
Purdue - ECON - 512
Economics 512 Spring 2009 Saunders Quiz 3Name: _1. How does the importance of economic growth compare with that of cyclical fluctuations from the point of view of consumers welfare? Although we read about cyclical phenomena much more frequently,
Cal Poly Pomona - EGR - 544
Cal Poly PomonaElectrical &amp; Computer Eng.EGR 544 Communication TheoryHomework #1 Answers Not yet!EGR 544-1
Wesleyan - PHYS - 505
GRADUATE RECORD EXAMINATIONSPhysics TestPractice BookThis practice book containsone actual full-length GRE Physics Test test-taking strategiesBecome familiar withtest structure and content test instructions and answering procedures Compare
Wesleyan - PHYS - 505
This book is provided FREE with test registration by the Graduate Record Examinations Board.Graduate Record ExaminationsThis practice book containsone actual full-length GRE Physics Test test-taking strategiesBecome familiar withtest structur
UVA - ASTR - 130
%!PS-Adobe-2.0 %Creator: dvipsk 5.58f Copyright 1986, 1994 Radical Eye Software %Title: prepqz-1-f00.dvi %Pages: 4 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Times-Roman Times-Bold Times-Italic %DocumentPaperSizes: Letter %EndCommen
UVA - ASTR - 130
%!PS-Adobe-2.0 %Creator: dvipsk 5.58f Copyright 1986, 1994 Radical Eye Software %Title: prepqz-2-f00.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Times-Roman Times-Bold %DocumentPaperSizes: Letter %EndComments %DVIPSComm
Kentucky - JAT - 520
REPRESENTING THE THIRD WAVE: MAINSTREAM PRINT MEDIA FRAMING OF A NEW FEMINIST MOVEMENTBy Carolyn BronsteinThis study analyzes the framing 0 /third wave feminism to determine whether journalists are recycling stock frames commonly used to portray th
Kentucky - JAT - 520
Human Communication. A Publication of the Pacific and Asian Communication Association Vol. 10, No. 1, pp. 33 44The Impact of Television Viewing on Young Adults Stereotypes Towards Hispanic Americans Qingwen Dong and Arthur Phillip MurrilloQingwe
Kentucky - JAT - 520
Kentucky - JAT - 520