Write a C++ Program that:
· Declares a 3x3 array.
· Input complete array from user.
· Print it’s diagonal.
#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;
}
Comments
Leave a comment