

 Thread Tools  Search this Thread 
#1
 
 
Function for two random numbers I need code to create function for the random selection between two numbers, I looked on the internet for examples of uses, but I did not understand much, but what l want know is that how to use the random number in c program. 
#2
 
 
Re: Function for two random numbers Try this : Code: int random (int min, int max) ( return (int) (min + ((float) rand () / RAND_MAX * (max  min + 1))); ) 
#3
 
 
Re: Function for two random numbers The key function in generating random numbers is; int random (int n); which generates a random number in the range of 0 to n1. Random number generators (pseudorandom, of course) in C; mostly fast oneliners for "inline" use (to eliminate call / return overhead). "srand()/rand()" isn't exactly the most sophisticated random number generator in the world. 
#4
 
 
Re: Function for two random numbers The random number generator produces a sequence of numbers that gives the appearance of being random, when in fact the sequence will eventually repeat and is predictable. Generating random numbers in C is needed in several applications. For instance, generating a default password for a new user on a network uses random generation of numbers and letters. 

Tags: c program, code, function, internet, random number 
Thread Tools  Search this Thread 

Similar Threads for: "Function for two random numbers"  
Thread  Thread Starter  Forum  Replies  Last Post 
Generate some quality of random number via Random Number Generation function  aMADeO!  Windows Software  4  13012012 05:07 PM 
C sharp program to print random numbers  Prashobh Mallu  Software Development  5  12012010 12:07 PM 
Random Numbers in C  Rob Dizzle  Software Development  5  30122009 10:37 AM 
Want an array of Random numbers  InterNetWorKed  Software Development  4  03112009 02:17 PM 
Random numbers. Help  tetilda  Software Development  2  15092008 05:52 PM 