Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
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: addnum.c 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 = 0.0; 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: addnum.c 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 .