Answer to Question #164181 in C++ for Richa

Question #164181

Write a menu driven program for the following operations on 2-d array of 3*3 elements:

a) sort the data row wise

b) sum of diagonals

c) sum of elements except diagonals

d) transpose the matrix

e) multiplication of matrix

f) additon of matrix

g) display perfect numbers of each column

h) display prime numbers of each row

i) display max digit of each row

j) sort the data column wise



1
Expert's answer
2021-02-17T06:45:52-0500
#include<iostream>
using namespace std;
int main(){
    
int     matrix[3][3];
for(int i=0;i<=2;++i){

    for(int j=0;j<=2;++j){
    
    cout<<"Enter matrix"<<endl;
    cin>>matrix[i][j];
    
    
    
    }

}
int sum=0;
    for( int j=0;j<=2;++j){
    
    
sum=sum+matrix[i][i];
    
    
    
    }    
    cout<<"sum of diagonials"<<sum<<endl;

int sum1=0;
for( i=0;i<=2;++i){

    for(int j=0;j<=2;++j){
    

sum1=sum1+matrix[i][j];
    
    
    
    }

}

    cout<<"sum without diagonials"<<sum1-sum<<endl;





    for( i=0;i<=2;++i){

    for(int j=0;j<=2;++j){
    

cout<<matrix[i][j]<<endl;
    
    
    
    }

    }

    
    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