how to rand between three integer num1 num2 num 3
fadi_1234 -3 Light Poster
Recommended Answers
Jump to PostYou want a random selection. There are a few ways, but storing those items in a container for random indexing is by far the simplest:
#include <array> #include <cstdlib> #include <ctime> #include <iostream> using namespace std; int main() { srand((unsigned)time(nullptr)); array<int, 3> a = {11, 22, 33}; …
Jump to PostYou keep changing what you ask for. Now answering:
let say that:
num=num2/3
num1=num3/5how to make random between num and num1
Assuming num < num1:
random-number = (rand() % (num1 - num)) + num
All 8 Replies
shauzi158 -4 Newbie Poster
WaltP commented: Learn to use the function before telling someone how to wrongly use it. -3
fadi_1234 -3 Light Poster
shauzi158 -4 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
fadi_1234 -3 Light Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
mrnutty 761 Senior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.