Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ random between two values

int randNum = rand()%(max-min + 1) + min;
Comment

make random nuber between two number in c++

#include <stdio.h>      /* NULL */
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */

int Main()
{
  int randomNumber;

  /* initialize random seed: */
  srand (time(NULL));

  /* generate random number between 1 and 10: */
  randomNumber = rand() % 10 + 1;
	v1 = rand() % 100;         // v1 in the range 0 to 99
	v2 = rand() % 100 + 1;     // v2 in the range 1 to 100
	v3 = rand() % 30 + 1985;   // v3 in the range 1985-2014 
}
Comment

generate random number between two numbers in cpp

int random = offset + (rand() % range);
Comment

PREVIOUS NEXT
Code Example
Cpp :: easy c++ code 
Cpp :: remove at index vector c++ 
Cpp :: minimum and maximum value of a vector in C++ 
Cpp :: default access modifier in c++ in struct 
Cpp :: c++ show current time 
Cpp :: extends c++ 
Cpp :: 2d array using vector 
Cpp :: c++ fibonacci 
Cpp :: mpi_bcast 
Cpp :: c++ string remove first character 
Cpp :: opencv c++ hello world 
Cpp :: what is the short cut way to find the max and min element in an array in c++ 
Cpp :: switch case with string c++ 
Cpp :: convert int to binary string c++ 
Cpp :: calculator c++ 
Cpp :: how to add colored text in c++ 
Cpp :: c++ replace string 
Cpp :: tuple c++ 
Cpp :: bubble sort in c+ 
Cpp :: c++ string contains 
Cpp :: How to reverse a string in c++ using reverse function 
Cpp :: c++ create multidimensional vector 
Cpp :: how to scan array in c++ 
Cpp :: double to int c++ 
Cpp :: on component begin overlap c++ 
Cpp :: Quicksort taking random pivot 
Cpp :: how to sort a string alphabetically in c++ 
Cpp :: c++ pi float 
Cpp :: how to sort in c++ 
Cpp :: what is a template in c++ 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =