/* * SelfTest2.question1.c * Chapter 9 * By John Stile * Purpose: Write a program that generates a random number * between 10 and 30 inclusively using modulus operator. */ #include // gives us printf #include // gives us rand/srand #include // gives us time #define MAX 20 // maro to set the max number int main(void) // header for main: takes nothing returns int { srand( time(NULL) ); // seed rand with current time printf("%d\n", (rand()%MAX+10) ); // pick a random number, // devide by our max value // take the remainder, and add 10 // print the decimal value of result return 0 ; // return 0 to calling progrma }