0

whats my error

#include<stdio.h> /*Printing odd numbers in the first and last column of a matrix*/ int add_matrix();//function declaration int main() { int row, col; printf("Enter the number of rows: "); scanf("%d", &row); printf("Enter the number of columns: "); scanf("%d", &col); int matrix[row][col]; for (int i=0; i<row; i++) { for (int j=0; j<col; j++) { printf("Matrix[%d][%d]: ", i, j); scanf("%d", &matrix[i][j]); } } add_matrix(matrix, row, col); } int add_matrix(int a[][],int row,int col) { int sum=0; for (int i=0; i<row; i++) { if((a[i][1] % 2) != 0) { sum += a[i][1]; } } }

12th Jan 2022, 10:21 AM
saad
1 Answer
+ 2
Function declaration not matching with definition... And must declare column size in array declaration.. void add_matrix(int a[][5],int i,int j);//function declaration And you are not or output any result of calculations.. First column is indicated by a[ i ][0] and last column is indicated by a[ i ][col-1]. Col=1 indicates 2nd column as array indices are starts from 0.
12th Jan 2022, 12:55 PM
Jayakrishna 🇼🇳