|
|
||||
|
|
rand()Prototype: int rand();Header File: stdlib.h (C) or cstdlib (C++) Explanation: rand returns a value between(inclusive) 0 and and RAND_MAX (defined by the compiler, often 32767). To get a more mangeale number, simply use the % operator, which returns the remainder of division. Example:
//Program returns a random number
#include <iostream&rt;
#include <cstdlib&rt;
using namespace std;
int main()
{
cout<<rand();
cout<<rand()%6; //Number between 0 and 5
}
Other Functions
----- |
|
||