#include<iostream>
using namespace std;
int main()
{
int i, j, rows, columns, sum;
cout << "
Please Enter the Matrix rows and Columns = ";
cin >> i >> j;
int sumRCArray[i][j];
cout << "
Please Enter the Matrix Items = ";
for(rows = 0; rows < i; rows++) {
for(columns = 0; columns < i; columns++) {
cin >> sumRCArray[rows][columns];
}
}
for(rows = 0; rows < i; rows++)
{
sum = 0;
for(columns = 0; columns < j; columns++)
{
sum = sum + sumRCArray[rows][columns];
}
cout << "
The Sum of Items in " << rows + 1<< " Row of a Matrix = " << sum ;
}
for(rows = 0; rows < i; rows++)
{
sum = 0;
for(columns = 0; columns < j; columns++)
{
sum = sum + sumRCArray[columns][rows];
}
cout << "
The Sum of Items in Column of a Matrix = " << sum ;
}
return 0;
}
Code Example |
---|
Cpp :: function overloading in c++ |
Cpp :: word equation numbers |
Cpp :: stack c++ |
Cpp :: c++ string slicing |
Cpp :: cpp lambda function |
Cpp :: how to print in new lines in C++ |
Cpp :: cuda shared variable |
Cpp :: cpp array init value |
Cpp :: c++ convert const char* to int |
Cpp :: ++ how to write quotation mark in a string |
Cpp :: best time to buy and sell stock leetcode solution |
Cpp :: resize string c++ |
Cpp :: why convert char* to string c++ |
Cpp :: long pi in c++ |
Cpp :: Traversing a C++ Array |
Cpp :: passing custom function in sort cpp |
Cpp :: C++ sum a vector of digits |
Cpp :: C++ Calculating the Mode of a Sorted Array |
Cpp :: find text in string c++ true false |
Cpp :: QVariant to int |
Cpp :: for statement c++ |
Cpp :: c++ polymorphism |
Cpp :: store array in vector |
Cpp :: ascii allowed in c++ |
Cpp :: how to extract a folder using python |
Cpp :: unordered_map c++ |
Cpp :: c++ class methods |
Cpp :: priority queue in cpp |
Cpp :: Shell-Sort C++ |
Cpp :: operator overloading c++ |