Uploaded by spicewolf10

CS1337 Notes

advertisement
CS 1337 9-7-2022
-Most of the time, a FOR loop can be represented by a WHILE loop
-DO-while is the only loop that guarantees the execution of the body at least once.
(useful for menus)
-Read up on pre-test loops and post-test loops
-HW assigned today ? -For HW, you will need the rand() and srand(). srand() will generate a pseudo-random int value between 0 and INT_MAX. You can use it to generate random values between a range [Min, Max]
Ex) rand % n will yield a number between 0 and n-1. So if you want to generate values between 0 and 6 then use rand()%(6+1)
But what if you don't want to start at 0 ? use a number to start before expression. So Min + rand()%(6+1)
reading assignment-- srand()
Download