CprS 157 Schedule
CprS 157 Class 11
CprS 157 Class 13

### Built-in and User-Defined Data Types Chapter 10 - Class 12

• atomic data types

• integral
• floating point
• range of values and constants
• representation

• list
• assignment expression vs. expression statement
• increment and decrement operators
• bitwise operators
• cast operator
• sizeof operator
• precedence of operators

• character data
• representation
• constants, escape sequences
• conversions

• type coercion
• promotion
• demotion

• user-defined simple data types
• typedef statement
• enumeration types
• internal representation
• assignment
• implicit type coercion
• incrementation
• comparison
• stream I/O

• named and anonymous data types

area.cpp
game.cpp

//******************************************************************
// Area program
// This program finds the area under the curve of a mathematical
// function in a specified interval. Input consists of two float
// values and one int. The first two are the low, high values for
// the interval. The third is the number of slices to be used in
// approximating the area. As written, this program finds the
// area under the curve of the function x cubed; however, any
// single-variable function may be substituted for the function
// named Funct
//******************************************************************

//******************************************************************
// Game program
// This program simulates the children's game Rock, Paper, and
// Scissors. Each game consists of inputs from two players,
// coming from fileA and fileB. A winner is determined for each
// individual game and for the games overall
//******************************************************************

Program area uses a for ... statement to solve the classic problem from freshman calculus of finding the area under a curve. Program game serves as the starting point for today's homework assignment. It illustrates a number of techniques involved in the use of user-defined enumerated datatypes.

### Programming Exercises

• Programming Warm-up Exercises (page 572)

• 10.1  (limits)
10.8-11  (enumeration type)

Solve these exercises in class, to your own satisfaction. If called for, create the appropriate data files and test your program on your data. Demonstrate your solutions to the instructor or to the class TA. There is nothing to hand in from this activity.

### Homework For Chapter 10

• Programming Problem 10.4, page 574 (Rock, Paper, Scissors)

•
Any computer store is LOADED with computer games, and some of the folks who write computer games long ago turned in their VW's for BMW's. You are about to break into that august company! Of course, all beginners have to start with something modest, and what could be more modest than "Rock, Paper, and Scissors"? Never mind about its sales potential. Let's see if we can code an interactive version by suitably modifying the author's file-driven working implementation. Carefully follow the specification in the text and use all of the software development guidelines you know to make a disciplined, careful development of your program design. Then strive for clear, elegant, and correct code. Include enough comments for a knowledgeable reader to have no difficulties in following your lines of thought. Enjoy!