Professional Documents
Culture Documents
#include <iostream.h>
#include<conio.h>
void main()
int i, j, c, r;
cin >> r ;
cin >> c;
cout << "enter elements a " << i+1 << j+1 << ":" ;
{
cout << "\n ";
cin >> c;
{
cout << "enter the elements b " << i+1 << j+1 << ":" ;
{
cout << "\n " ;
{
for (j=0; j<c; j++)
C[i][j]=A[i][j]+B[i][j];
}
for (i=0; i<r; i++)
{
cout << "\n " ;
for (j=0; j<c; j++)
{
int A[10][10], B[10][10], C[10][10];
int i, j, c, r;
cout << "enter the number of rows of matrix A :" ;
cin >> r ;
cin >> c;
{
cout << "enter elements a " << i+1 << j+1 << ":" ;
{
cout << "\n ";
cin >> r;
{
cout << "enter the elements b " << i+1 << j+1 << ":" ;
cin >> B[i][j];
{
cout << "\n " ;
{
for (j=0; j<c; j++)
C[i][j]=A[i][j]-B[i][j];
}
}
getch();
}
Output
enter the number of rows of matrix A :3
enter the number of columns of matrix A :3
enter the elements of matrix A
enter elements a 11:78
enter elements a 12:98
enter elements a 13:56
enter elements a 21:43
enter elements a 22:23
enter elements a 23:85
enter elements a 31:12
enter elements a 32:32
enter elements a 33:67
the entered matrix A is :
78 98 56
43 23 85
12 32 67
enter the rows of matrix B:3
enter the columns of matrix B :3
enter the elements of matrix B :
enter the elements b 11:11
enter the elements b 12:34
enter the elements b 13:23
enter the elements b 21:35
enter the elements b 22:9
enter the elements b 23:51
enter the elements b 31:3
enter the elements b 32:7
enter the elements b 33:37
{
int A[10][10],B[10][10], C[10][10];
int i,j, k;
cout << "enter the rows and columns of matrix A" << endl ;
cout << "enter the element a " << i+1 << j+1 << ":";
cout << "enter the rows and columns of matrix B" << endl ;
cout << "enter the element b " << i+1 << j+1 << ":";
C[i][j]=0;
cout << "the resultant matrix is " << endl;
{
C[i][j]=0;
C[i][j]=C[i][j]+A[i][k]*B[k][j];
getch();
}
Output
enter the rows and columns of matrix A
enter the element a 11:1
enter the element a 12:1
enter the element a 21:1
enter the element a 22:1
enter the rows and columns of matrix B
enter the element b 11:2
enter the element b 12:2
enter the element b 21:2
enter the element b 22:2
the resultant matrix is
4 4 4 4
Process returned 0 (0x0) execution time : 4.913 s
Press any key to continue.
Program to print coordinate of simple cube
#include<iostream.h>
#include<conio.h>
void main()
{
int i, j, k, n;
cout << "enter the number of atoms lying on any axis " ;
cin >> n;
cout << i << " " << j << " " << k << endl ;
}
getch();
}
Output-1
enter the number of atoms lying on any axis 1
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
Process returned 0 (0x0) execution time : 1.163 s
Press any key to continue.
Output-2
0 0 1
0 0 2
0 1 0
0 1 1
0 1 2
0 2 0
0 2 1
0 2 2
1 0 0
1 0 1
1 0 2
1 1 0
1 1 1
1 1 2
1 2 0
1 2 1
1 2 2
2 0 0
2 0 1
2 0 2
2 1 0
2 1 1
2 1 2
2 2 0
2 2 1
2 2 2
int i, j, k, n;
cout << "enter the number of atoms lying on any axis " ;
cin >> n;
cout << i << " " << j << " " << k << endl ;
cout << (i+i-1)*0.5 << " " << (j+j-1)*0.5 << " " << (k+k-1)*0.5 <<
endl;
}
getch();
}
Output-1
enter the number of atoms lying on any axis 1
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
0.5 0.5 0.5
#include<iostream.>
#include<conio.h>
void main()
int i, j, n;
cin >> n;
cout << (i+i-1 )*0.5 << " " << (j+j-1)*0.5 << endl;
getch();
}
Output
enter the number of atoms on any axis 2
0 0
0 1
0 2
1 0
1 1
0.5 0.5
1 2
0.5 1.5
2 0
2 1
1.5 0.5
2 2
1.5 1.5
#include<conio.h>;
void main()
int i, j, k, n;
cout << "enter the number of atoms lying on any axis " ;
cin >> n;
cout << i << " " << j << " " << k << endl ;
cout << i*0.5 << " " << (j+j-1)*0.5 << " " << (k+k-1)*0.5 <<
endl;
cout << (i+i-1)*0.5 << " " << j*0.5 << " " << (k+k-1)*0.5 <<
endl;
cout << (i+i-1)*0.5 << " " << (j+j-1)*0.5 << " " << k*0.5 << endl;
if (i>0 && j>0 && k>0)
cout << i << " " << (j+j-1)*0.5 << " " << (k+k-1)*0.5 << endl;
cout << (i+i-1)*0.5 << " " << j << " " << (k+k-1)*0.5 << endl;
cout << (i+i-1)*0.5 << " " << (j+j-1)*0.5 << " " << k << endl;
getch();
}
Output
enter the number of atoms lying on any axis 2
0 0 0
0 0 1
0 0 2
0 1 0
0 1 1
0 0.5 0.5
0 1 2
0 0.5 1.5
0 2 0
0 2 1
0 1.5 0.5
0 2 2
0 1.5 1.5
1 0 0
1 0 1
0.5 0 0.5
1 0 2
0.5 0 1.5
1 1 0
0.5 0.5 0
1 1 1
1 1 2
1 2 0
0.5 1.5 0
1 2 1
1 2 2
2 0 0
2 0 1
1.5 0 0.5
2 0 2
1.5 0 1.5
2 1 0
1.5 0.5 0
2 1 1
2 1 2
2 2 0
1.5 1.5 0
2 2 1
2 2 2
int A[10][10], i, j, r, c;
float determinant = 0;
cin >> r;
cin >> c;
cout<<"Enter elements of matrix A:\n";
cout << "enter the elements a" << i+1 << j+1 << ":" ;
cin>>A[i][j];
}
cout << "\nGiven matrix is:";
cout<<"\n";
for(j = 0; j < 3; j++)
cout<<A[i][j]<<"\t";
cout<<((A[(j+1)%3][(i+1)%3] * A[(j+2)%3][(i+2)%3]) -
(A[(j+1)%3][(i+2)%3] * A[(j+2)%3][(i+1)%3]))/ determinant<<"\t";
cout<<"\n";
}
getch();
}
Output:
enter the row of matrix A: 3
enter the columns of matrix A:4
Enter elements of matrix A:
enter the elements a11:1
enter the elements a12:2
enter the elements a13:3
enter the elements a21:4
enter the elements a22:5
enter the elements a23:6
enter the elements a31:7
enter the elements a32:8
enter the elements a33:0
determinant: 27
cout << "Enter elements a" << i + 1 << j + 1 << ": ";
}
cout << endl << "Entered Matrix: " << endl;
if(j == c - 1)
trans[j][i]=a[i][j];
}
cout << endl << "Transpose of Matrix: " << endl;
if(j == r - 1)
}
getch();
}
Output
Enter rows and columns of matrix: 3
3
Enter elements of matrix:
Enter elements a11: 1
Enter elements a12: 2
Enter elements a13: 3
Enter elements a21: 4
Enter elements a22: 5
Enter elements a23: 6
Enter elements a31: 7
Enter elements a32: 8
Enter elements a33: 9
Entered Matrix:
123
456
789
Transpose of Matrix:
147
258
369