WRITE A PROGRAM IN C TO MULTIPLY TWO 2-D ARRAYS

Answers were Sorted based on User's Feedback



WRITE A PROGRAM IN C TO MULTIPLY TWO 2-D ARRAYS..

Answer / shubham singh

#include<conio.h>
#include<stdio.h>
void main()
{
int a[2][2],b[2][2],c[2][2];//declare 3 array int type
int i,j,k;

for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
} scanf("%d",&a[i][j]);//inserting element in array a

}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
} scanf("%d",&b[i][j]);//inserting element in array b

}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
for(k=;k<2;K++)
{
c[i][j]+=a[i][k]*b[i][j];//multiply of a and b
}
}
}

for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d",a[i][j]);//printing element of array c
}
}
}//main close

Is This Answer Correct ?    29 Yes 23 No

WRITE A PROGRAM IN C TO MULTIPLY TWO 2-D ARRAYS..

Answer / abhradeep chatterjee

#include<conio.h>
#include<stdio.h>
void main()
{
int a[2][2],b[2][2],c[2][2];//declare 3 array int type
int i,j,k;

for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
} scanf("%d",&a[i][j]);//inserting element in array a

}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
} scanf("%d",&b[i][j]);//inserting element in array b

}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
for(k=;k<2;K++)
{
c[i][j]+=a[i][k]*b[i][j];//multiply of a and b
}
}
}

for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d",a[i][j]);//printing element of array c
}
}
}

Is This Answer Correct ?    20 Yes 21 No

WRITE A PROGRAM IN C TO MULTIPLY TWO 2-D ARRAYS..

Answer / abhradeep chatterjee

Shubham Singh's Code is Wrong. Please follow my code for
output.

Is This Answer Correct ?    5 Yes 10 No

WRITE A PROGRAM IN C TO MULTIPLY TWO 2-D ARRAYS..

Answer / akshay sharma

#include<stdio.h>
#include<conio.h>
main()
{
int a[2][2],b[2][2],c[2][2],i,j,k;

for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&a[i][j]);
}
}

for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{


c[i][j]=a[i][j]*b[i][j];

}
}

for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d",c[i][j]);
}
}
}

Is This Answer Correct ?    10 Yes 18 No

Post New Answer

More C Interview Questions

Why should I use standard library functions instead of writing my own?

0 Answers  


Why doesn't the code "a[i] = i++;" work?

4 Answers  


Lists the benefits of c programming language?

0 Answers  


Can include files be nested? How many levels deep can include files be nested?

0 Answers   Aspire, Infogain,


What is optimization in c?

0 Answers  






Is that possible to add pointers to each other?

0 Answers  


while initialization of array why we use a[][2] why not a[2][]...?

0 Answers   Aptech,


Explain the importance and use of each component of this string: Foo.Bar, Version=2.0.205.0, Culture=neutral, PublicKeyToken=593777ae2d274679d

1 Answers   TCS,


what is difference between array and structure?

44 Answers   College School Exams Tests, CTS, Google, HCL, IBM, Motorola, TCS,


Explain this code. #include <stdio.h> void f1(int *k) { *k = *k + 10; } main ( ){ int i; i = 0; printf (" The value of i before call %d \n", i); f1 (&i); printf (" The value of i after call %d \n", i); }

3 Answers   IBM,


p*=(++q)++*--p when p=q=1 while(q<=6)

0 Answers   KINPOE,


How can I find leaf node with smallest level in a binary tree?

1 Answers  


Categories