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 the difference between āgā and āgā in C?
What is call by reference in functions?
What is the difference between the local variable and global variable in c?
Is stack a keyword in c?
What is variables in c?
What is a floating point in c?
What is the difference between procedural and functional programming?
What is a 'null pointer assignment' error?
What is the difference between Printf(..) and sprint(...) ?
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
What is volatile keyword in c?
What is spaghetti programming?
write a programming in c to find the sum of all elements in an array through function.
What is structure packing in c?
Why c is a mother language?