At the end of code

Pravesh KunwarPravesh Kunwar badarpur new delhi

include

include<conio.h>

include <stdlib.h>

include <time.h>

using namespace std;

int order;

int q=0;
int w=0;
long r=0;
char e=' ';

int Matrices;

int main()
{
input:
cout<<"\n\tEnter The Size of Matrix: ";

cin>>order;
cout<<"\n\nEnter Number of Matrices to be Multiplied (More than and less than 10) ";

cin>>Matrices;
if(Matrices>10||Matrices<1)
{
system("cls");
cout<<"\n\n\n\n\t\t\t\t!Wrong Input Please Try Again \n\tNumber Of Matrices are more or less than the Expected Input\n\t\t\tEnter To Continue..";
getch();
goto input;
}
if(order>10||order<2)
{
system("cls");
cout<<"\n\n\n\n\t\t\t\t!Wrong Input Please Try Again \n\tOrder Of Matrices is more or less than the Expected Input\n\t\t\tEnter To Continue..";
getch();
goto input;
}

void Multiplier(char [][10],char B[][10]);
void Input(char A[][10],int Matrix);
void End(char Result[][10]);

char First[10][10];
char Second[10][10];

Input(First,1);
for(int i=2;i<=Matrices;i++)
{
Input(Second,i);
Multiplier(First,Second);
}

End(First);

}

void Multiplier(char A[10][10],char B[10][10])
{

for(int r=0;r<order;r++)
{
    for(int c=0;c<order;c++)
    {

        q=A[r][c];
        q=q-48;
        w=B[r][c];
        w=w-48;
        r=q*w;
        e=r+48;
        A[r][c]=e;cout<<"(A=)"<<A[r][c]<<")";getch();

    }

}



for(int r=0;r<order;r++)
{
    for(int c=0;c<order;c++)
    {
        cout<<"(A=)"<<A[r][c]<<")";getch();
    }

}

}

void Input(char A[10][10],int Matrix)
{

system("cls");
cout<<"Enter "<<Matrix;
if(Matrix==1)cout<<"st";
else if(Matrix==2)cout<<"nd";
else if(Matrix==3)cout<<"rd";
else if(Matrix>3)cout<<"th";
cout<<" Matrix: "<<endl<<endl;

cout<<"\t 1\t 2\t 3"<<endl;
cout<<"\t-------------------";
for(int r=0;r<order;r++)
{
    cout<<"\n\t|\t \t  |\n"<<r+1;
    for(int c=0;c<order;c++)
    {
        cout<<"\t|";
        A[r][c]=getch();
        cout<<A[r][c];
    }
    cout<<"|";
}
cout<<"\n\t-------------------";

}

void End(char Result[10][10])
{
system("cls");
cout<<"Resultant Matrix is: "<<endl<<endl;

cout<<"\t 1\t 2\t 3"<<endl;
cout<<"\t-------------------";
for(int r=0;r<order;r++)
{
    cout<<"\n\t|\t \t  |\n"<<r+1;
    for(int c=0;c<order;c++)
    {
        cout<<"\t|";

        cout<<Result[r][c];
    }
    cout<<"|";
}
cout<<"\n\t-------------------";

}

/* It's a matrix multiplying code of c+++ in the multiplier function it receives two matrices [2d array] and assigns the corresponding element products to the first one (to clarify read the function). As you can see there are two loops in the multiplier function at the end of the first loop I print cout<<A[r][c]; here the result come as expected but when the loop terminates in the second loop I have again try to print that array but the values are not left they are changed as you can see there is no assignment between the loops no function no jump statement but still the values changes . I can't understand what's the logic Can anyone please help me .
I have used codeblocks here

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories