Wednesday, June 10, 2009

Dr. Arvind Poswal Hot Comments



The following example generates random numbers until it produces the number 0. The keys are the time.h library, and functions srand and rand.

/ * rand example: guess the number * / # include
< time.h>
< iostream>
# include using namespace std;
int main ()

{int i = 1;
srand (time (NULL));
i = 1;
while (i! = 0) {court
<< i<<",";
i = rand ()% 10;

} system ("PAUSE") ;
return 0;}

0 comments:

Post a Comment