Advertisement
saira12tabassum19

Untitled

Jul 28th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. //diagonal matrix
  2. #include<iostream>
  3. using namespace std;
  4. int main()
  5. {
  6. int row,column,i,j,ar[10][10],k=0,check1=0,count1=0,countd=0,checkd=0;
  7. while(1)
  8. {cout<<"Enter the size of array :"<<endl;
  9. cin>>row>>column;
  10. for(i=0;i<row;i++)
  11. {
  12. for(j=0;j<column;j++)
  13. {
  14. cin>>ar[i][j];
  15. cout<<ar[i][j]<<" ";
  16. } cout<<endl;
  17. }
  18.  
  19. for(i=0;i<row;i++)
  20. {
  21. for(j=0;j<column;j++)
  22. {
  23. if(i!=j)
  24. {
  25. if(ar[i][j]==0);
  26. else k=1;
  27. }
  28. else {
  29. if(ar[i][j]==1){check1=1;}
  30. else if(ar[i][j]==ar[0][0]){checkd=1;}
  31. }
  32. }
  33. if(k==1) break;
  34. else if(check1==1){count1++; check1=0;}
  35. else if(checkd==1){countd++; checkd=0;}
  36. }
  37. if(i==row)
  38. {
  39. if(count1==row)cout<<"Scalar & Diagonal & Identity Matrix"<<endl;
  40. else if(countd==row)cout<<"Scalar & Diagonal Matrix"<<endl;
  41. else cout<<"Diagonal Matrix"<<endl;
  42.  
  43. }
  44. else cout<<"Not Diagonal Not Scalar Not Identity Matrix"<<endl;
  45. check1=count1=countd=checkd=0;
  46.  
  47.  
  48. }
  49.  
  50.  
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement