Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this c++ task Problem Statement: We want to create a program that will store random integers between O and 99 in

I need help with this c++ task

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Problem Statement: We want to create a program that will store random integers between O and 99 in a two-dimensional array. The program should find, and display sum of all elements stored in the array. Solution: Use : rand() function for generating random numbers. What is rand()? rand() function is an inbuilt function in C++ STL, which is defined in header file. rand() is used to generate a series of random numbers. We use this function when we want to generate a random number in our code. Like we are making a game of ludo in C++ and we have to generate any random number between 1 and 6 so we can use rand() to generate a random number The random number is generated by using an algorithm that gives a series of non-related numbers whenever this function is called. Like we want to generate a random number between 1-6 then we use this function like - Num = rand() % 6+1; Syntax int rand(); Parameters The function accepts no parameter(s) - Return value This function returns an integer value between 0 to RAND_MAX. Create a project with the name "ArrayProject" Inside this project, create a main class with the name "SumElements and add the following code in this class Output sample: Enter number of rows: 3 Enter number of colums: 3 Generating randowm numbers in matrix of 3 rows and 3 colums: Matrix [0,0]= 3 Matrix [0,1]= 6 Matrix [0,2]= 7 Matrix [1,0]= 5 Matrix [1,1]= 3 Matrix [1,2]= 5 Matrix [2,0]= 6 Matrix [2,1)= 2 Matrix [2,2)= 9 The sum of all elements of the above array is 46 | LAB EXERCISE: 1. Create a new project with the name Lab1_Arrays. Inside this project, create a file with the name ArrayExercises. II. In ArrayExercises file create the following methods: 1) fillArray_1D(array, size) method, to initialize the 1D array with random values (between 0 and 99) void fillArray_1D(int array(), int size}{ for(int i = 0; i

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions