S
shan
What is the meaning for the error expression syntax and type mismatch
error.I am using turbo c++.can anybody correct the errors in the
folowing program.
Following program is to find matrix addition.
Thanks in advance.
#include<stdio.h>
int rows,cols,a[3][3],b[3][3];
void main()
{
int mat_add[3][3],i,j;
int enter(void);
int getting_mat_1(int a[][3]);
int getting_mat_2(int b[][3]);
enter();
getting_mat_1(a[][3]); /*line 10 expression syntax*/
getting_mat_2(b[][3]); /*line 11 same as above*/
for(i=0;i<rows;i++)
for(j=0;j<cols;j++)
mat_add[j]=a[j]+b[j];
for(i=0;i<rows;i++)
{
printf("\n");
for(j=0;j<cols;j++)
printf("%d",mat_add[j]);
}
}
int enter(void)
{
int i,j;
printf("Enter how many rows to be entered\n");
scanf("%d",&rows);
printf("Enter how many columns to be entered\n");
scanf("%d",&cols);
printf("Enter the matrix in the form\n1 0 1\n9 8 7\n7 5 2\n");
return(rows,cols);
}
void getting_mat_1(int a[][3])
{ /*line 37 type mismatch in
declaration*/
int i,j;
for(i=0;i<rows;i++)
{
for(j=0;j<cols;j++)
{
if ('\n'==getchar())
break;
else
scanf("%d",a[j]);
}
}
}
int getting_mat_2(int b[][3])
{
int i,j;
for(i=0;i<rows;i++)
{
for(j=0;j<cols;j++)
{
if ('\n'==getchar())
break;
else
scanf("%d",b[j]);
}
}
}
error.I am using turbo c++.can anybody correct the errors in the
folowing program.
Following program is to find matrix addition.
Thanks in advance.
#include<stdio.h>
int rows,cols,a[3][3],b[3][3];
void main()
{
int mat_add[3][3],i,j;
int enter(void);
int getting_mat_1(int a[][3]);
int getting_mat_2(int b[][3]);
enter();
getting_mat_1(a[][3]); /*line 10 expression syntax*/
getting_mat_2(b[][3]); /*line 11 same as above*/
for(i=0;i<rows;i++)
for(j=0;j<cols;j++)
mat_add[j]=a[j]+b[j];
for(i=0;i<rows;i++)
{
printf("\n");
for(j=0;j<cols;j++)
printf("%d",mat_add[j]);
}
}
int enter(void)
{
int i,j;
printf("Enter how many rows to be entered\n");
scanf("%d",&rows);
printf("Enter how many columns to be entered\n");
scanf("%d",&cols);
printf("Enter the matrix in the form\n1 0 1\n9 8 7\n7 5 2\n");
return(rows,cols);
}
void getting_mat_1(int a[][3])
{ /*line 37 type mismatch in
declaration*/
int i,j;
for(i=0;i<rows;i++)
{
for(j=0;j<cols;j++)
{
if ('\n'==getchar())
break;
else
scanf("%d",a[j]);
}
}
}
int getting_mat_2(int b[][3])
{
int i,j;
for(i=0;i<rows;i++)
{
for(j=0;j<cols;j++)
{
if ('\n'==getchar())
break;
else
scanf("%d",b[j]);
}
}
}