Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Tasks: The aim of this question is to practice the usage of random numbers and arrays in C++. Basically, you are asked to write a
Tasks: The aim of this question is to practice the usage of random numbers and arrays in C++. Basically, you are asked to write a C++ program as follows. Declare two arrays of size 5 . One array will store the values of sum of selection and the second one will store the number of selections. Every element in the two arrays is calculated as follows: generate random numbers between 0 and 1 until their sum exceeds 1, then, store the sum as an element in the first array. The number of generated random numbers for that sum is stored in the second array. For example, if the program generated 0.3,0.57 and 0.45=1.32 which exceeds 1 , then the first element in the first array will be 1.32 (sum 1 of the three random numbers) and the first element in the second array will be 3 (number of generated random numbers until sum exceeds one.). The program will continue until it stores n elements in each array. For every element to be stored in the first array, display the generated random numbers as given in the sample output. Finally, the program displays the output of the two arrays. Figure 1 shows a sample output of the program
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started