#include<iostream.h>
#include<conio.h>
class game
{
private:
int arr[3][3];
int i,j;
public:
void input()
{
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{cout<<"array["<<i<<"]["<<j<<"]"<<"\t";
cin>>arr[i][j];}
}
void output()
{
cout<<"\n\n\n";
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
cout<<arr[i][j]<<"\t";
cout<<endl<<endl;}
cout<<"\n";
}
void sum()
{
cout<<"\n\n";
cout<<"sum of 1st row "<<"\t"<<(arr[0][0]+arr[0][1]+arr[0][2])<<endl;
cout<<"sum of 2nd row "<<"\t"<<(arr[1][0]+arr[1][1]+arr[1][2])<<endl;
cout<<"sum of 3rd row "<<"\t"<<(arr[2][0]+arr[2][1]+arr[2][2])<<endl;
cout<<"sum of 1st col "<<"\t"<<(arr[0][0]+arr[1][0]+arr[2][0])<<endl;
cout<<"sum of 2nd col "<<"\t"<<(arr[0][1]+arr[1][1]+arr[2][1])<<endl;
cout<<"sum of 3rd col "<<"\t"<<(arr[0][2]+arr[1][2]+arr[2][2])<<endl;
cout<<"sum of 1st diagonal"<<"\t"<<(arr[0][0]+arr[1][1]+arr[2][2])<<endl;
cout<<"sum of 2nd diagonal"<<"\t"<<(arr[0][2]+arr[1][1]+arr[2][0])<<endl;
}
void numbers()
{
cout<<"\nthe nos you have to enter are\n";
cout<<"6 1 8"<<endl;
cout<<"7 5 3"<<endl;
cout<<"2 9 4"<<endl<<endl;
}
~game()
{
cout<<"\n\nobject destroyed";
}
};
void main()
{
game g;
g.numbers();
g.input();
g.output();
g.sum();
getch();
}
#include<conio.h>
class game
{
private:
int arr[3][3];
int i,j;
public:
void input()
{
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{cout<<"array["<<i<<"]["<<j<<"]"<<"\t";
cin>>arr[i][j];}
}
void output()
{
cout<<"\n\n\n";
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
cout<<arr[i][j]<<"\t";
cout<<endl<<endl;}
cout<<"\n";
}
void sum()
{
cout<<"\n\n";
cout<<"sum of 1st row "<<"\t"<<(arr[0][0]+arr[0][1]+arr[0][2])<<endl;
cout<<"sum of 2nd row "<<"\t"<<(arr[1][0]+arr[1][1]+arr[1][2])<<endl;
cout<<"sum of 3rd row "<<"\t"<<(arr[2][0]+arr[2][1]+arr[2][2])<<endl;
cout<<"sum of 1st col "<<"\t"<<(arr[0][0]+arr[1][0]+arr[2][0])<<endl;
cout<<"sum of 2nd col "<<"\t"<<(arr[0][1]+arr[1][1]+arr[2][1])<<endl;
cout<<"sum of 3rd col "<<"\t"<<(arr[0][2]+arr[1][2]+arr[2][2])<<endl;
cout<<"sum of 1st diagonal"<<"\t"<<(arr[0][0]+arr[1][1]+arr[2][2])<<endl;
cout<<"sum of 2nd diagonal"<<"\t"<<(arr[0][2]+arr[1][1]+arr[2][0])<<endl;
}
void numbers()
{
cout<<"\nthe nos you have to enter are\n";
cout<<"6 1 8"<<endl;
cout<<"7 5 3"<<endl;
cout<<"2 9 4"<<endl<<endl;
}
~game()
{
cout<<"\n\nobject destroyed";
}
};
void main()
{
game g;
g.numbers();
g.input();
g.output();
g.sum();
getch();
}
0 comments:
Post a Comment