🗊 Презентация Control Structures

Категория: Образование
Нажмите для полного просмотра!
Control Structures, слайд №1 Control Structures, слайд №2 Control Structures, слайд №3 Control Structures, слайд №4 Control Structures, слайд №5 Control Structures, слайд №6 Control Structures, слайд №7 Control Structures, слайд №8 Control Structures, слайд №9 Control Structures, слайд №10 Control Structures, слайд №11 Control Structures, слайд №12 Control Structures, слайд №13 Control Structures, слайд №14 Control Structures, слайд №15 Control Structures, слайд №16 Control Structures, слайд №17 Control Structures, слайд №18 Control Structures, слайд №19 Control Structures, слайд №20 Control Structures, слайд №21 Control Structures, слайд №22 Control Structures, слайд №23 Control Structures, слайд №24 Control Structures, слайд №25 Control Structures, слайд №26 Control Structures, слайд №27 Control Structures, слайд №28

Вы можете ознакомиться и скачать презентацию на тему Control Structures. Доклад-сообщение содержит 28 слайдов. Презентации для любого класса можно скачать бесплатно. Если материал и наш сайт презентаций Mypresentation Вам понравились – поделитесь им с друзьями с помощью социальных кнопок и добавьте в закладки в своем браузере.

Слайды и текст этой презентации


Слайд 1


Control Structures Week 3
Описание слайда:
Control Structures Week 3

Слайд 2


2.15 Essentials of Counter-Controlled Repetition Counter-controlled repetition requires Name of control variable/loop counter Initial value of...
Описание слайда:
2.15 Essentials of Counter-Controlled Repetition Counter-controlled repetition requires Name of control variable/loop counter Initial value of control variable Condition to test for final value Increment/decrement to modify control variable when looping

Слайд 3


1 // Fig. 2.16: fig02_16.cpp 2 // Counter-controlled repetition. 3 #include 4 5 using std::cout; 6 using std::endl; 7 8 // function main begins...
Описание слайда:
1 // Fig. 2.16: fig02_16.cpp 2 // Counter-controlled repetition. 3 #include 4 5 using std::cout; 6 using std::endl; 7 8 // function main begins program execution 9 int main() 10 { 11 int counter = 1; // initialization 12 13 while ( counter

Слайд 4


2.15 Essentials of Counter-Controlled Repetition The declaration int counter = 1; Names counter Declares counter to be an integer Reserves space for...
Описание слайда:
2.15 Essentials of Counter-Controlled Repetition The declaration int counter = 1; Names counter Declares counter to be an integer Reserves space for counter in memory Sets counter to an initial value of 1

Слайд 5


Control Structures, слайд №5
Описание слайда:

Слайд 6


