1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
V125BC [204]
3 years ago
3

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:
#include
#include // Enables use of rand()
#include // Enables use of time()
int main(void) {
int seedVal = 0;
/* Your solution goes here */
return 0;
}
2). Type two statements that use rand() to print 2 random integers between (and including) 100 and 149. End with a newline. Ex:
101
133
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, srand() has already been called; do not call srand() again.
GIVEN:
#include
#include // Enables use of rand()
#include // Enables use of time()
int main(void) {
int seedVal = 0;
seedVal = 4;
srand(seedVal);
/* Your solution goes here */
return 0;
}
Computers and Technology
1 answer:
lutik1710 [3]3 years ago
7 0

Answer:

1. The solution to question 1 is as follows;

srand(seedVal);

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

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

2. The solution to question 2 is as follows

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

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

Explanation:

The general syntax to generate random number between interval is

Random Number = Lower Limit + rand() % (Upper Limit - Lower Limit + 1)

In 1;

The solution starts by calling srand(seedVal);

The next two statements is explained as follows

To print two random integers between intervals of 0 and 9 using rand()"

Here, the lower limit = 0

the upper limit =  9

By substituting these values in the formula above; the random number will be generated as thus;

Random Number = 0 + rand() % (9 - 0 + 1)

Random Number = 0 + rand() % (10)

Random Number = rand() % (10)

So, the instruction to generate the two random variables is rand() % (10)

2.

Similar to 1 above

To print two random integers between intervals of 100 and 149 using rand()"

Here, the lower limit = 100

upper limit = 149

By substituting these values in the formula above; the random number will be generated as thus;

Random Number = 100 + rand() % (149 - 100 + 1)

Random Number = 100 + rand() % (50)

So, the instruction to generate the two random variables is 100 + rand() % (50)

You might be interested in
What is the difference between word processing software and presentation software​
Gnesinka [82]

Answer:

Word is a word processing program. PowerPoint is presentation software. MS Word is used for preparing documents which have higher quantum of text and tables. ... On the other hand, MS Powerpoint is used in cases where you want to give a presentation.

3 0
3 years ago
Which of the following are options when using the Select tool in Paint? (Select all that apply.)
meriva
I believe the answer is all of them except picture selection<span />
3 0
3 years ago
These are pictorial images displayed on a computer screen​
Mrrafil [7]

Answerthats nice

(: -With Star

Explanation:

3 0
2 years ago
What mass of nh3 can be made from 35g of n2?
Anton [14]
 <span>14 g N in 17 g NH3 
so 35 g N will make 17*35/14 = 42.5 g</span>
3 0
3 years ago
Write a program that: Takes the list lotsOfNumbers and uses a loop to find the sum of all of the odd numbers in the list (hint:
Alika [10]

Answer:

Following are the code to this question:

#include <iostream>//defining header file

using namespace std;

int main()//defining main method

{

int x[]={2,3,4,6,7,8,9,1,11,12};//defining 1-D array and assign value

int i,sum=0;//defining integer variable

for(i=0;i<10;i++)//defining loop for count value

{

   if(x[i]%2==1)//defining if block to check odd value

   {

       sum=sum+x[i];//add value in sum variable

   }

}

cout<<sum;//print sum

return 0;

}

Output:

31

Explanation:

In the above-given program, an integer array "x" is declared that holds some integer values, and in the next line two integer variable "i and sum" is defined which is used to calculate the value.

In the next line, a for loop is declared, that counts all array value, and it uses the if block to check the odd value and add all the value into the sum variable.

5 0
3 years ago
Other questions:
  • _________ is a specially formatted request used to perform ip address to data link address resolution.
    14·1 answer
  • Technician A says copper has a low resistance. Technician B says the length of wire doesn't affect resistance. Who is correct?
    11·1 answer
  • Why is personal responsibility important when considering technology?​
    14·2 answers
  • Is something wrong with Brainly?
    5·2 answers
  • You have a small company and want to keep your cost low, but it is important your employees share data. which network would prov
    13·1 answer
  • What does it mean to design,<br> implement, and maintain computer<br> systems?
    15·1 answer
  • PLEASE HURRY!!!!!!!!!! WILL MARK BRAINLIEST!!
    13·1 answer
  • Which type(s) of license(s) allow the underlying software code to be viewed?
    15·1 answer
  • You compared each letter in the correct word to the letter guessed.
    5·1 answer
  • Olivia wants to change some settings in Outlook. What are the steps she will use to get to that function? open Outlook → File →
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!