Answer to Question #322599 in C++ for herry

Question #322599

Write a C++ Program that:

·        Declares a 3x3 array.

·        Input complete array from user.

·        Print it’s diagonal.



1
Expert's answer
2022-04-02T09:58:43-0400




#include<iostream>
using namespace std;
int main()
{
	const int N=3;
	int numbers[3][3];
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			cout<<"Enter number ["<<i<<"]"<<"["<<j<<"]: ";
			cin>>numbers[i][j];
		}
	}	
	cout<<"Diagonal:\n";
	for(int i=0;i<N;i++){
		cout<<numbers[i][i]<<"\n";
	}


	cin>>numbers[0][0];


	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

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS