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
Why is c not oop?
What's the difference between constant char *p and char * constant p?
Combinations of fibanocci prime series
Do you know the use of 'auto' keyword?
the portion of a computer program within which the definition of the variable remains unchanged a) mode b) module c) scope d) none
How can I implement sets or arrays of bits?
What is "Duff's Device"?
what is a function method?give example?
What is putchar() function?
What is the advantage of c?
What is getch?
What is meant by recursion?
What do you mean by a local block?
In a switch statement, what will happen if a break statement is omitted?
What is the use of bit field?