60 347
Assignments Done
98%
Successfully Done
In April 2018

Answer to Question #24432 in C++ for adrian thomas

Question #24432
7.Enter a 3*3 matrix and display the diagonal element.
Expert's answer
#include <iostream>
#include <conio.h>

using namespace std;

void main(){
int a=0,b=0,i,j,s,c[3][3]; //initialising matrix
cout<<"Enter Values into Matrix of side(s)
";
for(i=0; i<3; i++) {
for(j=0; j<3; j++){
cin>>c[i][j];
}
}
cout<<"
The Given Matrix is
"; // Output MAtrix
for(i=0; i<3; i++) {
cout<<"
";
for(j=0; j<3; j++){
cout<<c[i][j];
}
}
cout<<"
Diagonal element: ";
for(i=0; i<3; i++) {
cout<<"
";
for(j=0; j<3; j++){
if(i==j){
cout<<c[i][j];
}
}
}
cout<<"
";
getch();
}

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions