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 calloc malloc realloc in c?
how to write a c program to print list of fruits in alpabetical order?
4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.
How do you define a function?
What is break in c?
What is .obj file in c?
how should functions be apportioned among source files?
What is declaration and definition in c?
What is dynamic dispatch in c++?
Is c procedural or functional?
What is a pointer value and address in c?
What is the function of this pointer?
What is the use of #define preprocessor in c?
Write a c program to build a heap method using Pointer to function and pointer to structure ?
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?