garryhtreez

6.17

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