Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

ITP Assignment(Array Matrix)

Assignment on with practice task

Uploaded by

Abdul Rafay
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

ITP Assignment(Array Matrix)

Assignment on with practice task

Uploaded by

Abdul Rafay
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

(Example-3) Code:

#include<iostream>

using namespace std;

int main()

const int row = 10;

const int column = 10;

int matrix[row][column];

cout << "Enter values for matrix:\n";

for (int i = 0; i < row; i++)

for (int j = 0; j < column; j++)

cin >> matrix[i][j];

cout << "\nLeft-Diagonal elements:\n";

for (int i = 0; i < row; i++)

for (int j = 0; j < column; j++)

if (i == j)

cout << matrix[i][j] << endl;

return 0; }
Output:
(Example-4) Code:
#include<iostream>

using namespace std;

int main()

const int row = 3;

const int column = 3;

int matrix[row][column], count = 0;

cout << "Enter values for matrix:\n";

for (int i = 0; i < row; i++)

for (int j = 0; j < column; j++)

cin >> matrix[i][j];

for (int i = 0; i < row; i++)

for (int j = 0; j < column; j++)

if (matrix[i][j] == 0)

count++;

if (count == row * column)


cout << "The given matrix is a Zero matrix\n";

else

cout << "The given matrix is not a Zero matrix\n";

return 0;

Output:
(Example-5) Code:
#include<iostream>

using namespace std;

int main()

const int row = 4;

const int column = 4;

int matrix[row][column], sum;

cout << "Enter values for matrix:\n";

for (int i = 0; i < row; i++)

for (int j = 0; j < column; j++)

cin >> matrix[i][j];

for (int i = 0; i < column; i++)

sum = 0;

for (int j = 0; j < row; j++)

sum += matrix[j][i];

cout << "Sum of column " << i + 1 << " = " << sum << endl;

}
return 0;

Output:

You might also like