Today we have discussed about Google Classroom. I request you all the students of
TY Mechanical A and B division to join Class invitation which I have sent to your official email address.
Dear all TY Mechanical Engineering Students,
Welcome to Google Class Room.
This class room will help us to connect with each other.
With this class room you can submit me your programs.
Let's use Google Classroom.
This is new way of submitting responses.
Definitely it will help us to learn CPP together.
CPP program to understand Square Magic 4X4 Matrix.
Through this we understood use of 2D arrya.
/*
Square Magic
4X4 Matrix
*/
#include<iostream.h>
#include<conio.h>
class magic;
class magic
{
private:
int no;
int a[4][4]; //2D array
public:
void enterip()
{
cout<<"\n Please enter number from 22 to 99=";
cin>>no;
if(no>=22&&no<=99)
{
a[0][0]=no-20;
a[0][1]=1;
a[0][2]=12;
a[0][3]= 7;
a[1][0]= 11;
a[1][1]= 8;
//a[1][2]= a[0][0]-1;
a[1][2]= no-21;
a[1][3]= 2;
a[2][0]= 5;
a[2][1]= 10;
a[2][2]= 3;
a[3][0]=4;
//a[3][1]=a[0][0]+1;
a[3][1]=no-19;
//a[2][3]= a[3][1]+1;
a[2][3]= no-18;
a[3][2]=6;
a[3][3]=9;
cout<<"\n\n\n Square Matrix:\n";
displaymatrix(); //calling of udf
}
else
{
cout<<"\n Sorry !! Square matrix will not be displayed";
cout<<"\n Your input is not from 22 to 99!!";
}
}
void displaymatrix()
{
int i,j;
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
cout<<"\t"<<a[i][j];
}
cout<<"\n";
}
}
};
void main()
{
clrscr();
magic sm;
sm.enterip();
getch();
}
It's was so important to me to learning languages 👌👌
ReplyDeleteThank you to Gorkshanath Shejal. For any issues please post such comment on my blogs. This will give me energy to work more.
Delete