Question

Suppose that an array A of n 1 numbers is given. We want to create a n x n matrix B such that, for 0 i<j<n, Bli.j] AIk] = Ali

Can someone please help me in solving question in attached image. Thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1
this program in c++
#include <iostream>

using namespace std;

int main()

{

int n;

cin>>n;

int a[n],c[n][n],b[n][n],i,j;

for(i=0;i<n;i++)   //This for loop run for n times

{

     cin>>a[i];

}

for(i=0;i<n;i++) //This for loop run for n times

{

      int sum=0;

       for(j=0;j<n;j++) //This for loop run for n times

      {

        if(i<=j)

        {

           sum=sum+a[j];

          c[i][j]=sum;

        }

       else

          c[i][j]=0;

      }

}

for(i=0;i<n;i++) //This for loop run for n times

{

      for(j=0;j<n;j++) //This for loop run for n times

      {

           if(i>=j)

             b[i][j]=0;

         else

             b[i][j]=c[i][j];

      }

}

for(i=0;i<n;i++) //This for loop run for n times

{

      for(j=0;j<n;j++) //This for loop run for n times

      {

         cout<<b[i][j];

       }

cout<<endl;

}

return 0;

}

En mo 3 B matrix 10 3 cmatrix TL 3 67 lo 2 s 5 0 0

Add a comment
Know the answer?
Add Answer to:
Can someone please help me in solving question in attached image. Thanks Suppose that an array...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT