Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to make randomizer c++

#include <bits/stdc++.h>
using namespace std;

int main(){
  	int n = 5,m = 10;
    //Make randomizer depended on time so it returns different value everytime
	srand(time(0));
  	//Now you can get random numbers like this
  	int a = rand();
  	//If you want it to be in range of for example integers 'n' and 'm'
  	int b = rand() % m + n;
    //this is gonna be at min 5, and at max 9 since n = 5, m = 10.
  
  	/*
    NOTE THAT THIS IS NOT A TRUE RANDOMIZER, RANDOMIZING NUMBERS IS NOT A THING,
  	INSTEAD, PROGRAMMING LANGUAGES HAVE THEIR FORMULAS TO CALCULATE A RANDOM
  	NUMBER FROM A VALUE THAT YOU PASS TO IT, AND SINCE THIS VALUE IS DEPENDED
    ON ThE TIME, IT IS AS RANDOMIZED AS IT CAN GET.
    */
}
 
PREVIOUS NEXT
Tagged: #randomizer
ADD COMMENT
Topic
Name
3+4 =