MastanaihnaiduYasam
2 views
45 slides
Mar 04, 2025
Slide 1 of 45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
About This Presentation
We must design a Loop, so that before or after each iteration, it checks to see if the task is done. If it in not done, the loop repeats one more time;if task is done,the loop terminates. This test is known as Loop Control Expression.
Size: 23.85 MB
Language: en
Added: Mar 04, 2025
Slides: 45 pages
Slide Content
REPETITION
Concept of Loop We must design a Loop, so that before or after each iteration, it checks to see if the task is done. If it in not done, the loop repeats one more time;if task is done,the loop terminates. This test is known as Loop Control Expression.
PRETEST AND POST TEST LOOPS
Initialization may be Implicit or Explicit. Implicit -No direct initialization of code, depends on pre-existing situation Explicit -we include code to set the beginning values of key loop variables. Infinite Loop if condition is not happened Loop updates INITIALIZATION AND UPDATING
INITIALIZATION AND UPDATING
Example
EVENT AND COUNTER CONTROLLED LOOPS Event C ontrolled Loop: Event changes the control expression from true to false
Counter controlled Loop: we know the number of time that the loop is repeated EVENT AND COUNTER CONTROLLED LOOPS
LOOP COMPARISONS
LOOPS IN C
while Statement
Compound while Statement
Process Controlled System Loop
for Loop
Compound for Loop
Comparing for and while Loops
Comparing for and while Loops- Example
do-while Statement
The Comma Expression
LOOP STATEMENTS - EXAMPLES
for Loops- Example
while Loops- Example
OTHER STATEMENTS RELATED TO LOOPING break
OTHER STATEMENTS RELATED TO LOOPING continue
LOOPING APPLICATIONS Summation & Product Powers Smallest and Largest Inquiries-any or all
Summation & Product
Summation- Example
Powers-Example
Smallest and Largest
Inquiries- any or all
Inquiries- any
Inquiries- all
PROGRAMMING EXAMPLE- THE CALCULATOR PROGRAM Addition, Subtraction, Division, Multiplication and Quit.