write an algorithm and c program to add two 2x2 matrics

Answer Posted / gouthami chintala

#include<stdio.h>
#include<conio.h>
void main()
{
int a[2][2],b[2][2],c[2][2];
int i,j;
printf("enter the elements for first matrix");
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
scanf("%d",&a[i][j]);
}
}printf("enter the elements for second matrix");
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf("the added matrix is ");
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
printf("%d",c[i][j]);
}
}
}


Is This Answer Correct ?    24 Yes 22 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com

1331


Which is better malloc or calloc?

656


using for loop sum 2 number of any 4 digit number in c language

1738


What is the explanation for cyclic nature of data types in c?

651


Explain how are 16- and 32-bit numbers stored?

787






Write a program with dynamically allocation of variable.

607


In C programming, how do you insert quote characters (‘ and “) into the output screen?

898


Explain what are header files and explain what are its uses in c programming?

630


What is volatile keyword in c?

587


How can I get random integers in a certain range?

617


Is c procedural or functional?

590


Can you write a programmer for FACTORIAL using recursion?

617


Explain what are bus errors, memory faults, and core dumps?

794


Write a code on reverse string and its complexity.

610


What is the right type to use for boolean values in c? Is there a standard type?

568