Lecture Computing for management - Chapter 27

After studying this chapter you will be able to understand: The basic components of a C++ program, including functions, special symbols, and identifiers; explore simple data types; discover how to use arithmetic operators; examine how a program evaluates arithmetic expressions; | Iteration Lecture 27 5/14/2020 5:41:16 AM Summary of Previous Lecture In the previous lecture we have been learnt Boolean Type int as Boolean Boolean expressions Boolean Operators Precedence Common mistakes Today’s Lecture while statement for statement break statement Nested loops The while Statement Implements the repetition in an algorithm Repeatedly executes a block of statements Tests a condition (Boolean expression) at the start of each iteration Terminates when condition becomes false (zero) Example: Read in numbers, add them, and print their sum and average set sum to 0 set count to 0 input totalNumbers while (count NOTE: the last statement could cause a division by 0 Read in numbers, add them, and print their sum and average set sum to 0 set count to 0 input totalNumbers while (count /**********************************\ Read in numbers and add them up Print out the sum and the average \**********************************/ int main() { return 0; } Read in numbers, add them, and print their sum and average set sum to 0 set count to 0 input totalNumbers while (count /**********************************\ Read in numbers and add them up Print out the sum and the average \**********************************/ int main() { float nextNum, sum = ; int count = 0, totalNumbers; return 0; } Read in numbers, add them, and print their sum and average set sum to 0 set count to 0 input totalNumbers while (count Summary of Previous Lecture In the previous lecture we have been learnt Boolean Type int as Boolean Boolean expressions Boolean Operators Precedence Common mistakes Today’s Lecture while statement for statement break statement Nested loops The while Statement Implements the repetition in an algorithm Repeatedly executes a block of statements Tests a condition (Boolean expression) at the start of each iteration Terminates when condition becomes false (zero) Example: Read in numbers, add them, and print their sum and average set sum to 0 set count to 0 input totalNumbers while (count NOTE: the last statement could cause a division by 0 Read in numbers, add them, and print their sum and average set sum to 0 set count to 0 input totalNumbers while (count < totalNumbers) { input nextNum add .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.