// Attached: HW_2b
// ===========================================================
// File: HW_2b
// ===========================================================
// Programmer: Elaine Torrez
// Class: CMPR 121
// ===========================================================
#include <iostream>
#include <iomanip>
using namespace std;
// Function prototypes
void getData(int array[][4], int rows);
void displayArray(int array[][4], int rows);
void clearScreen();
int main()
{
const int ROWS = 3;
const int COLS = 4;
int numArray[ROWS][COLS];
getData(numArray, ROWS);
displayArray(numArray, ROWS);
return 0;
}
// ===========================================================
void getData(int array[][4], int rows)
{
cout << "Enter integers into the 2-Dimensional array:\n";
for (int row = 0; row < rows; row++)
{
for (int col = 0; col < 4; col++)
{
cout << "Enter a number: ";
cin >> array[row][col];
}
}
}
// ===========================================================
void displayArray(int array[][4], int rows)
{
clearScreen();
cout << "Here is the data in the 2-Dimensional array:\n";
for (int row = 0; row < rows; row++)
{
for (int col = 0; col < 4; col++)
{
cout << setw(6) << array[row][col];
}
cout << endl;
}
cout << "\nPress any key to continue . . .";
cin.get();
cin.get();
}
// ===========================================================
void clearScreen()
{
system("cls"); // Windows
// system("clear"); // Mac/Linux
}