Answer to Question #190915 in C++ for Mogera Rashed

Question #190915

write a c++ program to enter the elements of the matrix a[4][4] then put the product of the first and last row elements of the array a in the new generated one dimensional array b[4]; finally display the array b.


1
Expert's answer
2021-05-09T00:25:41-0400
#include <iostream>
#include <string>
#include <iomanip>


using namespace std;


int main(){
	
	int a[4][4];
	int b[4];


	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			cout<<"Enter value ["<<i<<"]"<<"["<<j<<"]: ";
			cin>>a[i][j];
		}
	}


	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			cout<<a[i][j]<<"   ";
		}
		cout<<"\n";
	}
	//put the product of the first and last row elements of the 
	//array a in the new generated one dimensional array b[4]; 
	for(int i=0;i<4;i++){
		b[i]=a[0][i]*a[3][i];
	}
	cout<<"The product of the first and last row elements of the array\n";
	for(int i=0;i<4;i++){
		cout<<"Column "<<i<<" = "<<b[i]<<"\n";
	}


	return 0;
}





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment