Program for Array 2 dimensi

Posted by Didi Setyapramana On 9:04 AM 0 komentar

#include <cstdlib>
#include <iostream>

using namespace std;

void baca(int q[10][10], int k, int b)
{
     for(int w=0;w<k;w++)
     for(int e=0;e<b;e++)
     {
             cout<<"Data["<<w+1<<","<<e+1<<"]:";
             cin>>q[w][e];
     }
}

void cetak(int r[10][10], int k, int b)
{
     for(int t=0;t<k;t++)
{
     for(int y=0;y<k;y++)   
     cout<<" "<<r[t][y];
     cout<<endl;
}
}

void jumlah(int h[10][10],int g[10][10] ,int k,int b,int f[10][10])
{
     for(int i=0;i<k;i++)
     for(int u=0;u<b;u++)
     f[i][u]=h[i][u]+g[i][u];
}

int main(int argc, char *argv[])

{
int a,b;
int c[10][10],l[10][10];
int j[10][10];

cout<<"Masukan Kolom:";
cin>>a;
cout<<"Masukan baris:";
cin>>b;
cout<<"Pertama"<<endl;
baca(c,a,b);
cetak(c,a,b);
cout<<"Kedua"<<endl;
baca(l,a,b);
cetak(l,a,b);
cout<<"Jumlah"<<endl;
jumlah(c,l,a,b,j);
cetak(j,a,b);

system("PAUSE");
return EXIT_SUCCESS;
}

Categories: ,

0 Response for the "Program for Array 2 dimensi"

Post a Comment