
|
| physics chemistry maths science forums |
|
|
|
| |
|
|
Community Discussion Question:
C++
|
| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 22 Apr 2008 21:58:50 IST
|
|
|
How to use randomizer funtion to generate random nos?
|
Live life king size |
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 23 Apr 2008 17:45:41 IST
|
|
|
use rand function like
int a=rand()
to get numbers in a range say 0 to 9
int a=rand() % 10
you need cstdlib for this
|

|
this reply: 0 points
(with 0 
in 0 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 23 Apr 2008 22:21:22 IST
|
|
|
int x = rand(n);
the above function generates a random number from 0 to (n-1)
The function is defined under "stdlib.h"
|
   
|
this reply: 0 points
(with 0 
in 0 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
|
|
|
|
|
|
|