tailieunhanh - Absolute C++ (4th Edition) part 8

Absolute C++ (4th Edition) part 8. KEY BENEFIT: C++ programming concepts and techniques are presented in a straightforward style using understandable language and code. KEY TOPICS: C++ Basics; Flow of Control; Function Basics; Parameters and Overloading; Arrays; Structures and Classes; Constructors; Operator Overloading, Friends, and References; Strings; Pointers and Dynamic Arrays; Separate Compilation and Namespaces; Streams and File I/O; Recursion; Inheritance; Polymorphism and Virtual Functions; Templates; Linked Data Structures; Exception Handling; Standard Template Library; Patterns and UML. MARKET: Useful for both beginning and intermediate C++ programmers. . | Loops 71 Self-Test Exercises 18. What is the output of the following int count 3 while count 0 cout count 19. What is the output of the following int count 3 while count 0 cout count 20. What is the output of the following int n 1 do cout n while n 3 21. What is the output of the following int n 1 do cout n while n 3 22. What is the output produced by the following x is of type int. int x 10 while x 0 cout x endl x x - 3 23. What output would be produced in the previous exercise if the sign were replaced with 24. What is the output produced by the following x is of type int. int x 10 do cout x endl x x - 3 while x 0 72 Flow of Control 25. What is the output produced by the following x is of type int. int x -42 do cout x endl x x - 3 while x 0 26. What is the most important difference between a while statement and a do-while statement THE COMMA OPERATOR comma The comma operator is a way of evaluating a list of expressions and returning the operator value of the last expression. It is sometimes handy to use in a for loop as indicated in our discussion of the for loop in the next subsection. We do not advise using it in other contexts but it is legal to use it in any expression. The comma operator is illustrated by the following assignment statement result first 2 second first 1 The comma operator is the comma shown. The comma expression is the expression on the right-hand side of the assignment operator. The comma operator has two expressions as operands. In this case the two operands are first 2 and second first 1 The first expression is evaluated and then the second expression is evaluated. As you may recall from Chapter 1 the assignment statement when used as an expression returns the new value of the variable on the left side of the assignment operator. So this comma expression returns the final value of the variable second which means that the variable result is set equal to 3. Since only the value of the second expression is returned the first expression is .

TỪ KHÓA LIÊN QUAN