Type a statement using srand() to seed random number generation using variable seedVal. Then type two statements using rand() to print two random integers between (and including) 0 and 9. End with a newline. Ex:
5 7
#include <stdio.h> #include <stdlib.h> // Enables use of rand() #include <time.h> // Enables use of time() int main(void) { int seedVal; seedVal = 0; srand(seedVal); printf("%d\n", (rand() % 10) + 0); printf("%d\n", (rand() % 10) + 0); return 0; }
Fixed range of random numbers.
Type two statements that use rand() to print 2 random integers between (and including) 100 and 149. End with a newline. Ex:
101 133
#include <stdio.h> #include <stdlib.h> // Enables use of rand() #include <time.h> // Enables use of time() int main(void) { int seedVal; seedVal = 4; srand(seedVal); printf("%d\n", (rand() % 50) + 100); printf("%d\n", (rand() % 50) + 100); return 0; }