hi
"this program is for adding 2 tables with 3 rows and 4 columns" ....
so i have done like this......
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][4],b[3][4],c[3][4];
int i,j;
clrscr();
printf("\nENTER AN ARRAY:");
printf("\n\nFIRST TABLE:");
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
scanf("%d",&a[j]);
}
}
printf("\nENTER AN ARRAY:");
printf("\n\nSECOND TABLE:");
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
scanf("%d",&b[j]);
}
}
printf("\nENTER AN ARRAY:");
printf("\nSUM OF TABLES:");
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
printf("%4d",c[j]);
c[j]=a[j]+b[j];
printf("\n");
}
}
getch();
}
galmca
0
Light Poster
Recommended Answers
Jump to PostI think you should move the printf ("\n"); outside of one of the 2 for loops:
#include<stdio.h> #include<conio.h> void main() { int a[3][4],b[3][4],c[3][4]; int i,j; clrscr(); printf("\nENTER AN ARRAY:"); printf("\n\nFIRST TABLE:"); for(i=0;i<3;i++) { for(j=0;j<4;j++) { scanf("%d",&a[i][j]); } } printf("\nENTER AN ARRAY:"); printf("\n\nSECOND TABLE:"); for(i=0;i<3;i++) { for(j=0;j<4;j++) …
Jump to PostGreetings,
There are a few issues with the program. Nothing major though.
Firstly, frrossk showed the first issue. The new line should only take place after the first loop is continuing, not the second loop. Also, the lines of:
printf("%4d ",c[i][j]); c[i][j]=a[i][j]+b[i][j];
Try flipping the …
All 6 Replies
galmca
0
Light Poster
frrossk
2
Posting Whiz in Training
Stack Overflow
8
Junior Poster
jigvesh
0
Light Poster
frrossk
2
Posting Whiz in Training
galmca
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.