
5. Flexing My 2D
by CodeChum Admin
I'm a pro-grammer and I want to flex to the world my 2D arrays in an extraordinary way! Ha-ha-ha!
Instructions:
In the code editor, you are provided with an initial code in the main() that asks the user for the elements of a 5x5 2D array and a call to a function called flex2D(). Do not edit anything in the main() function.
Your task is to implement the function definition of the flex2D() with the following details:
Return type - void
Function name - flex2D
Parameters - int[][5]
Definition - prints the elements of each of the row twice.
Input
1. Elements of a 5x5 2D array
Output
Enter the elements:
1 9 2 3 4
8 2 4 0 1
0 3 1 3 4
9 2 3 1 5
8 8 1 7 6
Flex:
1 9 2 3 4
1 9 2 3 4
8 2 4 0 1
8 2 4 0 1
0 3 1 3 4
0 3 1 3 4
9 2 3 1 5
9 2 3 1 5
8 8 1 7 6
8 8 1 7 6
![Output
main.c
< >
+ c
Test Cases
1
#include<stdio.h>
Enter the elements:
3
void flex2D(int[][5]);
ÇE Run Tests
1.9-2-3-4
4
8-2-4 0 1
5- int main(void) {
int matrix[5][5];
e- 3-1-3-4
7
Test Case
9-2-3-1.5
printf("Enter the elements:\n");
for(int row = 0; row < 5; row++) {
for(int col = 0; col < 5; col++) {
scanf("%d", &matrix[row][col]);
}
}
8
1
8.8 17 6
9
10
Flex:
11
1.9- 2-3-4
12
Test Case
13
2
1.9 2 3-4
14
8-2-4 0 1
15
printf("\nFlex:\n");
8-2-4 0 1
16
e- 3-1.3-4
17
flex2D(matrix);
Test
a. 3.1.3.4
18
O Case
Hidden
19
return 0;
20 }
3
Score: 0/10
21
22 // TODO: Implement the function definition](https://content.bartleby.com/qna-images/question/82304115-cf1d-40b3-864e-0ed64499952f/de140973-51b3-4e58-96a9-a4b113bc448d/qoguld1a_thumbnail.png)
![8-2 4 0 1
main.c
+
Test Cases
e 3 1.3-4
9.2 3 15
4
5- int main(void) {
int matrix[5][5];
8-8 1-7-6
CE Run Tests
6
7
Flex:
printf("Enter the elements:\n");
for(int row = 0; row
for(int col = 0; col < 5; col++) {
scanf("%d", &matrix[row][col]);
}
}
1.9 2 3 4
5; row++) {
Test Case
10
1.9 2-3-4
11
1
8-2-4 0 1
12
8. 2-4 0 1
13
e 3 13-4
14
e- 3-1-3-4
15
printf("\nFlex:\n");
Test Case
16
2
9 2-3-1-5
17
flex2D(matrix);
9 2-3-1-5
18
8.8 1.7-6
19
return 0;
20 }
Test
8-8 1.7-6
21
O Case
Hidden
// TODO: Implement the function definition
23 - void flex2D(int arrO[5]) {
22
3
Score: 0/10
24
25 }
>](https://content.bartleby.com/qna-images/question/82304115-cf1d-40b3-864e-0ed64499952f/de140973-51b3-4e58-96a9-a4b113bc448d/fhu15rq_thumbnail.png)

Step by stepSolved in 3 steps with 2 images

- C++arrow_forwardProgramming Language: C++ Please use the resources included and provide notes for understanding. Thanks in advance. Code two functions to fill an array with the names of every World Series-winning team from 1903 to 2020, then output each World Series winner with the number of times the team won the championship as well as the years they won them. The input file is attached, along with the main function and screenprint. Please note team names that include two words, such as Red Sox, have an underscore in place of the space. This enables you to use the extraction operator with a single string variable. The following resources are included: Here is main. #include <iostream>#include <fstream>#include<string> using namespace std; // Add function declarations and documentation here void fill(string teams[], int size);void findWinner(string teams[], int size); int main(){ const int SIZE = 118;int lastIndex;string team[SIZE]; fill(team, SIZE);findWinner(team, SIZE); return…arrow_forwardIn C++Using the code provided belowDo the Following: Modify the Insert Tool Function to ask the user if they want to expand the tool holder to accommodate additional tools Add the code to the insert tool function to increase the capacity of the toolbox (Dynamic Array) USE THE FOLLOWING CODE and MODIFY IT: #define _SECURE_SCL_DEPRECATE 0 #include <iostream> #include <string> #include <cstdlib> using namespace std; class GChar { public: static const int DEFAULT_CAPACITY = 5; //constructor GChar(string name = "john", int capacity = DEFAULT_CAPACITY); //copy constructor GChar(const GChar& source); //Overload Assignment GChar& operator=(const GChar& source); //Destructor ~GChar(); //Insert a New Tool void insert(const std::string& toolName); private: //data members string name; int capacity; int used; string* toolHolder; }; //constructor GChar::GChar(string n, int cap) { name = n; capacity = cap; used = 0; toolHolder = new…arrow_forward
- Which aggregating operations are permitted for struct variables but not array variables, and which are prohibited for array variables?arrow_forwardSummary In this lab, you use what you have learned about searching an array to find an exact match to complete a partially prewritten C++ program. The program uses an array that contains valid names for 10 cities in Michigan. You ask the user to enter a city name; your program then searches the array for that city name. If it is not found, the program should print a message that informs the user the city name is not found in the list of valid cities in Michigan. The file provided for this lab includes the input statements and the necessary variable declarations. You need to use a loop to examine all the items in the array and test for a match. You also need to set a flag if there is a match and then test the flag variable to determine if you should print the the Not a city in Michigan. message. Comments in the code tell you where to write your statements. You can use the previous Mail Order program as a guide. Instructions Ensure the provided code file named MichiganCities.cpp is…arrow_forwardWhen traversing an array, which of the following statements does not need to keep track of the individual array subscripts: Do...Loop, For...Next, or For Each...Next?arrow_forward
- C++ Programming Code two functions to fill an array with the names of every World Series-winning team from 1903 to 2020, then output each World Series winner with the number of times the team won the championship as well as the years they won them. The input file is attached, along with the main function and screenprint. Please note team names that include two words, such as Red Sox, have an underscore in place of the space. This enables you to use the extraction operator with a single string variable. The following resources are included: Here is main. #include <iostream>#include <fstream>#include<string> using namespace std; // Add function declarations and documentation here void fill(string teams[], int size);void findWinner(string teams[], int size); int main(){ const int SIZE = 118;int lastIndex;string team[SIZE]; fill(team, SIZE);findWinner(team, SIZE); return 0;} // Add function definitions here WorldSeriesChampions.txt…arrow_forwardGood evening, i am working on this arrays problem and was hoping you could help with it please? (my programming language is c++) Thanks!arrow_forwardProblem Description - JAVA PROGRAMMING Use a Two-dimensional (3x3) array to solve the following problem: Write an application that inputs nine numbers, each of which is between 1 and 10, inclusive. Display the array after the user inputs each value. Rotate/flip the array by changing places. Make the rows columns and vice versa. You have to move the elements to their new locations. Remember to validate the input and display an error message if the user inputs invalid data. Documentation and the screenshot(s) of the results. Example: 1 2 3 4 5 6 7 8 9 the result will be : 1 4 7 2 5 8 3 6 9arrow_forward
- C++ Coding: ArraysTrue and False Code function definitions for eoNum() and output(): Both eoNum() and output() are recursive functions. output() stores the even/odd value in an array. Store 0 if the element in the data array is even and store 1 if the element in the data array is odd. eoNum() displays all the values in an array to the console.arrow_forwardThe program should allow the user to enter the age of the child and the number of days per week the child will be at the day care center. The program should output the appropriate weekly rate. The file provided for this lab contains all of the necessary variable declarations, except the two-dimensional array. You need to write the input statements and the code that initializes the two-dimensional array, determines the weekly rate, and prints the weekly rate. Comments in the code tell you where to write your statements. 1. Open the source code file named DayCare.cpp using Notepad or the text editor of your choice. 2. Declare and initialize the two-dimensional array. 3. Write the C++ statements that retrieve the age of the child and the number of days the child will be at the day care center. 4. Determine and print the weekly rate. 5. Save this source code file in a directory of your choice, and then make that directory your working directory. 6. Compile the source code…arrow_forwardConsider the following program specification: Write a program that will prompt the user for 10 integer values and stores them in an array. The values entered by the user only be between 0 and 100 and the program should validate these appropriately. The program should then: Display the average of the values Display the highest value in the array Display the lowest value in the array Discuss how the values should be validated. What control structures could be used? Using eclipsearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





