Click here to Skip to main content
15,920,110 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
i have project online examination. i want to generate a random number only once second time that number not generate,because i want to select question with respect to that number.
total no of no generate is 40.
my platform is c#.net(website)
Posted
Updated 17-Mar-11 18:06pm
v2
Comments
[no name] 18-Mar-11 0:08am    
Edited for Easy readablitiy and removed the email since it will be marked as spam.

Hope Simple Random Number Generation[^]article from CP might help you.
 
Share this answer
 
Comments
Albin Abel 18-Mar-11 1:13am    
Good link. Really random number generation is a tricky business, because the under the hood it is a mathematical formula which generate a sequence and what we get is just a random pick from the sequence and not purely random. I feel it is good article trying for a pure random number. My 5
[no name] 18-Mar-11 1:31am    
Thanks AlbinAbel.
Sandeep Mewara 18-Mar-11 3:34am    
Good link. 5!
[no name] 18-Mar-11 3:35am    
Thanks Sandeep.
Espen Harlinn 18-Mar-11 5:26am    
Nice link, my 5
There is no guarantee that the chance of the number not coming again unless you remove the number from the set. Simple probability theory in 6th standard. From the deck of playing cards random choosing your queen can happen again and again unless the chosen queen is removed from the deck.

You can very well use a good random number generator as the link given by Ramalinga's or use .Net's Random class. If you range is large you perceive there is no repetition. But not 100% true. What you need is check before using that number that did you already got it or not. Then discard it if already got it.
 
Share this answer
 
v2
Comments
Sandeep Mewara 18-Mar-11 3:34am    
Good answer. 5!
Albin Abel 18-Mar-11 4:07am    
Thanks Sandeep Mewara
Espen Harlinn 18-Mar-11 5:26am    
Nice reply, my 5
Albin Abel 18-Mar-11 5:47am    
Thanks Espen Harlinn

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900