Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C++ language pts in total) Part 4: rand() and conditional statements pt) In your assignment, you have variables, the need to use rand(), and

in C++ language
image text in transcribed
image text in transcribed
image text in transcribed
pts in total) Part 4: rand() and conditional statements pt) In your assignment, you have variables, the need to use rand(), and conditionals. Create program called rand_numbers.cpp and type the following program into the file. cout "x="x endl; return 0; \} Compile and run the above program 3 times. - What is the result of each rand() for the different executions? Comment out the srand() function call. Compile and run the above program 3 times. - What is the result of each rand() for the different executions? Now add an additional srand() function call in between the two rand/cout lines of code, so there are two srand() function calls. Compile and run the above program 3 times. - What is the result of each rand() for the different executions? (1 pt) Edit your rand_numbers.cpp program so that it chooses a random int that is in the range 0-5 based on the value returned from rand(). I think the mod operator \% would be very useful here. What is anything mod 5 or 6 ? How can this help you? Print the random 05 number to the screen. Now, use this number, 0-5, to select which message to print: - If the number is 0, print "Bummer, I'm zero!!!" - Else if the number is odd, 1, 3 or 5 , print "I'm an odd number!" - Else it's an even number, print "I'm an even number!" (1 pt) Now, determine which odd number or even number you have by using nested if blocks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Does your strategic intent lay out the priorities?

Answered: 1 week ago