Showing posts with label Matrix. Show all posts
Showing posts with label Matrix. Show all posts

WAP to find transport of of given 3x3 matrix

/*WAP to find transport of of given 3x3 matrix*/
#include<stdio.h>
#include<conio.h>
void main()
{
	int a[3][3],i,j;
	clrscr();
	printf("Enter Elements for A Matrix:");
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			printf("\n\nElements[%d][%d]:",i,j);
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			printf("%d\t",a[i][j]);
		}
		printf("\n");
	}
	printf("\nTranspose of Matrix:\n");
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			printf("%d\t",a[j][i]);
		}
		printf("\n");
	}
	getch();
}

WAP to find multioplication of given two matrix from user


#include<stdio.h>
#include<conio.h>

main()
{
	int i,j,k,a[3][3],b[3][3],c[3][3];
	clrscr();

	printf("\n\nA:\n");
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			scanf("%d",&a[i][j]);
			c[i][j]=0;
		}
	}

	printf("\n\nB:\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++)
		{
			for (k = 0; k < 3; k++)
			{
				c[i][j] += a[i][k] * b[k][j];
	        	}
	    	}	
	}

	printf("\n\nAns:\n");
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
			printf("%d\t",c[i][j]);
		printf("\n");
	}

	getch();
}

WAP to get input 2D MATRIX from user and print them on output screen

#include<stdio.h>
#include<conio.h>

void main()
{
    int i,j;
    int a[3][3];
    int b[3][3];

    clrscr();
    printf("Enter values for a:--\n");
    for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		   {
		   scanf("%d",&a[i][j]);
		   }
	}

    printf("Enter values for b:--\n");
    for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		   {
		   scanf("%d",&b[i][j]);
		   }
	}

clrscr();
printf("\nvalue of matrix a\n");
    for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		   {
		   printf("\t%d",a[i][j]);
		   }
		   printf("\n");
	}

printf("\nValue of matrix b \n");
 printf("Enter values for a:--\n");
    for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		   {
		   printf("\t%d",b[i][j]);
		   }
		   printf("\n");
	}



    getch();

}