+ 1
How do i generate a random number between 2 bodies
As above; I wanna make a simple higher/lower card game and i just dont know how to generate a random number
7 Answers
+ 3
Agreed Tina 🕊🇺🇦🇮🇷 . That was a snippet from my help code from other question. Completely it would have looked like this:
https://code.sololearn.com/cjqnVOICZkkg/?ref=app
+ 3
#include <iostream>
#include <cstdlib>
using namespace std;
// generate a random integer number from b up to e
int intRand( int b, int e) {
double r = e - b + 1;
return b + (int)(r * rand()/(RAND_MAX+1.0));
}
// Next time you need show your attempt with a question.
+ 2
JaScript great! perhaps adding a random seed makes it perfect.
+ 2
JaScript your random sequence is always the same pattern.
run the code multiple times.
https://code.sololearn.com/cP2X15VoVPQS/?ref=app
+ 1
Tina 🕊🇺🇦🇮🇷 would you like to show us, how can mentioned code be made perfect?
+ 1
I have learned, that i dont know enough for this question yet. But thats okay
+ 1
Or maybe tina is just trying too hard when i need an introductory answer