4.20 Simulate the game of craps.
Read QR Code ISO/IEC18004 In NoneUsing Barcode Control SDK for Software Control to generate, create, read, scan barcode image in Software applications.
Make Quick Response Code In NoneUsing Barcode creator for Software Control to generate, create QR image in Software applications.
The game of craps is played with two dice. Each time the pair of dice is tossed, the sum of the two numbers that come up is used. That sum will be an integer in the range 2 to 12 since the faces of each die are numbers 1 to 6. The player wins immediately if he tosses a 7 or an 11, and he loses immediately if he tosses a 2, 3, or 12. If he tosses a 4, 5, 6, 8, 9, or 10, then that number becomes his point. He then repeats tossing the dice until he wins by making his point or he loses by tossing a 7.
Recognize QR In NoneUsing Barcode reader for Software Control to read, scan read, scan image in Software applications.
QR-Code Generator In C#.NETUsing Barcode generator for Visual Studio .NET Control to generate, create QR Code image in Visual Studio .NET applications.
#include #include #include
QR Code Printer In Visual Studio .NETUsing Barcode creation for ASP.NET Control to generate, create QR-Code image in ASP.NET applications.
QR Code JIS X 0510 Generation In VS .NETUsing Barcode maker for .NET framework Control to generate, create QR-Code image in .NET applications.
ciostream.h> cstdlib.h> ctime.h>
Printing QR Code 2d Barcode In Visual Basic .NETUsing Barcode generation for VS .NET Control to generate, create QR Code 2d barcode image in .NET applications.
Generate Code 128 Code Set C In NoneUsing Barcode generation for Software Control to generate, create Code 128 Code Set A image in Software applications.
void initializeSeed(); int toss(); void win(); void lose(); main0 initializeSeed(); int point = toss(); if (point == 2 II point == 3 II point == 12) lose(); if (point == 7 II point == 11) win(); int t; for(x) { t = toss(); if (t == 7) lose(); if (t == point) win();
Code 39 Full ASCII Generation In NoneUsing Barcode encoder for Software Control to generate, create USS Code 39 image in Software applications.
Generating EAN-13 In NoneUsing Barcode maker for Software Control to generate, create GTIN - 13 image in Software applications.
CHAP. 41
UPC-A Creator In NoneUsing Barcode encoder for Software Control to generate, create UPC A image in Software applications.
Draw Bar Code In NoneUsing Barcode creation for Software Control to generate, create barcode image in Software applications.
void initializeSeed
Identcode Creation In NoneUsing Barcode generator for Software Control to generate, create Identcode image in Software applications.
GTIN - 13 Drawer In VS .NETUsing Barcode generator for Reporting Service Control to generate, create GTIN - 13 image in Reporting Service applications.
unsigned seed = time(NULL);
Draw Data Matrix In JavaUsing Barcode creator for Android Control to generate, create Data Matrix ECC200 image in Android applications.
Draw Code-128 In NoneUsing Barcode creator for Office Word Control to generate, create Code 128A image in Microsoft Word applications.
srand (seed) ;
Print Code 128C In JavaUsing Barcode maker for Java Control to generate, create Code 128A image in Java applications.
UPC - 13 Creation In JavaUsing Barcode generation for Android Control to generate, create GTIN - 13 image in Android applications.
int toss0 int die1 = rand()/10%6 + 1; int die2 = rand()/10%6 + 1; int t = die1 + die2; tout C-C "\tYou tossed a ' << t -CC endl; return t;
Code-39 Drawer In NoneUsing Barcode printer for Word Control to generate, create USS Code 39 image in Word applications.
EAN-13 Printer In .NETUsing Barcode drawer for VS .NET Control to generate, create EAN 13 image in Visual Studio .NET applications.
void win0 tout << "\tYou won.\n"; exit(O);
void lose0 tout << "\tYou lost.\n"; exit(O); 3x.2 tossed a .4 Yuu t o s s e d a You tossed a 7 You Just. Y-011 b13sCsed a 8 Yuu +iLxsd3ed a 3, Yc J tossed a 6 Yau tossed a 3 Y%X..I t o s s e d a 8 Yuu wun.
. ;.
.. . .
FUNCTIONS
[CHAP. 4
Supplementary Programming Problems
STANDARD C LIBRARY FUNCTIONS
4.21 Write a simple program like the one in Example 4.2 to check the identity: cos2x + sin2x = 1. 4.22 Write a simple program like the one in Example 4.2 to check the identity:
tan 2x = 2 tan x /( 1 - tan2x).
4.23 Write a simple program like the one in Example 4.2 to check the identity: cosh2X - sinh2x = 1. 4.24 Write a simple program like the one in Example 4.2 to check the identity: asinx + aces x = nl/2. 4.25 Write a simple program like the one in Example 4.2 to check the identity: log x2 = 2 log x. 4.26 Write a simple program like the one in Example 4.2 to check the identity: bx = e@ lo@). 4.27 Write a test driver to test the functions listed in Table 4.1.
USER-DEFINED
FUNCTIONS
function that returns the area of a circle with given
4.28 Write and test the following area ( )
radius: float area(float
4.29 Write and test the following min ( > function that returns the smallest of two given integers: int min(int x, int y)
4.30 Write and test the following min ( >
function that returns the smallest of three given integers:
int min(int x, int y, int z) 4.31 Write and test the following min function that returns the smallest of four given integers: int min(int x, int y, int z, int w) 4.32 Write and test the following min ( >
function that uses the min ( int , int > function to find and return the smallest of three given integers:
int min(int x, int y, int z)
4.33 Write and test the following min ( > function that uses the min ( int , int > function to find and return the smallest of four given integers: int min(int x, int y, int z, int w) 4.34 Write and test the following min ( > function that uses the min ( int , to find and return the smallest of four given integers:
int min(int x, int y, int z, int w) int , int > function
4.35 Write and test the following power ( > function that returns can be any nonnegative integer: float power(float x, unsigned p).