Question

Complete the mult() and printArr() functions

#include <iostream> using namespace std; void init(int arr]05], int x)t //initialization loop for row 1 and 2 for(int i = 0;

31 int x 32 34 // initialize function call 35 init(arr,x); 36 //multiply function call 37 mult(arr); 38 // print function cal

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ code

============================================================================================

#include<iostream>

using namespace std;

void init(int arr[][5],int x)
{
  
   for(int i=0;i<2;i++)
   {
       for(int j=0;j<5;j++)
       {
               arr[i][j]=x;
       }
       ++x;
   }
  
}

void mult(int arr[][5])
{
   //multiply row 2 by row 1
   for(int i=0;i<5;i++)
   {
       arr[2][i]=arr[0][i]*arr[1][i];
   }
  
  
}
void printArr(int arr[][5])
{
   //loop to print elements of the array
   for(int i=0;i<3;i++)
   {
       for(int j=0;j<5;j++)
       {
           cout<<arr[i][j]<<" ";
      
       }
       cout<<endl;
   }
}

int main()
{

int arr[3][5];
int x;

cin>>x;
init(arr,x);
mult(arr);

printArr(arr);
return 0;
}

============================================================================================

Output

DACheogC++ Cheqq 2damay murtiply.cop IExecutingl -DevC++5.1 Eile Edit Search Yew Project Egecute lools AStyle岦ndow Help Proje

Add a comment
Know the answer?
Add Answer to:
Complete the mult() and printArr() functions #include <iostream> using namespace std; void init(int arr]05], int x)t //initialization loop for row 1 and 2 for(int i = 0; i < 2; i++){ arr i]...
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