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
What is data types?
Explain what are multibyte characters?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
What is the main difference between calloc () and malloc ()?
Linked lists -- can you tell me how to check whether a linked list is circular?
What is the scope of static variable in c?
Find MAXIMUM of three distinct integers using a single C statement
hi any body pls give me company name interview conduct "c" language only
List out few of the applications that make use of Multilinked Structures?
What are unions in c?
What is wrong with this statement? Myname = 'robin';
How can you increase the size of a statically allocated array?
What is character constants?
What is #line in c?
What is const and volatile in c?