Pages

💡 Now You Can Get your Assignments Sollution here... .💡 100% plagiarism Free Service...💡 Responsibility, punctuality and on-time delivery... 💡 Furnishing you with experts... 💡 experienced in your subject 100% privacy... 💡 helping you with the highest efficiency , professionalism Affordable and budget-friendly costs that do not make a hole in your wallet

Showing posts with label Arrays. Show all posts
Showing posts with label Arrays. Show all posts

Addition of Two Matrix

Using the functions of task 2 to create another 2-D array of user defined size. Add this
2-D array to the 2-D array created in task 2 and store the result in 3rd 2-D array. Be careful
because both the arrays may be of different sizes so the 3rd array should be able to hold
the result properly



#include<iostream>
using namespace std;
void output2 (int n1,int m1,int** dpp)
{
for(int i=0; i<n1; i++)
{
for(int j=0; j<m1;j++)
{
cout<<dpp[i][j]<<" ";

}
cout<<endl;
}
}
void task4(int n1,int m1,int** dppp,int N,int M,int **dp)
{
bool found=false;
int**dpp;
int r=0,c=0;
if(n1>N)
r=n1;
else r=N;
if(m1>M)
c=m1;
else c=M;
dpp = new int*[r];
for( int i=0; i<r; i++)
dpp[i]=new int[c];
for( i=0; i<r; i++)
{
for(int j=0; j<c;j++)

{
if(dp[i][j]==true && dppp[i][j]==true)
{
dpp[i][j]= dp[i][j]+dppp[i][j];
}
}
}
output2(r,c,dpp);

}
void output1 (int n1,int m1,int** dppp,int n,int m,int**dp)
{
for(int i=0; i<n1; i++)
{
for(int j=0; j<m1;j++)
{
cout<<dppp[i][j]<<" ";

}
cout<<endl;
}
cout<<endl;
task4( n1, m1,dppp, n, m,dp);
}

void input1(int n1,int m1,int **dp,int n,int m)
{
int **dppp;
cout<<"enter the no of rows : ";
cin>>n1;
cout<<endl<<"enter the number of columns : ";
cin>>m1;
dppp = new int*[n1];
for(int i=0; i<n1; i++)
dppp[i]=new int[m1];
for( i=0; i<n1; i++)
{
for(int j=0; j<m1;j++)
{
dppp[i][j]= rand()%10;
}
}
output1(n1,m1,dppp,n,m,dp);
}

void output (int n,int m,int** dp,int n1,int m1)
{
for(int i=0; i<n; i++)
{
for(int j=0; j<m;j++)
{
cout<<dp[i][j]<<" ";

}
cout<<endl;
}
input1(n1,m1,dp,n,m);
}

void input(int n, int m,int n1,int m1)
{
int**dp;
cout<<"enter the no of rows : ";
cin>>n;
cout<<endl<<"enter the number of columns : ";
cin>>m;
dp = new int*[n];
for(int i=0; i<n; i++)
{
dp[i]=new int[m];
}
for(int k=0; k<n; k++)
{
for(int j=0; j<m;j++)
{
dp[k][j]= rand()%10;
}
}
output(n,m,dp,n1,m1);
}
int main()

{

int n=0,n1=0,m1=0,m=0;
input(n,m,n1,m1);
system("pause");
return 0;

}