//random/sleep //program prints 6 random numbers //and sleeps 1 second between eache number #include #include #include void sleep(clock_t wait) { clock_t goal; goal=wait + clock(); while (goal > clock()); } void main(void) { int i; //seeds the random_number generator with current time so that //the numbers will we different every time we run. srand((unsigned)time(null)); long t = time(null); //display 6 numbers for (i = 1; i <=6; i++) { if (i == 6) cout <<"Bonus number is" << " " << rand()%59 << endl; else cout << 1 + rand()%59 << " "; sleep(1000); } } ------------------------------------------------------- POINTERS ======== a pointer is a variable whose value points to another variable's address. in order to have a pointer actually point to another variable it is necessary to have the memory address of that variable. to get the memory address of the variable, put the & sign in front of the variable name. this is called the reference operator, because it returns the memory address. #include int main() { int x; //a normal integer int *pointer; //a pointer to an integer pointer = &x; //READ IT, "pointer equals the address of x" cin >> x; //reads in x cout << *pointer; //NOTE the use of the * to outputthe actual number stored in x return 0; } /* notice that; the pointer is initialized to pointto a specific memory address before it is used. if this was not the case, it could be pointing to any thing. * the delete operator frees_up the memory allocated through new. to do so, the syntax is as follows: delete pointer; ---------------- #include int main() { int students; cout <<"Enter the number of students :"; cin >> students; cout <<"\nNumber of students :" << students; cout << "\n\n"; return 0; } ----------------- #include int main() { int students; int *ptrstudents; ptrstudents = &students; cout <<"Enter the number of students :"; cin >> students; cout <<"\nNumber of students :" << students <<"\nThat is: " << *ptrstudents << " students." ; cout << "\n\n"; return 0; } on test.. *write an array of integers that creates an array of 10 integers *int r=what(2,x); cout << what(x,r) << endl;