Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int tambah(int a[][2], int b[][2]);
- int main() {
- int a[2][2]={1,2,3,4};
- int b[2][2]={5,6,7,8};
- int c[2][2];
- int j,i;
- printf("Matriks A \n");
- for (i=0; i<2; i++) {
- for(j=0;j<2;j++) {
- printf(" %d" ,a[i][j]);
- }
- printf("\n");
- }
- printf("Matriks B \n");
- for (i=0; i<2; i++) {
- for(j=0;j<2;j++) {
- printf(" %d" ,b[i][j]);
- }
- printf("\n");
- }
- tambah(a,b);
- return 0;
- }
- //-- Assuming the dimension is 2x2
- int tambah(int a[][2], int b[][2]){
- int i,j;
- int c[2][2];
- printf("Hasil a+b \n");
- for (i=0; i<2; i++) {
- for(j=0;j<2;j++) {
- c[i][j]=a[i][j]+b[i][j];
- printf(" %d",c[i][j]);
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement