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
How do you declare a variable that will hold string values?
how to find anagram without using string functions using only loops in c programming
Why string is used in c?
What are loops c?
Is c dynamically typed?
What is volatile variable in c with example?
What is the purpose of main( ) in c language?
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
What is the explanation for modular programming?
What is malloc and calloc?
Once I have used freopen, how can I get the original stdout (or stdin) back?
What is a #include preprocessor?
What is a constant?
How can variables be characterized?
Why pointers are used in c?