You are on page 1of 5

A Project

Program
ming
In
CS 103
Rosny Angelo M.
Lanuza
Kurt Jayson
SUBMITTED BY
Macapagal
Julius Z. Punay
Mark Nartea
Bernie A. Baltazar

SUBMITTED TO
Cathie De Salit Dumpit

//Program Using 2D arrays that Computes the Sum of Rows


and Column
#include<iostream>
using namespace std;
int main()
{
int arr[50][50],column[50]={0},row[50]={0};
int sizec,sizer,rc,total,Number=0;
cout<<"How many Column you want: ";
cin>>sizec;
cout<<"How many Rows you want: ";
cin>>sizer;
//Link Start
total=sizec*sizer;// total of Number input
cout<<"Please Enter "<<total<<" Number";
for(int c=0;c<sizec;c++)
{
for(int r=0;r<sizer;r++)
{
cout<<"\nEnter Number "<<++Number<<":"; //
Storing the Num into Array
cin>>arr[c][r];
}
}
//-----Looping of Column
for(int c=0;c<sizec;c++)
{
for(int r=0;r<sizer;r++)
{

column[c]=column[c]+arr[c][r]; //Getting the sum of


Column
}
}
//----Display the all value of Array
for(int c=0;c<sizec;c++)
{
for(int r=0;r<sizer;r++)
{
cout<<"\t"<<arr[c][r];
}
cout<<"\t"<<"="<<" "<<column[c]<<"\n";
}
//----Looping in Rows
for(int c=0;c<sizec;c++)
{
for(int r=0;r<sizer;r++)
{
row[r]=row[r]+arr[c][r]; //Getting the sum of Row
}
}
//----Displaying of line
cout<<"
";
for(int r=0;r<sizer;r++){
cout<<"_______";
}
cout<<"\n";
for(int r=0;r<sizer;r++)
{
cout<<"\t"<<row[r];
}
}

You might also like