
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
I need to write a C++ program that will read in a two dimensional array from a file after prompting for the file from the user. The first two values in the file are the dimensions of the array. The dimensions will NOT exceed a 20 by 20 2d array and are guaranteed to be at least 0 by 0. The rest of the values will be integers delimited by white space. Determine the largest and smallest values in the file.
Program Requirements:
- Use global constants for the maximum dimensions of the array
- Use a void function called FillArray that accepts four arguments (an input file object, a two dimensional array, the actual row size, and the actual column size). This function should read through the file and fill the array. The file object, row size, and column size should be defined as reference parameters.
- Use a value returning function called FindMax that accepts three arguments: the 2d array as a constant parameter, the row size, and the column size. It should return the largest value in the array.
- Use a value returning function called FindMin that accepts three arguments: the 2d array as a constant parameter, the row size, and the column size. It should return the smallest value in the array.

Transcribed Image Text:1. Sample Run 1 (invalid file)
Enter filename to process: nofile.dat
nofile.dat not found!
2. Sample Run 2 (dataone.dat)
Enter filename to process: dataone.dat
Min value: -4
Max value: 7
3. Sample Run 3 (datatwo.dat)
Enter filename to process: datatwo.dat
Min value: -99
Max value: 100
4. Sample Run 4 (datathree.dat)
Enter filename to process: datathree.dat
Min value: 0
Max value: 0
![1 #include <fstream>
2 #include <iostream>
3 #include <string>
45
const int MAX_DM = 0;
6
7 void FillArray (int arr[], int row_size[], int col_size[]);
bool FindMax(int row_size[], int col_size[]);
bool FindMin(int row_size[], int col_size[]);
8
9
10
11 ✓ int main() {
12
13
14
15
16
17
18
19
20
21
int row_size[MAX_DM];
int col_size[MAX_DM];
std::string filename;
}
std::ifstream data_file;
std::cout << "Enter filename to process:
getline(std::cin, filename);
data_file.open(filename);
22
23 ✓
24
25 ✓
26
27
28
29
30
31
void FillArray (input, int arr[], int row_size[], int col_size[]) {}
32
33 v bool FindMax(int row_size[], int col_size[]) {
34
35 }
36
37 bool FindMin(int row_size[], int col_size[]) {
38
39 }
if (!data_file) {
std::cout << filename <<< "not found!";
} else {
std::cout << filename <<< '\n'
}
<< "Min value: << '\n' << "Max value: ";](https://content.bartleby.com/qna-images/question/3eb03a80-7cae-4d33-b228-e2e0361c370e/514d0238-8f34-422b-88a2-23914a6ac997/xnzg1wq_thumbnail.png)
Transcribed Image Text:1 #include <fstream>
2 #include <iostream>
3 #include <string>
45
const int MAX_DM = 0;
6
7 void FillArray (int arr[], int row_size[], int col_size[]);
bool FindMax(int row_size[], int col_size[]);
bool FindMin(int row_size[], int col_size[]);
8
9
10
11 ✓ int main() {
12
13
14
15
16
17
18
19
20
21
int row_size[MAX_DM];
int col_size[MAX_DM];
std::string filename;
}
std::ifstream data_file;
std::cout << "Enter filename to process:
getline(std::cin, filename);
data_file.open(filename);
22
23 ✓
24
25 ✓
26
27
28
29
30
31
void FillArray (input, int arr[], int row_size[], int col_size[]) {}
32
33 v bool FindMax(int row_size[], int col_size[]) {
34
35 }
36
37 bool FindMin(int row_size[], int col_size[]) {
38
39 }
if (!data_file) {
std::cout << filename <<< "not found!";
} else {
std::cout << filename <<< '\n'
}
<< "Min value: << '\n' << "Max value: ";
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Topical Information Use C++. This lab should provide you with practice in file handling, libraries, and random variate generation. Program Information Write a program that allows the user to create files of random data. They should be offered a menu of possibilities: 1) create random Whole number data file 2) create random Decimal number data file 3) create random Character data file 4) Quit program The first 3 options should ask for appropriate bounds. Your program should make sure they are in order before passing them to your random value generation function. Then, ask how many random values to generate and what file to place them in. Assuming the file opened correctly, proceed to generate all requested random values. The menu should continue to loop until the quit option is chosen. Options should be choosable by either the number or the capitalized word. (For example, to quit, they should be able to enter 4, Q, or q.)arrow_forwardHow do I do this C programming question?arrow_forward59. Question: Write a C++ program. Using Dynamic Array, read a data file containing some names into a dynamically declared array. Note that the total number of names is not known so your program should determine it. Create a second array that contains the names in alphabetical order. Produce an output file containing the alphabetized list. Important: Do not copy codes from prepinsta.com.arrow_forward
- Write a function that will read input into an array from a filearrow_forwardPROBLEM: Create a program that will ask to fill in two square matrices and perform matrix multiplication. Output the resulting matrix in proper format. SPECIFICATIONS that you need to follow: - The maximum size of the square matrices is 10x10. Matrices 1 and 2 should have the same dimensions. - You may only use the codes that we studied under our lectures - All lines of codes should have a comment. - Save your cpp file as Surname_FE (Example: Pangaliman_FE.cpp) TEST CASES: If a user inputs n = 2: Input: Input dimension (nxn) of the matrix, n = 2Input Matrix 1 elements: 1 2 3 4Input Matrix 2 elements: 5 6 7 8 Result: Resultant matrix: 19 22 43 50 If a user inputs n = 10: Input: Input dimension (nxn) of the matrix, n = 10 Input Matrix 1 elements: -35 54 64 31 45 -12 17 -31 -19 -78 -35 54 3 -10 -11 90 -41 31 -30 0 22 -53 21 -13 -64 32 -70 57 58 86 -77 30 73 24 -77 -90 -26 85 48 -47 -96 58 70 -59 82 -97 43 51 45 62 63 40 67 42 52 -78 -69…arrow_forwardUSING PYTHON: Create a function that takes a filename("string") of a PGM image file as input and loads in the image in the file, and returns it as an image matrix. Rules: Cannot make any input calls in the main body, use basic python (nothing like .shape or .width) I have attached an example of what the function should do, as well as what the PGM image file looks like.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- 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

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education