Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- int main()
- {
- int arr[10][10],row,i,j,sum=0,max;
- cout<<"Enter number of rows and cols for arr(max 10): ";
- cin>>row;
- for(i=0;i<row;i++)
- {
- for(j=0;j<row;j++)
- cin>>arr[i][j];
- }
- max=arr[0][0];
- cout<<"The array is: \n";
- for(i=0;i<row;i++)
- {
- for(j=0;j<row;j++)
- {
- cout<<arr[i][j]<<" ";
- }
- cout<<endl;
- }
- for(i=0;i<row;i++)
- {
- for(j=0;j<row;j++)
- {
- if(i==j)
- sum+=arr[i][j];}}
- cout<<"Sumata na dijagonalata e "<<sum<<endl;
- system("PAUSE");
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement