NEED HELP!
Hey guys! im sorry, kinda off topic here. i need your help!
I need codes for generating random number using C program.
i know u need to use array but i can't seem to get it generating different patterns. :|
EDIT: sorry non repeating numbers tho. ;D
14 years, 13 weeks ago
|
Sordie

Joined: 3rd Apr 2009
Posts: 2044
Re: NEED HELP!
No array needed. Just use the rand() function. ie:
int random_number = rand() % max_random_number;
You should also probably use the srand() function at the start of your program to seed the random number generator. The defacto thing to do is use the time as the seed:
srand(time());
---
http://sordie.co.uk
http://twitter.com/@SordieEO
14 years, 13 weeks ago
|
Chase

Joined: 2nd Apr 2012
Posts: 40
Re: NEED HELP!
14 years, 11 weeks ago
|
Bladex

Joined: 24th Jan 2010
Posts: 1048
Re: NEED HELP!
wow sordie havent seen you in a long time ^^
---
"With your feet steady and firm on the ground soar high and ignore limitations" -Bladex
EOSERV Class : Pixel Artist, Grammar Nazi, Server Owner, Mapping Artist, Server Coder, Test Player,
The Game Maker
14 years, 11 weeks ago
| | | |