Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 6.17 Random Numbers
- Deitel & Deitel C++ How to Program, 10th ed (Indian subcontinent adaptation)
- Visual Studio Community 2019
- */
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- srand(static_cast<unsigned int>(time(0)));
- // just one statement:
- cout << "0, 3, 6, 9, 12: " << rand() % 5 * 3
- << "\n3, 5, 7, 9, 11, 13: " << rand() % 6 * 2 + 3
- << "\n6, 10, 14, 18: " << 6 + rand() % 4 * 4 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment