### random number generation

hey guys,
my question is quick and simple. how do i generate random numbers but between 1 and 52?
i know how to generate numer between 0 and 52 but no idea how to do it if it starting with 1. thanks a lot :)
Have you tried Googling?
http://www.cplusplus.com/reference/random/

Alternatively, [0..51]+1.
Well i can do that but my professor told us in class not to use google becz it is not always a credible source. Anyways thank you guys :)
Try this

 ``12345678910111213141516171819202122232425262728293031323334353637`` ``````#include using std::cout; using std::endl; #include using std::rand; using std::srand; #include using std::time; int main(){ int randomNumber; //randomize random number generator using current time srand(time(0)); cout<<"Generate random numbers between 1-52"<<'\n'<

/*
*
* from C++ How to program,5th edition book:
*
* randomNumber=shiftingValue + rand() % scalingFactor;
*
* where shiftingValue is equal to the first number in the desired range of consecutive integers and scalingFactor is equal to the width of the desired range of consecutive int egers. The exercises show that it is possible to choose integers at random from sets of values other than ranges of consecutive integers.
*/
Topic archived. No new replies allowed.