Ok the for loop out and it now displays all the elements but still cant get them in a nice matrix square, tried newling to get the effect but not with sucess, also now matrix A disply runs into the start of entering matrix B, can some1 suggest when i need to tell the printf to newline? thanks for all the help so far, its been brilliant, im learning more C here then i did in 10 weeks of course lectures !
so far:
Code:
#include <stdio.h>
#define MAX_R 4
#define MAX_C 4
#define MAX_C2 4
#define MAX_R2 4
int main()
{
int R = 0, C = 0, R2 = 0, C2 = 0;
int r_i = 0, c_i = 0, c2_i = 0, r2_i = 0;
int Matrix_A [MAX_R] [MAX_C];
int Matrix_B [MAX_R2] [MAX_C2];
int Matrix_C [MAX_R] [MAX_C2];
int x = 0, y = 0;
printf("This program will multiply 2 matrices (up to the order or 4x4),and display the result\n");
do {
printf("Enter the order of Matrix A in the format NxN:\n");
scanf ("%dx%d",&R ,&C);
if (R>4 || C>4)
{
printf("Order too great\n");
}
} while (R>4 || C>4);
do {
printf("\nFor row %d of Matrix A",r_i +1);
while(c_i < C) {
printf("\n\tEnter the value for column %d :",c_i +1);
scanf("%d",&Matrix_A [r_i] [c_i]);
++c_i;
}
c_i = 0;
++r_i;
}while (r_i < R);
for(x=0; x<R; x++){
for(y=0; y<C; y++)
{
printf("\t\n%3d",Matrix_A [x] [y]);
if ( (x == 0 && y == 0) || (x ==1 && y == 0))
printf("\n");
}
do {
printf("Enter the order of Matrix B in the format NxN:\n");
scanf ("%dx%d",&R2 ,&C2);
if (R2>4 || C2>4)
{
printf("Order tpp great\n");
}
}while (R2>4 || C2>4);
do {
printf("\nFor row %d of Matrix B",r2_i +1);
while(c2_i < C2) {
printf("\n\tEnter the value for column %d :",c2_i +1);
scanf("%d",&Matrix_B [r2_i] [c2_i]);
++c2_i;
}
c2_i = 0;
++r2_i;
}while (r2_i < R2);
for(x=0; x<R2; x++){
for(y=0; y<C2; y++)
{
printf("%3d",Matrix_B [x] [y]);
}
}
return (0);
}
}