You are on page 1of 7

Programm

ing
CS 102
Project from

Submitted by:
Rosny Angelo Lanuza
Mark Nartea
Kurt Macapagal
Bernie A. Baltazar

Submitted to:

Julius Punay

Cathie De Salit
Dumpit

//Program Using 2D arrays that Computes the Sum of Rows and Column
#include<iostream>
#include <ctype.h>
using namespace std;
int main()
{
int arr[50][50],column[50]={0},row[50]={0};
int sizec,sizer,total,Number=0,typeC;
cout<<"\t"<<"\t"<<"(Program that Computes the Sum of Rows and Column)\n";
cout<<"\nHow many Rows you want: ";
cin>>sizer;
cout<<"\nHow many Column you want: ";
cin>>sizec;
//Link Start
total=sizer*sizec;// total of Number input
cout<<"Please Enter "<<total<<" Number\n";
for(int r=0;r<sizer;r++)
{
for(int c=0;c<sizec;c++)
{
cout<<"\nEnter Number "<<++Number<<":"; // Storing the Num into Array
cin>>arr[r][c];
}
}
//-----Looping of Rows
for(int r=0;r<sizer;r++)
{
for(int c=0;c<sizec;c++)
{
row[r]=row[r]+arr[r][c]; //Getting the sum of Rows
}
}
//----Display the all value of Array
for(int r=0;r<sizer;r++)
{
cout<<"\t"<<"\t";
for(int c=0;c<sizec;c++)
{
cout<<"\t"<<arr[r][c];
}
cout<<"\t"<<"="<<" "<<row[r]<<"\n";
}
//----Looping in Column

for(int r=0;r<sizer;r++)
{
for(int c=0;c<sizec;c++)
{
column[c]=column[c]+arr[r][c]; //Getting the sum of Row
}
}
//----Displaying of line
cout<<"\t"<<"\t"<<"\t";
for(int c=0;c<sizec;c++){
cout<<"_______";
}
//-------------------------------------cout<<"\n";
cout<<"\t"<<"\t";
//-------------------------------------for(int c=0;c<sizec;c++)
{
cout<<"\t"<<column[c]<<"\n\n";
}
}

// Program that compute Sum of Row or a Column

#include<iostream>
using namespace std;
int main()
{
char type,typeC;
int arr[40],column=0,rows=0;
int day,sizer,sizec;
cout<<"\t"<<"\t"<<"(Program that compute Sum of Row or a Column)\n\n";
cout<<"Type R for Rows Or Type C for Column\n\n";
LOOP: //------Loop to start agian
cout<<"\nPlease type R or C:";
cin>>type;
if(type=='R'||type=='r')
{
//-------links start to rows
day=0;
rows=0;
cout<<"How many Rows You want:";
cin>>sizer;
cout<<"\nPlease Enter a "<<sizer<<" Number\n";
//Entering number for Rows
for(int r=0;r<sizer;r++)
{
cout<<"Enter a Number "<<++day<<":";
cin>>arr[r];
}
//-----Getting Sum of Rows
for(int r=0;r<sizer;r++)
{
rows=rows+arr[r];
}
for(int r=0;r<sizer;r++)
{
cout<<"\t"<<arr[r];
}
cout<<"\t"<<"="<<" "<<rows;
Con:
cout<<"\n\n\n\nAre you want to Continue (y) or (n):";
cin>>typeC;
if(typeC=='Y'||typeC=='y')
{
goto LOOP; //-----Go to LOOP to start agian
}else{
cout<<"Program Exit";

return (0); //-----Exit the program


}
}
if((type=='C')||(type=='c'))
{
//-----Link start to Column
day=0;
column=0;
cout<<"How many Column You want:";
cin>>sizec;
cout<<"\nPlease Enter a "<<sizec<<" Number\n";
for(int c=0;c<sizec;c++)
{
cout<<"Enter a Number "<<++day<<":";
cin>>arr[c];
}
//--------Looping for Column
for(int c=0;c<sizec;c++)
{
column+=arr[c]; //Getting the sum of Row
}
//--------Getting the sum of Column
for(int c=0;c<sizec;c++)
{
cout<<"\t"<<"\t"<<arr[c]<<"\n";
}
cout<<"\t"<<"\t"<<"____\n";
cout<<"\t"<<"\t"<<column;
goto Con;
}else{ //----- for wrong key words
cout<<"Invalid Key\n";
cout<<"\nProgram Force Close";
return (0);
}
goto LOOP;
}

You might also like