Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ Create a program that does the following Create an array of 30 numbers. Fill the array with the numbers 40 through 69, For example,

c++

Create a program that does the following

  • Create an array of 30 numbers.
    • Fill the array with the numbers 40 through 69,
    • For example, the zero elements of the array should contain 40 while the one element should contain 41.
    • Print the array out to the screen.
  • Then create a second array of size 20.
    • Fill this array with random numbers.
    • Hint, you can use the random number code from here to help: C++ Random Numbers
  • Find the SUM of all 20 of these numbers.
  • Then print the SUM of the numbers followed by the list of random numbers to a text file called "numbers.txt."
  • --------------------------------------------------------------------------------------------------------------------------------------------------------
  • C++ Random Numbers

  • Step 1 :
    • #include
    • #include
  • Step 2:
    • above "using namespace std" type the following lines. Outside main()
      • unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
      • std::default_random_engine rd(seed1);
      • std::mt19937 mt(rd());
  • Step 3:
    • prototype one of the two following functions
      • int makeRandomInt(int, int);
        • OR
      • double makeRandomDouble(int, int);
  • Step 4a:
    • Create the following function if you want random Ints:
      • int makeRandomInt(int MIN, int MAX)
      • {
      • std::uniform_int_distribution dist(MIN, MAX);
      • return dist(mt);
      • }
  • Step 4b
    • Create the following function if you want random Ints:
      • double makeRandomDouble(int MIN, int MAX)
      • {
      • std::uniform_real_distribution dist(MIN, MAX);
      • return dist(mt);
      • }
  • Step 5
    • Use the function in the main
      • x = makeRandomInt(1,10);
        • or
      • x = makeRandomDouble(1,10);
      • Where 1 is the min and 10 is the max.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions