Figure 9-11 shows the completed guessing game program and includes a sample run of the gram. The statement on Line 15 uses the srand and time functions to initialize the random number generator. The...


Please provide full completed code


Figure 9-11 shows the completed guessing game program and includes a sample run of the<br>gram. The statement on Line 15 uses the srand and time functions to initialize the random<br>number generator. The rand function, which appears in the assignment statement on Line 16,<br>generates a random integer from 1 through 10. The statement assigns the random integer to the<br>randomNumber variable.<br>

Extracted text: Figure 9-11 shows the completed guessing game program and includes a sample run of the gram. The statement on Line 15 uses the srand and time functions to initialize the random number generator. The rand function, which appears in the assignment statement on Line 16, generates a random integer from 1 through 10. The statement assigns the random integer to the randomNumber variable.
1 7/Guessing Game.cpp - number guessing game<br>2 7/Created/revised by <your name> on <current date><br>3<br>4 #include <iostream><br>5 #include <ctime><br>6 //#include <cstdlib><br>7 using namespace std;<br>8<br>9 int main()<br>10 {<br>required for the<br>time function<br>your compiler may require<br>this directive to use the<br>rand and srand functions<br>11<br>12 int numberGuess 0;<br>13<br>14<br>int randomNumber - 0;<br>15<br>16<br>17<br>//generate a random number from 1 through 10<br>srand (static cast<int>(time (0)));<br>randomNumber - 1 + rand() % (10 - 1 + 1);<br>18 //get first guess from user<br>19<br>20<br>21<br>22 while (numberGuess !- randomNumber)<br>23<br>24<br>25<br>26<br>27<br>28<br>cout <« > numberGuess; { cout <« "sorry,="" guess="" again:="" ";="" cin="">> numberGuess; } //end while cout « endl « "Yes, the number is " « randomNumber < «="" endl;="" 29="" 30="" 31="" }="" end="" of="" main="" function="" return="" 0;="" e="" guessing="" game="" guess="" a="" number="" from="" 1="" through="" 10:="" 5="" sorry,="" guess="" again:="" 8="" sorry,="" guess="" again:="" 2="" yes,="" the="" number="" is="" 2.="" press="" any="" key="" to="" continue="" figure="" 9-11="" guessing="" game="" program="" "/="">
Extracted text: 1 7/Guessing Game.cpp - number guessing game 2 7/Created/revised by on 3 4 #include 5 #include 6 //#include 7 using namespace std; 8 9 int main() 10 { required for the time function your compiler may require this directive to use the rand and srand functions 11 12 int numberGuess 0; 13 14 int randomNumber - 0; 15 16 17 //generate a random number from 1 through 10 srand (static cast(time (0))); randomNumber - 1 + rand() % (10 - 1 + 1); 18 //get first guess from user 19 20 21 22 while (numberGuess !- randomNumber) 23 24 25 26 27 28 cout <« "guess="" a="" number="" from="" 1="" through="" 10:="" ";="" cin="">> numberGuess; { cout <« "sorry,="" guess="" again:="" ";="" cin="">> numberGuess; } //end while cout « endl « "Yes, the number is " « randomNumber < « endl; 29 30 31 } //end of main function return 0; e guessing game guess a number from 1 through 10: 5 sorry, guess again: 8 sorry, guess again: 2 yes, the number is 2. press any key to continue figure 9-11 guessing game program «="" endl;="" 29="" 30="" 31="" }="" end="" of="" main="" function="" return="" 0;="" e="" guessing="" game="" guess="" a="" number="" from="" 1="" through="" 10:="" 5="" sorry,="" guess="" again:="" 8="" sorry,="" guess="" again:="" 2="" yes,="" the="" number="" is="" 2.="" press="" any="" key="" to="" continue="" figure="" 9-11="" guessing="" game="">
Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here