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]
3 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]3 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
Does anyone know a working free spotify premium on ios 2021 plz i have had any luck finding anything:(​
natima [27]
No sorry

................
5 0
3 years ago
Read 2 more answers
Assslainsdffddsvvdesdssbhasasco5m
alexandr402 [8]
Hahahahaha I wanna was the day I wanna was the last time I got to
8 0
3 years ago
Read 2 more answers
What is the car on the right?
oksano4ka [1.4K]

looks like a rxc custom gt3 with a v6 *badass sport car*

3 0
3 years ago
What was the importance of the turing machine to today’s computers?
Ronch [10]
It helps you with life and brainly
5 0
3 years ago
When is it not necessary to invoke the method myMethod using dot notation? When myMethod is private. When myMethod is invoked by
Paraphin [41]

Answer:

When myMethod is invoked by a method in the same class as myMethod.

Explanation:

When you are in a class, it is like a different enviroment and within that class you can call a method without using the dot notation because you are still within the class.

Outside the class and despite the type of method, public, private or static, the dot notation will be required.

5 0
3 years ago
Read 2 more answers
Other questions:
  • Write a complete program to do the following: The main program calls a method to read in (from an input file) a set of people's
    12·1 answer
  • Ou have just set up a network that will use the tcp/ip protocol, and you want client computers to obtain ip configuration automa
    9·1 answer
  • Could this be restored? And is it worth the money it’d take?
    9·2 answers
  • Can web sites contain copyright material? <br> Yes <br> No
    10·2 answers
  • The CSS property of top , bottom , left , or right moves the element the specified distance from the respective edge of the clos
    7·1 answer
  • A port is the point at which a peripheral device attaches to or communicates with a computer or mobile device. True False
    15·1 answer
  • Implement the function printTwoLargest that inputs an arbitrary number of positive numbers from the user. The input of numbers s
    14·1 answer
  • Which of these expressions is used to check whether num is equal to value?
    13·1 answer
  • You can use a minus sign to make a negative numberlike -2. What happens to each of the following 2++2
    8·1 answer
  • 72. In Object Oriented Programming, a class_____ starts
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!