2 Dimensional Array Matrix The Greater Value Comparison
2 Dimensional Array Matrix The Greater Value Comparison
C language
Program Contents:
#include <stdio.h>
main(){
int matriks1[3][4];
int matriks2[3][4];
int matriks3[3][4];
int brs,klm;
//input matriks1
printf("Input nilai matriks1 \n");
for (brs=0;brs<=2;brs++)
{
for (klm=0;klm<=3;klm++)
{
printf("nilai matriks (%d,%d) : ",brs,klm);
scanf("%d",&matriks1[brs][klm]);
}
}
//input matriks2
printf("Input nilai matriks2 \n");
for (brs=0;brs<=2;brs++)
{
for (klm=0;klm<=3;klm++)
{
printf("nilai matriks (%d,%d) : ",brs,klm);
scanf("%d",&matriks2[brs][klm]);
}
}
//output matriks1
printf("\n");
printf("----Matriks 1----\n");
for (brs=0;brs<=2;brs++)
{
for (klm=0;klm<=3;klm++)
{
printf("%d ", matriks1[brs][klm]);
}printf("\n");
}
//output matriks2
printf("\n");
printf("----Matriks 2----\n");
for (brs=0;brs<=2;brs++)
{
for (klm=0;klm<=3;klm++)
{
printf("%d ", matriks2[brs][klm]);
}printf("\n\n");
}
//Comparison
printf("----Matriks 3----\n");
for (brs=0;brs<=2;brs++){
for (klm=0;klm<=3;klm++)
{
if(matriks1[brs][klm] > matriks2[brs][klm]){
matriks3[brs][klm] = matriks1[brs][klm];
}else{
matriks3[brs][klm] = matriks2[brs][klm];
}printf("%d ", matriks3[brs][klm]);
}printf("\n\n");
}
}
Output Results
0 komentar:
Posting Komentar
Terimakasih Atas Komentarnya semoga berguna demi blog ini