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
Nina [5.8K]
2 years ago
7

How can i take out a random (double) number in between 5.0 to 15.0 in c++?

Computers and Technology
1 answer:
ollegr [7]2 years ago
3 0

Answer:

#include <iostream>

using namespace std;

int main() {

   srand(time(0));

   for(int i=0;i<5;i++)

   {

      double f = (double)rand() / RAND_MAX;//generating random numbers.

       double a= 5.0 + f * (15.0 - 5.0);//random numbers in range provided.

       cout<<a<<" ";

   }

return 0;

}

Explanation:

The above program generate five random numbers in the range 5.0 to 15.0.The function rand() is used to generate random numbers.First we have to call srand(time(0)) otherwise the rand() function will generate same random numbers over and over every time.

You might be interested in
The IT Department already has been testing Windows Server 2012 R2, and some time ago purchased licenses to convert all of its Wi
Nana76 [90]

Answer:

19

Explanation:

5 0
3 years ago
Some of y'all make me lose braincells with your questions
boyakko [2]

Answer:

ok done we will try

BTW have a nice day enjoy your day Stay blessed stay happy stay strong

5 0
2 years ago
Read 2 more answers
Who is mostly affected by computer viruses?
Komok [63]
People who use Windows OS.
3 0
3 years ago
Formatting changes only the appearance of data ___it does not affect the data itself.
Vladimir [108]

Answer:

The answer to this question is "true".

Explanation:

In this question, the answer is true because The use of formatting provides changes in the data presentation, not in the data. It is also known as layout.

The layout or formatting is important for two reasons that can be given as:  

1) It makes your data like a formatted data.

2) It helps to make your data more readable.

8 0
3 years ago
. If you executean infinite recursive function on a computer it will executeforever.
S_A_V [24]

Answer:

b. False

Explanation:

If you execute an infinite recursive function on a computer it will NOT execute forever.

4 0
2 years ago
Other questions:
  • Although the battery on your smartphone is fully charged, it drains quickly. In some instances when the phone shows that the bat
    12·1 answer
  • Changing the user name in the word application is completed through the __.
    10·2 answers
  • A _______ is smaller than a notebook or laptop and has a touchscreen and sometimes a pointing device.
    13·1 answer
  • g What advantage does a circuit-switched network have over a packet-switched network? What advantages does TDM have over FDM in
    10·2 answers
  • USDA-APHIS Animal Care Resource Policy #12 "Considerations of Alternatives to Painful/Distressful Procedures" states that when a
    11·1 answer
  • Consider a binary-search method in an array that reports whether an object is in the array. The documentation indicates that the
    11·1 answer
  • Which of the following involves writing hidden messages so that only the sender and intended recipient know a message exists? St
    5·1 answer
  • Assign the size of userInput to stringSize. Ex: if userInput is "Hello", output is: Size of userInput: 5
    7·1 answer
  • Explain why this scenario could put an organization in jeopardy of losing some of its workforce.
    12·1 answer
  • 300134223+304532264440=
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!