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

typedef struct
{
	int M[40][40];
	int br;
	int kl;
}mtrks;

void entri (mtrks *A, mtrks *B);
//void entrinilai(mtrks *A, mtrks *B);
void entrinilai(mtrks *A,mtrks *B);

void tampil(mtrks A, mtrks B);
//void tampil(Matriks M);

void pilih(mtrks *A, mtrks *B, mtrks *C);
int add(mtrks A, mtrks B, mtrks *C);
void transposeSquareMatrix(mtrks *C, int br, int kl);



int main()
{
	
	int br,kl;
	mtrks A,B,C;

	entri(&A,&B);
	entrinilai(&A,&B);
//	entrinilai(&B);
  tampil(A,B);
	getch();
	pilih(&A,&B,&C);
	getch();
	return 0;


}





int pil;

void entri(mtrks *A, mtrks *B)
{



	do{
	printf("Masukkan jumlah baris matriks A : ");
	scanf("%d",&(*A).br);
	printf("Masukkan jumlah kolom matriks A :");
	scanf("%d",&(*A).kl);
	if((((*A).br)*((*A).kl))>41 )
	{
		printf("Maaf, jumlah maksimal elemen adalah 40\n\n");
	}
	}while((((*A).br)*((*A).kl))>41);

	do{
	printf("Masukkan jumlah baris matriks B : ");
	scanf("%d",&(*B).br);
	printf("Masukkan jumlah kolom matriks B :");
	scanf("%d",&(*B).kl);
	if((((*B).br)*((*B).kl))>41 )
	{
		printf("Maaf, jumlah maksimal elemen adalah 40\n\n");
	}
	}while((((*B).br)*((*B).kl))>41);

}




void entrinilai(mtrks *A, mtrks *B)
{
	int br,kl;
	printf("\n\n\nMatriks A : \n");
	for(br=0;br<(*A).br;br++)
	{
		for(kl=0;kl<(*A).kl;kl++)
		{
			printf("Masukkan nilai baris ke %d kolom ke %d : ",br+1,kl+1);
			scanf("%d",&(*A).M[br][kl]);
			
		}
	}


	printf("\n\n");

		printf("Matriks B :\n");
		for(br=0;br<(*B).br;br++)
	{
		for(kl=0;kl<(*B).kl;kl++)
		{
			printf("Masukkan nilai baris ke %d kolom ke %d : ",br+1,kl+1);
			scanf("%d",&(*B).M[br][kl]);
			
		}
	}
}



void tampil(mtrks A, mtrks B)
{
	int br,kl;
	printf("\n\nMatriks A = \n");
	for(br=0;br<A.br;br++)
	{
		for(kl=0;kl<A.kl;kl++)
		{
		
			printf("%d\t",A.M[br][kl]);
			
		}
		printf("\n");
	}


	printf("\n\n");
	printf("Matriks B =\n");
		
		for(br=0;br<B.br;br++)
		{
		for(kl=0;kl<B.kl;kl++)
		{
			
			printf("%d\t",B.M[br][kl]);
			
		}
		printf("\n");
	}

}


int add(mtrks A, mtrks B, mtrks *C)
{
	int br,kl;
	if(A.br==B.br&&A.kl==B.kl)
	{
		for(br=0;br<A.br;br++)
			for(kl=0;kl<A.kl;kl++)
				{
					(*C).M[br][kl]=A.M[br][kl]+B.M[br][kl];
				}
		
	}
	else
		printf("Operasi penjumlahan tidak dapat dilakukan\n");
				
}


void pilih(mtrks *A, mtrks *B, mtrks *C)
{
	int pil;
	int br,kl;
	do{
		system("CLS");
		printf("\n************MENU OPERASI MATEMATIKA***********\n");
		printf("1. Penjumlahan\n");
		printf("2. Pengurangan\n");
		printf("3. Perkalian\n");
		printf("4. Transpose\n");
		printf("5. Lihat tampilan matriks\n");
		printf("0. Keluar\n");
		printf("Masukkan pilihan Anda :");
		scanf("%d",&pil);
		switch(pil)
	
	{
	case 1 :
		{
			//printf("Total penjumlahan adalah : %d\n");
				if((*A).br==(*B).br&&(*A).kl==(*B).kl)
				{
					printf("Matriks C=\n");
					for(br=0;br<(*A).br;br++)
					{
						for(kl=0;kl<(*A).kl;kl++)
						{
							(*C).M[br][kl]=(*A).M[br][kl]+(*B).M[br][kl];
							printf("%d\t",(*C).M[br][kl]);
						}
						printf("\n");
					}
				}
				else
					printf("tidak dapat menjalankan operasi penjumlahan ordo tidak sama");
	
			
		getch();
		break;
		}
	case 2 :
		if((*A).br==(*B).br&&(*A).kl==(*B).kl)
				{
					printf("Matriks C=\n");
					for(br=0;br<(*A).br;br++)
					{
						for(kl=0;kl<(*A).kl;kl++)
						{
							(*C).M[br][kl]=(*A).M[br][kl]-(*B).M[br][kl];
							printf("%d\t",(*C).M[br][kl]);
						}
						printf("\n");
					}
				}
				else
					printf("tidak dapat menjalankan operasi penjumlahan ordo tidak sama");
	
			
		getch();
		break;

	case 3 :
		{
			int br,kl,k;
			for(br=0;br<(*B).br;br++)
			{
				for(kl=0;kl<(*B).kl;kl++)
				{
                  (*C).M[br][kl]=0;
					for(k=0;k<(*B).kl;k++)
                {
						(*C).M[br][kl]=(*C).M[br][kl]+(*A).M[br][k]*(*B).M[k][kl];
                    }
					printf("%d\t",(*C).M[br][kl]);
				}
				printf("\n");
			}
		}
		getch();
		break;
		
		case 4 :
        //    void transposeSquareMatrix(mtrks *C, int br, int kl)
{
	int i,j;
	if(br == kl){
		for(i=0;i<br;i++)
        {
                         
			for(j=0;j<kl;j++)
            {
				int temp=(*C).M[i][j];
				(*C).M[i][j]=(*C).M[j][i];
				(*C).M[j][i]=temp;
				printf("%d\t",(*C).M[br][kl]);
			}
		}printf("\n");
	}
	else {
		printf("Error transposing matrix, not square matrix");
		exit(0);
	}
}
getch();
break;


	case 5 :
		{
			int br,kl;
			printf("\n\nMatriks A = \n");
			for(br=0;br<(*A).br;br++)
			{
				for(kl=0;kl<(*A).kl;kl++)
				{
					printf("%d\t",(*A).M[br][kl]);
				}
				printf("\n");
			}


			printf("\n\n");
			printf("Matriks B =\n");
		
			for(br=0;br<(*B).br;br++)
				{
					for(kl=0;kl<(*B).kl;kl++)
					{
						printf("%d\t",(*B).M[br][kl]);
					}
				printf("\n");
				}

			getch();break;
		}
	case 0 :
		{
			printf(" ");
			break;
		}
	default :
			printf("Masukkan angka 0-5 saja.\n");
			getch(); break;
		
	}
		
		
	}while(pil!=0);
	
}

Do you have a reason for posting all that code ???

Hi,

I'm new to the IT world and was wondering what the code is for? Is it a game or a pic. or what?

who knows? and more importanly, who cares?

the OP didn't bother describing anything, so i'm not going to bother trying cipher out the code. Or trying to read his mind.

the fact that he uses <conio.h> does tells me it's probably a broken, unportable mess, and I just stopped looking at it right there.

I'd suggest the OP compile the code then run it to see what it does.

What I guess is that the name "my code" is not a very appropriate name for this thread, because the OP probably didn't even write this code himself.
But who knows? Only the OP, right?
But if he just drops down his code on forum, without any comments, then he's just begging for replies like this one.
If he did, then I strongly suggest him to read the following guide, whatever error or bug there is in his code, this will help to prevent nearly any of them: http://cboard.cprogramming.com/c-programming/88495-development-process.html (follow these guidelines when designing/creating/writing a new program).
I also want to suggest the OP to read this: How to ask questions the smart way.

commented: Excellence! +36
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.