Professional Documents
Culture Documents
Oop Assign 1
Oop Assign 1
Oop Assign 1
1.
#include<bits/stdc++.h>
int r, int c)
// swapping of elements
}
// Driver code
int main()
{7, 3, 0},
Op: 7 8 9
037
136
#include<stdio.h>
int main()
scanf("%d", &a[rows][columns]);
return 0;
Op:
10 20 30
40 50 60
70 80 90
4.
/* C++ program to transpose of a given matrix*/
#include <iostream>
int main()
int temp;
for(int j=0;j<3;j++)
cout<<matrix[i][j]<<"\t";
cout<<endl;
cout<<endl;
matrix[i][j]=matrix[j][i];
matrix[j][i]=temp;
for(int j=0;j<3;j++)
cout<<matrix[i][j]<<"\t";
cout<<endl;
return 0;
Op:
43 23 55
65 76 32
33 51 22
43 65 33
23 76 51
55 32 22
5.
#include <stdio.h>
int main()
/*
scanf("%d", &A[row][col]);
/*
*/
scanf("%d", &B[row][col]);
/*
*/
sum = 0;
/*
*/
}
C[row][col] = sum;
/*
*/
printf("\n");
return 0;
Op:
123
456
789
321
654
987
Product of Matrix A * B =
42 36 30
96 81 66
6.
Program to Add Two Matrices
#include <stdio.h>
int main()
scanf("%d", &rowCount);
scanf("%d", &columnCount);
scanf("%d", &firstMatrix[i][j]);
scanf("%d", &secondMatrix[i][j]);
printf("%d\t",resultMatrix[i][j]);
printf("\n");
}
return 0;
Op:
123
456
789
321
654
987
4 4 4
10 10 10
16 16 16
7.