Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this c++ task, please statement Purpose: Purpose of this Lab is to familiarize the students with the use of elementary data

I need help with this c++ task, please

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

image text in transcribed

statement Purpose: Purpose of this Lab is to familiarize the students with the use of elementary data structure- Arrays. Another aim is to teach the students how to implement one dimensional and two- dimensional arrays. The students are given small tasks related to 1-D and 2-D arrays which they complete during the lab session under the supervision of the lab instructor. This helps them understand the concepts well which they learn in their lectures. Activity Outcomes: The students will learn how to write methods related to some actions performed on 1-D and 2-D arrays. They will understand how to write simple methods to calculate average of all elements of 1-D array and display how many elements are below and how many are above this average. count and display how many elements in 1-D array are even and how many are odd. find and swap the largest and smallest elements in 1-D array. find and display sum of each row and each column of 2-D array. display elements of row which has the largest sum of elements. display row(s) which contain(s) repeated elements. Theory Review (10 Minutes): Since an array is the basic data structure, the students are already familiar with in their previous courses, nothing can be added here as a review of this data structure. We shall practice solving some exercises related to 1-D and 2-D arrays. Practice Activity with Lab Instructor: Problem Statement: We want to create a program that will store random integers between 0 and 99 in a two dimensional array. The program should find and display sum of all elements stored in the array. Solution: 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 main.cpp int row; 1 #include // Library used for input/output handling 2 #include // Library required to use Random Numbers function (rand():) 3 4 using namespace std; 5 6- int main() { 7 8 // Program to calculate the sum of numbers in a 2D arrays 9 18 int col; 11 12 cout > row; //input the value of rows 14 15 cout > col; //input the value of columns 17 18 int matrix[row][col]; //define a 2D array 19 20 cout

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

Postgresql 16 Administration Cookbook Solve Real World Database Administration Challenges With 180+ Practical Recipes And Best Practices

Authors: Gianni Ciolli ,Boriss Mejias ,Jimmy Angelakos ,Vibhor Kumar ,Simon Riggs

1st Edition

1835460585, 978-1835460580

More Books

Students also viewed these Databases questions

Question

Understand cultural differences.

Answered: 1 week ago

Question

Explain all drawbacks of application procedure.

Answered: 1 week ago

Question

Explain the testing process of accounting 2?

Answered: 1 week ago