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 are the usage of pointer in c?
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers
What are global variables?
How would you rename a function in C?
What does a pointer variable always consist of?
Why main is used in c?
Explain the concept and use of type void.
Why enum is used in c?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
Explain what are multidimensional arrays?
Why can't I perform arithmetic on a void* pointer?
What is the heap in c?
Explain how can I open a file so that other programs can update it at the same time?
What are directives in c?
Explain the difference between call by value and call by reference in c language?