oke_google

Modul 3.0

Nov 29th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int matriks[2][2];
  8. int matriks1[2][2];
  9. int hasil[2][2];
  10. cout<<"Masukan Nilai Matriks A = \n";
  11. for(int baris=0; baris<2; baris++){
  12. for(int kolom=0; kolom<2; kolom++){
  13. cout<<"Element ke-"<<baris<<"."<<kolom<<" = ";
  14. cin>>matriks[baris][kolom];
  15. }
  16. }
  17. cout<<"Matriks A = \n";
  18. for(int baris=0; baris<2; baris++){
  19. for(int kolom=0; kolom<2; kolom++){
  20. cout<<matriks[baris][kolom]<<"\t";
  21. }
  22. cout<<endl;
  23. }
  24. cout<<"\nMasukan Nilai Matriks B = \n";
  25. for(int baris=0; baris<2; baris++){
  26. for(int kolom=0; kolom<2; kolom++){
  27. cout<<"Element ke-"<<baris<<"."<<kolom<<" = ";
  28. cin>>matriks1[baris][kolom];
  29. }
  30. }
  31. cout<<"Matriks B = \n";
  32. for(int baris=0; baris<2; baris++){
  33. for(int kolom=0; kolom<2; kolom++){
  34. cout<<matriks1[baris][kolom]<<"\t";
  35. }
  36. cout<<endl;
  37. }
  38. cout<<"\nPenjumlahan Matriks\n";
  39. cout<<"-------------------\n";
  40. for(int baris=0; baris<2; baris++){
  41. for(int kolom=0; kolom<2; kolom++){
  42. hasil[baris][kolom]=matriks[baris][kolom]+matriks1[baris][kolom];
  43. cout<<hasil[baris][kolom]<<"\t";
  44. }
  45. cout<<endl;
  46. }
  47. cout<<"\nPengurangan Matriks\n";
  48. cout<<"-------------------\n";
  49. for(int baris=0; baris<2; baris++){
  50. for(int kolom=0; kolom<2; kolom++){
  51. hasil[baris][kolom]=matriks[baris][kolom]-matriks1[baris][kolom];
  52. cout<<hasil[baris][kolom]<<"\t";
  53. }
  54. cout<<endl;
  55. }
  56. cout<<"\nPerkalian Matriks\n";
  57. cout<<"-----------------\n";
  58. for(int baris=0; baris<2; baris++){
  59. for(int kolom=0; kolom<2; kolom++){
  60. hasil[baris][kolom]=matriks[baris][kolom]*matriks1[baris][kolom];
  61. cout<<hasil[baris][kolom]<<"\t";
  62. }
  63. cout<<endl;
  64. }
  65. }
Add Comment
Please, Sign In to add comment