0% found this document useful (0 votes)
62 views

Matrix 1 PDF

The document describes two C programs to perform matrix operations. The first program sums two 3x3 matrices by taking input for each matrix, initializing a third matrix, and setting each element of the third matrix to the sum of the corresponding elements of the first two matrices. The second program performs the same process but subtracts the elements instead of adding them to calculate the subtraction of two matrices.

Uploaded by

shayan sohail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Matrix 1 PDF

The document describes two C programs to perform matrix operations. The first program sums two 3x3 matrices by taking input for each matrix, initializing a third matrix, and setting each element of the third matrix to the sum of the corresponding elements of the first two matrices. The second program performs the same process but subtracts the elements instead of adding them to calculate the subtraction of two matrices.

Uploaded by

shayan sohail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

PROGRAMME NO.

1
PROGRAMME TO FIND OUT THE SUM OF TWO GIVEN
MATRICES
IN PSEUDO LANGAUGE:-

Input:2 matrices a[3][3],b[3][3]

For(i=02)

For(j=02)

Input: a[i][j]

For(i=02)

For(j=02)

Input:b[i][j]

For(i=02)

For(j=02)

Output:sum of matrices=a[i][j]+b[i][j]
}

IN C-LANGUAGE:-

#include<stdio.h>

#include<conio.h>

void main()

clrscr();

int a[3][3],b[3][3],c[3][3],i,j;

printf("To find the sum of two given matrices of order 3\n");

printf("Enter the matrix A\n");

for(i=0;i<=2;i=i+1)

for(j=0;j<=2;j=j+1)

printf("a[%d][%d]=",i+1,j+1);

scanf("%d",&a[i][j]);

printf("Enter the matrix B\n");

for(i=0;i<=2;i=i+1)

for(j=0;j<=2;j=j+1)

printf("b[%d][%d]=",i+1,j+1);
scanf("%d",&b[i][j]);

printf("sum of matrices A and B given\n");

for(i=0;i<=2;i=i+1)

for(j=0;j<=2;j=j+1)

c[i][j]=a[i][j]+b[i][j];

printf("c[%d][%d]=%d\t",i+1,j+1,c[i][j]);

getch();

}
Output Image:-

PROGRAMME NO.2
PROGRAMME TO FINDOUT THE SUBTRACTION OF TWO
GIVEN MATRICES
IN PSEUDO LANGUAGE:-

Input:2 matrices a[3][3],b[3][3]

For(i=02)

For(j=02)

Input: a[i][j]

}
}

For(i=02)

For(j=02)

Input:b[i][j]

For(i=02)

For(j=02)

Output:subtraction of matrices=a[i][j]-b[i][j]

IN C-LANGUAGE:-

#include<stdio.h>

#include<conio.h>

void main()

clrscr();

int a[3][3],b[3][3],c[3][3],i,j;

printf("To find the subtraction of two given matrices of order


3\n");

printf("Enter the matrix A\n");


for(i=0;i<=2;i=i+1)

for(j=0;j<=2;j=j+1)

printf("a[%d][%d]=",i+1,j+1);

scanf("%d",&a[i][j]);

printf("Enter the matrix B\n");

for(i=0;i<=2;i=i+1)

for(j=0;j<=2;j=j+1)

printf("b[%d][%d]=",i+1,j+1);

scanf("%d",&b[i][j]);

printf("subtraction of matrices A and B given\n");

for(i=0;i<=2;i=i+1)

for(j=0;j<=2;j=j+1)

c[i][j]=a[i][j]-b[i][j];

printf("c[%d][%d]=%d\t",i+1,j+1,c[i][j]);

getch();
}

Output Image:

You might also like