Topics discussed in this section:

Slides:



Advertisements
Similar presentations
Arithmetic Series Vocabulary series: the sum of the indicated terms in a sequence arithmetic series: the sum of an arithmetic sequence.
Advertisements

What is the sum of the following infinite series 1+x+x2+x3+…xn… where 0
Topics discussed in this section:
Computer Science: A Structured Programming Approach Using C1 6-7 Other Statements Related to Looping Three other C statements are related to loops: break,
Computer Science: A Structured Programming Approach Using C Converting File Type A rather common but somewhat trivial problem is to convert a text.
Do Loop The syntax of DO loop: DO variable = initial_value, final_value[, increment] [statements] END DO Example: PROGRAM LINES ! Illustration of DO-loops.
CS150 Introduction to Computer Science 1
CMSC 250 Discrete Structures Summation: Sequences and Mathematical Induction.
Computing Sums and Averages 04/17/15. Totaling Up a List Write a program to input a list of four numbers and output the total.
Chapter 5: Control Structures II (Repetition)
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand basic loop concepts: ■ pretest loops and post-test loops ■ loop.
Computer Science: A Structured Programming Approach Using C Masks In many programs, bits are used as binary flags: 0 is off, and 1 is on. To set.
MATH 224 – Discrete Mathematics
Arithmetic Sequences and Series
Additional Topics in Differential Equations
Principles of programming languages 2: Answers for exercises
Section 16.3 Triple Integrals. A continuous function of 3 variable can be integrated over a solid region, W, in 3-space just as a function of two variables.
Real World Applications: Statistical Measures Problem (page 95-98) Read a series of floating-point numbers from the standard input, and print a statistical.
Principle of Programming Lanugages 2: Imperative languages Isao Sasano Department of Information Science and Engineering ( structured programming, control.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To be able to list and describe the six expression categories ❏ To understand.
Section 12-1 Sequence and Series
Computer Science: A Structured Programming Approach Using C1 2-7 Input/Output Although our programs have implicitly shown how to print messages, we have.
1 Objectives ❏ To understand basic loop concepts: ■ pretest loops and post-test loops ■ loop initialization and updating ■ event and counter controlled.
Computer Science: A Structured Programming Approach Using C1 5-3 Multiway Selection In addition to two-way selection, most programming languages provide.
solve x + (-16) = -12 solve x + (-16) = X = 4.
Aim: What is the arithmetic series ? Do Now: Find the sum of each of the following sequences: a) b)
Computer Science: A Structured Programming Approach Using C1 2-7 Input/Output Although our programs have implicitly shown how to print messages, we have.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 5 Repetition.
11/10/2016CS150 Introduction to Computer Science 1 Last Time  We covered “for” loops.
Computer Science: A Structured Programming Approach Using C1 6-6 Loop Examples This section contains several short examples of loop applications. Each.
Series Section Intro to Series Series A sum of the terms of a sequence is called a series. A series is a finite series if it is the sum of a finite.
1 2/21/2016 MATH 224 – Discrete Mathematics Sequences and Sums A sequence of the form ar 0, ar 1, ar 2, ar 3, ar 4, …, ar n, is called a geometric sequence.
Computer Science 101 For Statement. For-Statement The For-Statement is a loop statement that is especially convenient for loops that are to be executed.
Topic #3: GCF and LCM What is the difference between a factor and a multiple? List all of the factors and the first 3 multiples of 6.
Announcements Midterm2 on April 18 th Monday at 19:40 This week recitations, we will solve sample midterm questions. I will also send previous years’ exams.
MATH 224 – Discrete Mathematics
Topics discussed in this section:
Introduction to the C Language
Principle of Programming Lanugages 2: Imperative languages
Intro to Programming Week # 6 Repetition Structure Lecture # 10
Topics discussed in this section:
Topics discussed in this section:
Topics discussed in this section:
Loops in C C has three loop statements: the while, the for, and the do…while. The first two are pretest loops, and the the third is a post-test loop. We.
Topics discussed in this section:
Introduction to the C Language
Chapter 6 Repetition Objectives ❏ To understand basic loop concepts:
Topics discussed in this section:
Consecutive Integers: Numbers are one apart
Outline Altering flow of control Boolean expressions
3-3 Side Effects A side effect is an action that results from the evaluation of an expression. For example, in an assignment, C first evaluates the expression.
4-2 Functions in C In C, the idea of top–down design is done using functions. A C program is made of one or more functions, one and only one of which.
Notes Over 10.1 Polynomial Vocabulary Degree is 1 Degree is 4
3-3 Side Effects A side effect is an action that results from the evaluation of an expression. For example, in an assignment, C first evaluates the expression.
Topics discussed in this section:
Topics discussed in this section:
Topics discussed in this section:
Topics discussed in this section:
Topics discussed in this section:
CS150 Introduction to Computer Science 1
Section 2.5 Sigma Notations and Summation
C Security Pre Function
Introduction to Computer Science
Every number has its place!
Introduction to Computer Science
Topics discussed in this section:
QUIZ 7. What are the min number of pieces you will have to consider for determining the centroid of the area? 1 B) 2 C) 3 D) 4 8. For determining.
Repetition (While Loop) LAB 9
Topics discussed in this section:
Topics discussed in this section:
Presentation transcript:

Topics discussed in this section: 6-7 Other Statements Related to Looping Three other C statements are related to loops: break, continue, and goto. The last statements, the goto, is not valid for structured programs and therefore is not discussed in this text. Topics discussed in this section: break continue Computer Science: A Structured Programming Approach Using C

FIGURE 6-20 break and Inner Loops Computer Science: A Structured Programming Approach Using C

The for and while as Perpetual Loops PROGRAM 6-16 The for and while as Perpetual Loops Computer Science: A Structured Programming Approach Using C

PROGRAM 6-17 Using a break Flag Computer Science: A Structured Programming Approach Using C

FIGURE 6-21 The continue Statement Computer Science: A Structured Programming Approach Using C

PROGRAM 6-18 continue Example Computer Science: A Structured Programming Approach Using C

Topics discussed in this section: 6-8 Looping Applications In this section, we examine four common applications for loops: summation, product, smallest and largest, and inquiries. Although the uses for loops are virtually endless, these problems illustrate many common applications. Topics discussed in this section: Summation Powers Smallest and Largest Inquiries Computer Science: A Structured Programming Approach Using C

FIGURE 6-22 Summation and Product Loops Computer Science: A Structured Programming Approach Using C

PROGRAM 6-19 Sum to EOF Function Computer Science: A Structured Programming Approach Using C

PROGRAM 6-19 Sum to EOF Function Computer Science: A Structured Programming Approach Using C

PROGRAM 6-20 Powers Function Computer Science: A Structured Programming Approach Using C

PROGRAM 6-20 Powers Function Computer Science: A Structured Programming Approach Using C

Note To find the sum of a series, the result is initialized to 0; to find the product of a series, the result is initialized to 1. Computer Science: A Structured Programming Approach Using C

FIGURE 6-23 Smallest and Largest Loops Computer Science: A Structured Programming Approach Using C

Smallest to EOF Function PROGRAM 6-21 Smallest to EOF Function Computer Science: A Structured Programming Approach Using C

Smallest to EOF Function PROGRAM 6-21 Smallest to EOF Function Computer Science: A Structured Programming Approach Using C

Note To find the largest, we need to initialize the smallest variable to a very small number, such as INT_MIN. To find the smallest, we need to initialize the result to a very large number, such as INT_MAX. Computer Science: A Structured Programming Approach Using C

FIGURE 6-24 any and all Inquiries Computer Science: A Structured Programming Approach Using C

anyPositive to EOF Function PROGRAM 6-22 anyPositive to EOF Function Computer Science: A Structured Programming Approach Using C

anyPositive to EOF Function PROGRAM 6-22 anyPositive to EOF Function Computer Science: A Structured Programming Approach Using C

PROGRAM 6-23 All Positive Function Computer Science: A Structured Programming Approach Using C

anyPositive to EOF Function PROGRAM 6-22 anyPositive to EOF Function Computer Science: A Structured Programming Approach Using C