2.16 for Repetition Structure General format when using for loops for ( initialization; LoopContinuationTest; increment ) statement Example for( int...
Описание слайда:
2.16 for Repetition Structure General format when using for loops for ( initialization; LoopContinuationTest; increment ) statement Example for( int counter = 1; counter

Слайд 7


1 // Fig. 2.17: fig02_17.cpp 2 // Counter-controlled repetition with the for structure. 3 #include 4 5 using std::cout; 6 using std::endl; 7 8 //...
Описание слайда:
1 // Fig. 2.17: fig02_17.cpp 2 // Counter-controlled repetition with the for structure. 3 #include 4 5 using std::cout; 6 using std::endl; 7 8 // function main begins program execution 9 int main() 10 { 11 // Initialization, repetition condition and incrementing 12 // are all included in the for structure header. 13 14 for ( int counter = 1; counter

Слайд 8


2.16 for Repetition Structure for loops can usually be rewritten as while loops initialization; while ( loopContinuationTest){ statement increment; }...
Описание слайда:
2.16 for Repetition Structure for loops can usually be rewritten as while loops initialization; while ( loopContinuationTest){ statement increment; } Initialization and increment For multiple variables, use comma-separated lists for (int i = 0, j = 0; j + i

Слайд 9


1 // Fig. 2.20: fig02_20.cpp 2 // Summation with for. 3 #include 4 5 using std::cout; 6 using std::endl; 7 8 // function main begins program...
Описание слайда:
1 // Fig. 2.20: fig02_20.cpp 2 // Summation with for. 3 #include 4 5 using std::cout; 6 using std::endl; 7 8 // function main begins program execution 9 int main() 10 { 11 int sum = 0; // initialize sum 12 13 // sum even integers from 2 through 100 14 for ( int number = 2; number

Слайд 10


2.17 Examples Using the for Structure Program to calculate compound interest A person invests $1000.00 in a savings account yielding 5 percent...
Описание слайда:
2.17 Examples Using the for Structure Program to calculate compound interest A person invests $1000.00 in a savings account yielding 5 percent interest. Assuming that all interest is left on deposit in the account, calculate and print the amount of money in the account at the end of each year for 10 years. Use the following formula for determining these amounts: a = p(1+r) p is the original amount invested (i.e., the principal), r is the annual interest rate, n is the number of years and a is the amount on deposit at the end of the n-th year

Слайд 11


1 // Fig. 2.21: fig02_21.cpp 2 // Calculating compound interest. 3 #include 4 5 using std::cout; 6 using std::endl; 7 using std::ios; 8 using...
Описание слайда:
1 // Fig. 2.21: fig02_21.cpp 2 // Calculating compound interest. 3 #include 4 5 using std::cout; 6 using std::endl; 7 using std::ios; 8 using std::fixed; 9 10 #include 11 12 using std::setw; 13 using std::setprecision; 14 15 #include // enables program to use function pow 16 17 // function main begins program execution 18 int main() 19 { 20 double amount; // amount on deposit 21 double principal = 1000.0; // starting principal 22 double rate = .05; // interest rate 23

Слайд 12


24 // output table column heads 25 cout
Описание слайда:
24 // output table column heads 25 cout

Слайд 13


Year Amount on deposit 1 1050.00 2 1102.50 3 1157.63 4 1215.51 5 1276.28 6 1340.10 7 1407.10 8 1477.46 9 1551.33 10 1628.89
Описание слайда:
Year Amount on deposit 1 1050.00 2 1102.50 3 1157.63 4 1215.51 5 1276.28 6 1340.10 7 1407.10 8 1477.46 9 1551.33 10 1628.89

Слайд 14


Control Structures, слайд №14
Описание слайда:

Слайд 15


2.19 do/while Repetition Structure Similar to while structure Makes loop continuation test at end, not beginning Loop body executes at least once...
Описание слайда:
2.19 do/while Repetition Structure Similar to while structure Makes loop continuation test at end, not beginning Loop body executes at least once Format do { statement } while ( condition );

Слайд 16


2.19 do/while Repetition Structure
Описание слайда:
2.19 do/while Repetition Structure

Слайд 17


1 // Fig. 2.24: fig02_24.cpp 2 // Using the do/while repetition structure. 3 #include 4 5 using std::cout; 6 using std::endl; 7 8 // function main...
Описание слайда:
1 // Fig. 2.24: fig02_24.cpp 2 // Using the do/while repetition structure. 3 #include 4 5 using std::cout; 6 using std::endl; 7 8 // function main begins program execution 9 int main() 10 { 11 int counter = 1; // initialize counter 12 13 do { 14 cout

Слайд 18


2.20 break and continue Statements break statement Immediate exit from while, for, do/while, switch Program continues with first statement after...
Описание слайда:
2.20 break and continue Statements break statement Immediate exit from while, for, do/while, switch Program continues with first statement after structure Common uses Escape early from a loop Skip the remainder of switch

Слайд 19


1 // Fig. 2.26: fig02_26.cpp 2 // Using the break statement in a for structure. 3 #include 4 5 using std::cout; 6 using std::endl; 7 8 // function...
Описание слайда:
1 // Fig. 2.26: fig02_26.cpp 2 // Using the break statement in a for structure. 3 #include 4 5 using std::cout; 6 using std::endl; 7 8 // function main begins program execution 9 int main() 10 { 11 12 int x; // x declared here so it can be used after the loop 13 14 // loop 10 times 15 for ( x = 1; x

Слайд 20


26 27 return 0; // indicate successful termination 28 29 } // end function main
Описание слайда:
26 27 return 0; // indicate successful termination 28 29 } // end function main

Слайд 21


2.20 break and continue Statements continue statement Used in while, for, do/while Skips remainder of loop body Proceeds with next iteration of loop...
Описание слайда:
2.20 break and continue Statements continue statement Used in while, for, do/while Skips remainder of loop body Proceeds with next iteration of loop while and do/while structure Loop-continuation test evaluated immediately after the continue statement for structure Increment expression executed Next, loop-continuation test evaluated

Слайд 22


1 // Fig. 2.27: fig02_27.cpp 2 // Using the continue statement in a for structure. 3 #include 4 5 using std::cout; 6 using std::endl; 7 8 // function...
Описание слайда:
1 // Fig. 2.27: fig02_27.cpp 2 // Using the continue statement in a for structure. 3 #include 4 5 using std::cout; 6 using std::endl; 7 8 // function main begins program execution 9 int main() 10 { 11 // loop 10 times 12 for ( int x = 1; x

Слайд 23


26 27 } // end function main
Описание слайда:
26 27 } // end function main

Слайд 24


2.21 Structured-Programming Summary Structured programming Programs easier to understand, test, debug and modify Rules for structured programming...
Описание слайда:
2.21 Structured-Programming Summary Structured programming Programs easier to understand, test, debug and modify Rules for structured programming Only use single-entry/single-exit control structures Rules 1) Begin with the “simplest flowchart” 2) Any rectangle (action) can be replaced by two rectangles (actions) in sequence 3) Any rectangle (action) can be replaced by any control structure (sequence, if, if/else, switch, while, do/while or for) 4) Rules 2 and 3 can be applied in any order and multiple times

Слайд 25


2.21 Structured-Programming Summary
Описание слайда:
2.21 Structured-Programming Summary

Слайд 26


2.21 Structured-Programming Summary All programs broken down into Sequence Selection if, if/else, or switch Any selection can be rewritten as an if...
Описание слайда:
2.21 Structured-Programming Summary All programs broken down into Sequence Selection if, if/else, or switch Any selection can be rewritten as an if statement Repetition while, do/while or for Any repetition structure can be rewritten as a while statement

Слайд 27


Readings: C++ How to Program, By H. M. Deitel Chapter 5. Control Statements: Part 2
Описание слайда:
Readings: C++ How to Program, By H. M. Deitel Chapter 5. Control Statements: Part 2

Слайд 28


Control Structures, слайд №28
Описание слайда:



Теги Control Structures
Похожие презентации
Mypresentation.ru
Загрузить презентацию