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

What is the difference between ā€˜gā€™ and ā€œgā€ in C?

2498


What is call by reference in functions?

553


What is the difference between the local variable and global variable in c?

526


Is stack a keyword in c?

632


What is variables in c?

602






What is a floating point in c?

596


What is the difference between procedural and functional programming?

513


What is a 'null pointer assignment' error?

720


What is the difference between Printf(..) and sprint(...) ?

779


pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)

2197


What is volatile keyword in c?

577


What is spaghetti programming?

664


write a programming in c to find the sum of all elements in an array through function.

1700


What is structure packing in c?

602


Why c is a mother language?

552