Question
Lines 10& 11 are wrong
CHALLENGE 2.19.2 rand function: Seed and then get random numbers Type a statement using srand0 to seed random number generation using variable seedVal. Then type two statements using rand to print two random integers between (and including) 0 and 9. End with a newline. Ex Note. For this activity, using one statement may yield different output (due to the compiler calling rand0 in a different order). Use two statements for this activity. Also, after calling srand) once, do not call srand0 again. (Notes) | #include <tostreao 2 #include <cstdlìb> // Enables use of rando 3 using nomespace std 5 int moin) 6 int seedVal; 8 cin >>seedVal; 9 10 cout<s(randx9)<cendl; 11 cout<<CrandO10)<cendl;/ Your solution goes here / 12 13 return ; 14 ) Run

Lines 12 & 13 are wrong
media%2F213%2F2138f385-4469-48f9-ad4f-b0
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include<iostream>
#include<cstdlib>
#include<ctime>

using namespace std;

int main()
{
   int seedVal;
   cin>>seedVal;

   srand(seedVal);


   cout<<(rand()%10)<<endl;
   cout<<(rand()%10)<<endl;

   return 0;
}


//////////////////////////////////


#include<iostream>
#include<cstdlib>
#include<ctime>

using namespace std;

int main()
{
   int seedVal;
   cin>>seedVal;

   srand(seedVal);


   cout<<(100+(rand()%50))<<endl;
   cout<<(100+(rand()%50))<<endl;

   return 0;
}
Add a comment
Know the answer?
Add Answer to:
Lines 10& 11 are wrong Lines 12 & 13 are wrong CHALLENGE 2.19.2 rand function: Seed...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C PROGRAM ONLY!!! 1). Type a statement using srand() to seed random number generation using variable...

    C PROGRAM ONLY!!! 1). Type a statement using srand() to seed random number generation using variable seedVal. Then type two statements using rand() to print two random integers between (and including) 0 and 9. End with a newline. Ex: 5 7 Note: For this activity, using one statement may yield different output (due to the compiler calling rand() in a different order). Use two statements for this activity. Also, after calling srand() once, do not call srand() again. (Notes) GIVEN:...

  • CHALLENGE ACTIVITY 13.1.2: Basic function call. Complete the function definition to output the hours given minutes....

    CHALLENGE ACTIVITY 13.1.2: Basic function call. Complete the function definition to output the hours given minutes. Output for sample program: 3.5 1 test passed All tests passed 1 #include <iostream> 2 using namespace std; 3 4 void OutputMinutesAsHours (double origMinutes) { 5 6 /* Your solution goes here */ 7 8} 9 10 int main() { 11 double minutes; 12 13 cin >> minutes; 14 15 OutputMinutesAsHours (minutes); // Will be run with 210.0, 3600.0, and 0.0. 16 cout <<...

  • Find and fix errors #include <iostream> #include <cstdlib> #include <ctime> using namespace std; const int MIN...

    Find and fix errors #include <iostream> #include <cstdlib> #include <ctime> using namespace std; const int MIN = 1; const int MAX = 10; int getRandom(int low, int high); int main() {    int random_num = 0; int player_num; int tries; int seed = static_cast<int>(time(0)); bool guessed = false;    srand(seed); // call the getRandom function below       tries = 4; while ( tries > 0 && !guessed ) { cout << "Enter a number within the range 1 to...

  • ​Declare an array with 1000 elements of type int Then in a loop generate 1000 random numbers and assign one to each element in the array The random numbers should be between 1 and 50 Then, prompt the user to enter a number, store this number in a local

    Rules to follow are:Declare an array with 1000 elements of type intThen in a loop generate 1000 random numbers and assign one to each element in the arrayThe random numbers should be between 1 and 50do not use rand or srand, use code is providedThen, prompt the user to enter a number, store this number in a local variable, the number should be safety checked using the GetInteger() functionThen, iterate through the array and determine how many times the user's...

  • In this lab we are going to complete a profile of two sorting algorithms by running...

    In this lab we are going to complete a profile of two sorting algorithms by running some tests to collect empirical data. 1. First we need to be able to generate some random integers. You can do this by including the following library : #include Now first run the following to generate a seed : srand (time(NULL)) You can then generate a random number using the function rand() 2. We will use two sort algorithms - Selection Sort and Bubble...

  • CHALLENGE ACTIVITY 3.11.1: Using boolean. D Assign is Teenager with true if kidAge is 13 to...

    CHALLENGE ACTIVITY 3.11.1: Using boolean. D Assign is Teenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign is Teenager with false. 1 import java.util.Scanner; 3 public class TeenagerDetector 1 public static void main (String [] args) { Scanner scnr = new Scanner(System.in); boolean isTeenager; int kidAge; D}]oll kidage = scnr.nextInt(); /* Your solution goes here */ Go USB if (isTeenager) { System.out.println("Teen"); else { System.out.println("Not teen"); 20 Run Feedback? CHALLENGE ACTIVITY 3.11.2: Boolean in branching statements. Write...

  • What are the errors in the following code? My professor gave us this prewritten code and...

    What are the errors in the following code? My professor gave us this prewritten code and asked us to find the errors in it so that it can run properly #include <cstdlib> #include <ctime> #include <iostream> using namespace std; // input: integer // output: none // adds five to the given parameter void addFive( int x ) { x += 5; } // input: none // output: a random number int generateRandomNumber() { srand( time(0) ); return rand() % 100;...

  • Use Dev C++ for program and include all of the following. Im lost. Make sure the...

    Use Dev C++ for program and include all of the following. Im lost. Make sure the user enters a letter of R, P, or S and the computer generates a number between 0-2 and changes that number to a letter of R, P or S, using a switch. Make sure the user knows why he/she has won or lost – print a message like “Paper covers Rock” or “Scissors cuts Paper”. Ask the user how many times he/she wants to...

  • Code in C++ Function Prototypes For the second part of the lab activity, you will be...

    Code in C++ Function Prototypes For the second part of the lab activity, you will be practicing writing function prototypes. Continue working on the same project from part A. First, rewrite the code so that you are using function prototypes for the functions getNumber.getMessage, and repeat. Remember that the prototypes go at the top of the file, followed by main, then the definitions of the three functions at the end. Second, you will be creating a new function (procedure) called...

  • c++ program Solitaire Battleship: I've posted in the pub/prog4 folder: AssignmentBase.cpp solution.o Since we aren't using...

    c++ program Solitaire Battleship: I've posted in the pub/prog4 folder: AssignmentBase.cpp solution.o Since we aren't using file i/o for this assignment, solution.o will be executable by default. Refer to previous assignments for instructions on copying down the provided files. You only have to write the bodies for the functions: displayBoard calculateAttack checkGameOver I have provided: main initBoard For this assignment you can change any code you want, I will only grade you on output. I don't mind if you change...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT