InterviewSolution
Saved Bookmarks
| 1. |
Write a function in C++ to print the product of each row of a two dimensional integer array passed as the argument of the function.Explain: if the two dimensional array contains204010405030603020402030Then the output should appear as:Product of Diagonal 1 = (1 x 5 x 2 x 4)=40Product of Diagonal 2 = (3 x 6 x 3 x 2)=108 |
|
Answer» void RowProduct(int A[4][3],int R,int C) { int Prod[R]; for(int i=0;i<R;i++) { Prod[i]=1; for(int j=0;j<c;j++) Prod[i]*=A[i][j]; cout<<"Product of row"<<i+1<<"="<<Prod[i]<<endl; } } |
|