Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6. int arr[10][10],row,i,j,sum=0,max;
  7. cout<<"Enter number of rows and cols for arr(max 10): ";
  8. cin>>row;
  9. for(i=0;i<row;i++)
  10. {
  11. for(j=0;j<row;j++)
  12. cin>>arr[i][j];
  13. }
  14. max=arr[0][0];
  15. cout<<"The array is: \n";
  16. for(i=0;i<row;i++)
  17. {
  18. for(j=0;j<row;j++)
  19. {
  20. cout<<arr[i][j]<<" ";
  21.  
  22. }
  23. cout<<endl;
  24. }
  25. for(i=0;i<row;i++)
  26. {
  27. for(j=0;j<row;j++)
  28. {
  29. if(i==j)
  30. sum+=arr[i][j];}}
  31. cout<<"Sumata na dijagonalata e "<<sum<<endl;
  32. system("PAUSE");
  33. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement