Skip to content

Instantly share code, notes, and snippets.

@Shariefh
Created October 26, 2013 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shariefh/7172321 to your computer and use it in GitHub Desktop.
Save Shariefh/7172321 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <iomanip>
using namespace std;
const int rows = 4;
const int columns = 6;
void print_array(int array[][6], int);
int main()
{
int array1[rows][columns];
int salesperson; //declare salesperson variable to use in while loop
int product; // variable for user to input product number
int amountSold; // variable for user to input quantity sold.
cout << "Enter the salesperson (1 -4), product number (1 -5), and total sales" << endl;
cout << "Enter -1 for the salesperson to end input. " << endl;
cin >> salesperson >> product >> amountSold;
while (salesperson != -1)
{
array1[rows][columns] += amountSold;
cin >> salesperson;
}
cout << "The total sales for each salesperson are displayed at the end of each row\n" <<
"and the total sales for each product are displayed at the bottom of each column" << endl;
cout << "\n" << setw(7) << "1" << setw(7) << "2" << setw(7) << "3" << setw(7) << "4" << setw(7) << "5" << setw(10) << "Total" << endl;
void print_array();
system("pause");
}
void print_array(int array[][6], int columns)
{
for (int i = 0; i <4; i++)
{
for (int j = 0; j < columns; j++)
cout << array[i][j] << " ";
cout << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment