file name:- addmat.cpp
#include<iostream.h>
#include<conio.h>
#define R 2
#define C 2
void main(){
int A[R][C],B[R][C],ANS[R][C],i,j;
clrscr();
cout<<"Enter elements of array A"<<endl;
for(i=0;i<R;i++){
for(j=0;j<C;j++){
cout<<"Enter A["<<i<<"]["<<j<<"]= ";
cin>>A[i][j];
}}
cout<<"Enter elements of array B"<<endl;
for(i=0;i<R;i++){
for(j=0;j<C;j++){
cout<<"Enter B["<<i<<"]["<<j<<"]= ";
cin>>B[i][j];
}}
for(i=0;i<R;i++){
for(j=0;j<C;j++){
ANS[i][j]=A[i][j]+B[i][j];
}}
cout<<"Addition of A and B ="<<endl;
for(i=0;i<R;i++){
for(j=0;j<C;j++){
cout<<ANS[i][j]<<" ";
}
cout<<endl;
}
getch();
}
#define R 2
#define C 2
void main(){
int A[R][C],B[R][C],ANS[R][C],i,j;
clrscr();
cout<<"Enter elements of array A"<<endl;
for(i=0;i<R;i++){
for(j=0;j<C;j++){
cout<<"Enter A["<<i<<"]["<<j<<"]= ";
cin>>A[i][j];
}}
cout<<"Enter elements of array B"<<endl;
for(i=0;i<R;i++){
for(j=0;j<C;j++){
cout<<"Enter B["<<i<<"]["<<j<<"]= ";
cin>>B[i][j];
}}
for(i=0;i<R;i++){
for(j=0;j<C;j++){
ANS[i][j]=A[i][j]+B[i][j];
}}
cout<<"Addition of A and B ="<<endl;
for(i=0;i<R;i++){
for(j=0;j<C;j++){
cout<<ANS[i][j]<<" ";
}
cout<<endl;
}
getch();
}
file name:- addmat.c
#include<stdio.h>
#include<conio.h>
#define R 2
#define C 2
void main(){
int A[R][C],B[R][C],ANS[R][C],i,j;
clrscr();
printf("Enter Elements of Array A\n");
for(i=0;i<R;i++){
for(j=0;j<C;j++){
printf("Enter A[%d][%d]=",i,j);
scanf("%d",&A[i][j]);
}}
printf("Ente r Elements of Array B\n");
for(i=0;i<R;i++){
for(j=0;j<C;j++){
printf("Enter B[%d][%d]=",i,j);
scanf("%d",&B[i][j]);
}}
for(i=0;i<R;i++){
for(j=0;j<C;j++){
ANS[i][j]=A[i][j]+B[i][j];
}}
printf("Addition of A and B =\n");
for(i=0;i<R;i++){
for(j=0;j<C;j++){
printf("%d ",ANS[i][j]);
}
printf("\n");
}
getch();
}
#define R 2
#define C 2
void main(){
int A[R][C],B[R][C],ANS[R][C],i,j;
clrscr();
printf("Enter Elements of Array A\n");
for(i=0;i<R;i++){
for(j=0;j<C;j++){
printf("Enter A[%d][%d]=",i,j);
scanf("%d",&A[i][j]);
}}
printf("Ente r Elements of Array B\n");
for(i=0;i<R;i++){
for(j=0;j<C;j++){
printf("Enter B[%d][%d]=",i,j);
scanf("%d",&B[i][j]);
}}
for(i=0;i<R;i++){
for(j=0;j<C;j++){
ANS[i][j]=A[i][j]+B[i][j];
}}
printf("Addition of A and B =\n");
for(i=0;i<R;i++){
for(j=0;j<C;j++){
printf("%d ",ANS[i][j]);
}
printf("\n");
}
getch();
}
No comments:
Post a Comment