0% found this document useful (0 votes)
27 views3 pages

Task 01: #Include Int Int For For

Task 01 contains code to input values into a 4x4 array and then output the values. Task 02 contains code to input values into two 3x3 arrays, add the corresponding elements, and output the summed array. Task 03 contains code to input values into a 3x3 array, define a function to calculate the transpose of the array, and output the transposed array. Task 04 contains code to input values into two 2x2 arrays, calculate the matrix multiplication of the arrays using a nested for loop, and output the product array.

Uploaded by

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

Task 01: #Include Int Int For For

Task 01 contains code to input values into a 4x4 array and then output the values. Task 02 contains code to input values into two 3x3 arrays, add the corresponding elements, and output the summed array. Task 03 contains code to input values into a 3x3 array, define a function to calculate the transpose of the array, and output the transposed array. Task 04 contains code to input values into two 2x2 arrays, calculate the matrix multiplication of the arrays using a nested for loop, and output the product array.

Uploaded by

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

Task 01:

#include<stdio.h>
int main()
{
int a[4][4],i,j;
printf("enter the value=\n");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
scanf("%d\n", &a[i][j]);
}
printf("\n");

}
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
printf("%d ", a[i][j]);
}
printf("\n");
}
}

Task 02:

#include<stdio.h>
int main()
{
int a[3][3],b[3][3],sum[3][3];
int i,j;

printf("enter the value matrix 1=\n");


for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d", &a[i][j]);
}
}
printf("enter the value matrix 2=\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d", &b[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
sum[i][j]=a[i][j]+b[i][j];
}
}
printf("now add the matrices=\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d ",sum[i][j]);
}
printf("\n");
}

Task 03:

#include<stdio.h>
void functionmatrix(int a[3][3],int transpose[3][3]);
int main()
{
int x[3][3],y[3][3];
int i,j;
printf("enter the number in x=\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d ",&x[i][j]);
}
}

functionmatrix(x,y);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d ",y[i][j]);
}
printf("\n");
}
}
void functionmatrix(int a[3][3],int transpose[3][3])
{
int i,j;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
transpose[i][j]=a[j][i];
}

}
}

Task 04:

#include<stdio.h>
int main()
{
int x[2][2],y[2][2],mul[2][2];
int i,j,k;
int sum=0;

printf("enter the numbers in x=\n");


for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d ", &x[i][j]);
}
}
printf("enter the numbers in y=\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d ",&y[i][j]);
}
}

for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
sum =0;
for(k=0;k<2;k++)
{
sum=sum+x[i][k]*y[k][j];
}
mul[i][j]=sum;
printf("%d ",mul[i][j]);

}
printf("\n");
}
}

You might also like