COP 3223C Lecture 16: COP 10:3
Document Summary
Can generate an integer using rand and assign it to an integer variable. Use % with values generated with rand. Rand()%10 would provide this number but also 0 which is not needed. We can add 1 and use rand()%10 + 1. But now there is a possibility of generating 10. To take care of both end points. Numbers are pseudo random, always will be the same. Force numbers to be chosen from a different starting point with srand. Srand is utilized before the random number and always once. Programs have been limited to user input via console and output of results to screen. This does not allow us to store results. To store results we need les, available even after the program is nished. Files can also be used to provide input. This is how real world programs work. Initialize the le pointer to point to the address of the le.