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
Romashka [77]
3 years ago
8

Type two statements that use rand() to print 2 random integers between (and including) 100 and 149. End with a newline. Ex:

Computers and Technology
2 answers:
Dahasolnce [82]3 years ago
8 0

Answer:

#include

#include // Enables use of rand()

#include // Enables use of time()

int main(void) {

int seedVal = 0;

seedVal = 4;

srand(seedVal);

cout<< rand()%(int)(149-100+1) + 100;

cout<< rand()%(int)(149-100+1) + 100;

return 0;

}

Explanation:

The code segment starts at line 8 and ends at line 9.

That is:

cout<< rand()%(int)(149-100+1) + 100;

cout<< rand()%(int)(149-100+1) + 100;

The syntax for generating random values in C using rand function is

rand()%(int)(max - min + 1) + min

Or

min + rand()%(int)(max - min + 1).

It works both ways..

Where max and min represent the range of values needed (maximum and minimum)

The random statement can also be used in loops

rosijanka [135]3 years ago
6 0

Answer:

#include <stdlib.h>

#include <time.h>

#include<iostream.h>

int main(void) {

   int seedVal = 0;  

   seedVal = 4;

   srand(seedVal);

  /* Solution*/

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

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

  return 0;

}

Explanation:

We start with the required include statements to enable use of srand, rand and time functions. I have also added iostream library to use "cout" function.

After that, the seed is initialized using srand(). And then the two rand functions are called with ranges including and between 100 and 149, and printed out.

You might be interested in
We love silky. she is very honest join this by using conjunction ​
VladimirAG [237]

Answer:

we love silky because she is very honest

4 0
3 years ago
Read 2 more answers
Firefox, Chrome, Opera, and Safari are examples of
MrRissso [65]
D. Browsers

You're on one right now! :)

3 0
3 years ago
What are the differences between Cc &amp; Bcc in emails that are sent ?​
Ket [755]

Cc stands for " carbon copy " and Bcc stands for " Blind carbon copy ". The difference between Cc and Bcc is that carbon copy (CC) recipients are visible to all other recipients whereas those who are BCCed are not visible to anyone.

8 0
3 years ago
Read 2 more answers
Instructions:Select the correct answer.
Gnesinka [82]
C) team leader is the answer
4 0
3 years ago
You want to securely erase data from your hard drive what can you use to do this and what is the process called
tankabanditka [31]
You could Factory Reset a computer or you could smash it with  a hammer
7 0
3 years ago
Read 2 more answers
Other questions:
  • Which transformation(s) can be used to map ARST onto
    8·1 answer
  • )in the link based implementation of the ADT sorted list what is the worst case time efficiency of the remove method?
    7·1 answer
  • What does PowerPoint display when you use the Notes Page view?
    14·2 answers
  • Which one of the following items is an example of software?
    12·2 answers
  • A software package developed to handle information requirements for a specific type of business is called a(n) ____. A. outsourc
    10·1 answer
  • Need help please. this effect my technology
    15·1 answer
  • Why is the access date important to include when citing a website? (select all that apply)
    9·2 answers
  • 2.
    11·1 answer
  • Where can a client identify the instant deposit options for their QuickBooks Payments account?
    5·1 answer
  • What are your thoughts on copyright?<br><br> (Write 2 or more sentences)
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!