Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

¿how a make random numers?

0 votes
asked Jun 6, 2021 by LUNA VEGA BELTRAN (120 points)
i need help with how i do random numers please

2 Answers

0 votes
answered Jun 8, 2021 by xDELLx (10,520 points)
very vague question.

Can u mention he language where u need to achieve the random numbers.
+4 votes
answered Jun 13, 2021 by ITSME (760 points)
edited Jun 13, 2021 by ITSME

In Python you can use random module

Example :

import random
x = random.randint(0,10) # The Numbers in the bracket are the start and stop values
print(x)

or 

import  random
a = ["apple","banana","mango"]
x = random.choice(a)
print (x)

In C language you need to add header file stdlib.h and use inbuilt function rand()

Example:

rand() % (u – l + 1)) + l

Here,

u is the upper limit. l is the lower limit.

So, if we want to find a random number between 0 to 9, it will be :

(rand() % (9 - 0 + 1)) + 0

or

rand() % 10

Similarly, we can find out a random number in a given range using the same formula.

In C++

You can use the same function from C with same header file

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...