C++ lecture 6

27 6 0
C++ lecture 6

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

C++ Programming Lecture Control Structure II The Hashemite University (Repetition) Computer Engineering Department (Adapted from the textbook slides) Outline         Introduction while Repetition Structure for Repetition Structure do/while Repetition Structure continue and break Statements Formulating Algorithms Nested Control Structures Examples The Hashemite University Introduction    In the last lecture we have explored the selection control structures In this lecture we will explore another type of control structure in which part of the code is repeated number of times Repetition (or looping) control structures:    while for do/while The Hashemite University Types of Looping  Two types of repetition or looping exist:  Sentinel-Controlled Repetition    In this type you not know the number of times the body of the loop must be repeated, i.e not know the number of loop iterations Mainly you use while, and do/while control structures for this type of looping Counter-Controlled Repetition   In this type you know the number of times the body of the loop must be repeated, i.e the number of loop iterations is defined in advance Mainly you use for control structures for this type of looping The Hashemite University while Repetition Structure I  Repetition structure    Programmer specifies an action to be repeated while some condition remains true Also called looping or simply loop Psuedocode while there are more items on my shopping list Purchase next item and cross it off my list   while loop repeated until condition becomes false where the next line of code after while loop will be executed Another example int product = 2; while ( product

Ngày đăng: 12/10/2021, 21:08

Mục lục

    C++ Programming Lecture 6 Control Structure II (Repetition)

    while Repetition Structure I

    while Repetition Structure II

    Essentials of Counter-Controlled Repetition

    for Repetition Structure I

    for Repetition Structure II

    for Repetition Structure III

    While and for example

    do...while Repetition Structure I

    do...while Repetition Structure II

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan