Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- int main()
- {
- srand(time(nullptr));
- const int ROWS = 4, COLUMNS = 5;
- int table[ROWS][COLUMNS];
- int sumNegative = 0;
- for (int i = 0; i < ROWS; i++)
- {
- for (int j = 0; j < COLUMNS; j++)
- {
- table[i][j] = rand() % (10 - -10) + -10;
- cout << table[i][j] << " ";
- }
- cout << endl;
- }
- for (int i = 0; i < ROWS; i++)
- {
- for (int j = 0; j < COLUMNS; j++)
- {
- if (table[i][j] < 0)
- {
- sumNegative += table[i][j];
- }
- }
- }
- cout << "Total sum of negatives is: " << sumNegative << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement