Thanks for your reply! I shall look at the fgets code and change everything accordingly. I removed the getchar(); line and it seems to restart the program back to the beginning, however it is skipping out the request for matrix A's rows...

Here is the code:

Code:

#include <stdio.h>
#include <math.h>
/* Function Prototype: Enter Matrix Data */
int Matrix_Data(int a[4][4],int x,int y)
{
int i,j;
char vld[80], c;
char ch;
int chk;
for(i=0;i<x;i++)
for(j=0;j<y;j++)
do {
printf (" Enter data integer, PRESS ENTER: ");
gets(vld);
chk = sscanf(vld, "%d",&a[i][j]);
if (chk != 1)
{ printf ("\n ERROR; You have entered a character. Please Enter a number!\n"); }
else
if (a[i][j] < 0 || a[i][j] > 99)
{ printf ("\n You have entered a number out of range.\n Please re-enter!\n"); }
} while (a[i][j] < 0 || a[i][j] > 99);
return (0);
}
/* Function Prototype: Display Matrix Data */
int Display_Matrix(int a[4][4],int x,int y)
{
int i,j;
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
printf("%16d",a[i][j]);
printf("\n\n");
}
return (0);
}
int main(void)
{
int i,j, RowA, ColA, RowB, ColB, k;
int MXA[4][4], MXB[4][4], MLT[4][4];
char vld[80], c;
int chk;
/* Introduction */
printf(" Matrix Multiplier\n");
printf(" _________________\n");
printf("\n Welcome to the Matrix Multiplier. This program is designed to output \n the result of multiplying two, 4 X 4 matrices.\n");
printf("\n_______________________________________________________________________________\n");
/* End Introduction */
do {
/*Matrix A*/
printf("\n Create Size of Matrix A [MAX 4 X 4 Matrix]:\n");
do {
printf("\n Number of Rows [R] = ");
gets(vld);
chk = sscanf(vld, "%d",&RowA);
if (chk != 1)
{ printf ("\n ERROR; You have entered a character. Please Enter a number!\n"); }
else
if (RowA < 0 || RowA > 4)
{ printf ("\n You have entered a number out of range.\n Please re-enter!\n"); }
} while (RowA < 0 || RowA > 4);
do {
printf("\n Number of Columns [C] = ");
gets(vld);
chk = sscanf(vld, "%d",&ColA);
if (chk != 1)
{ printf ("\n ERROR; You have entered a character. Please Enter a number!\n"); }
else
if (ColA < 0 || ColA > 4)
{ printf ("\n You have entered a number out of range.\n Please re-enter!\n"); }
} while (ColA < 0 || ColA > 4);
/* End Matrix A */
/* Matrix B */
printf("\n Create Size of Matrix B [MAX 4 X 4 Matrix]:\n");
do {
printf("\n Number of Rows [R] = ");
gets(vld);
chk = sscanf(vld, "%d",&RowB);
if (chk != 1)
{ printf ("\n ERROR; You have entered a character. Please Enter a number!\n"); }
else
if (RowB < 0 || RowB > 4)
{ printf ("\n You have entered a number out of range.\n Please re-enter!\n"); }
} while (RowB < 0 || RowB > 4);
do {
printf("\n Number of Columns [C] = ");
gets(vld);
chk = sscanf(vld, "%d",&ColB);
if (chk != 1)
{ printf ("\n ERROR; You have entered a character. Please Enter a number!\n"); }
else
if (ColB < 0 || ColB > 4)
{ printf ("\n You have entered a number out of range.\n Please re-enter!\n"); }
} while (ColB < 0 || ColB > 4);
/* End Matrix B */
printf("\n_______________________________________________________________________________\n");
/* Enter Data for both Matrices */
if (RowB == ColA)
{
printf("\n DATA for Matrix A\n\n");
Matrix_Data(MXA, RowA, ColA); //Call Matrix_Data Prototype for Matrix A
printf("\n The structure of Matrix A is as follows: \n\n");
for (i=0;i<RowA;i++)
{
for(j=0;j<ColA;j++)
printf(" %d\t",MXA[i][j]);
printf("\n\n");
}
printf("\n DATA for Matrix B\n\n");
Matrix_Data(MXB, RowB, ColB); //Call Matrix_Data Prototype for Matrix B
printf("\n The structure of Matrix B is as follows: \n\n");
for (i=0;i<RowB;i++)
{
for(j=0;j<ColB;j++)
printf(" %d\t",MXB[i][j]);
printf("\n\n");
}
/* End Enter Data for both Matrices */
printf("\n_______________________________________________________________________________\n");
/* Multiplication of Matrix A and Matrix B */
for(i=0;i<RowA;++i)
for(j=0;j<ColB;++j)
{
MLT[i][j]=0;
for(k=0;k<ColA;++k)
MLT[i][j] += MXA[i][k]*MXB[k][j];
}
printf("\n The result of multiplying Matrix A and Matrix B is as follows: \n\n");
Display_Matrix(MLT, RowA, ColB); //Call Display_Matrix Prototype
}
else
{
printf("\n The Size of Matrices you have chosen cannot be multiplied.\n Please check again.\n\n");
}
printf("\n_______________________________________________________________________________\n");
/* End Program */
printf("\nWould you like to restart the program? (y = Yes, n = No): \n");
c = getchar();
printf("\n_______________________________________________________________________________\n");
} while ((c == 'y' || c == 'Y'));
//system ("PAUSE");
return (0);
}

Why is it skipping out the request for matrix A's rows when I hit yes to restarting the program?

Thank you!