-
C++ Help
I am writing the code to generate random number but I am not sure how to begin. Can someone please see if you can help me out.
I am entering the function prototype and the function to generate a random number. The function will accept two integer arguments and return a random number between those two values (inclusive). For example, if the two argument values passed to the function are 1 and 10, the function will return a random integer number in the range of 1 to 10. From the main function, prompt the user for the two numbers, call the function, and display the random number.
thanks
Nazma
-
Well do you know how to generate a random number period? As in , do you know the standard call for a random number? That would be a good place to start. You just call rand( ) for a random number. Make sure you include stdlib.h ( or cstdlib ) for it though. You'll probably also want to seed the generator with something like the current time. Try time.h ( or ctime ) and then call srand( time( NULL ) ); Only call this once in the beginning of your program and you should be fine. If you have problems figuring out more, give this a try and post your code. We will be happy to help.
-