Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

this is my program so far but i\'m getting errors. can someoneplease help me out

ID: 3609381 • Letter: T

Question

this is my program so far but i'm getting errors. can someoneplease help me out? thanks.

#include <stdio.h>
#include <math.h>
//#define comes here
//Function prototypes come here
int main(void)
{
{
        int rows, cols, row,col;
        double **a, *b, *c,sum;
        FILE *infile;
        infile =fopen("matrix5.dat", "r");
        fscanf(infile, "%d %d",&rows, &cols);
       printf("rows=%d    cols=%d ", rows, cols);
          a = (double**)calloc((size_t)rows, sizeof(double *));
        for(row=0; row<rows;row++){
          a[row]=(double *)calloc((size_t)cols, sizeof(double));
        }
        for(row=0; row<rows;row++)
          for(col=0; col<cols; col++) fscanf(infile, "%lf",a[row]+col);

       printf(" a[][]: ");
        for(row=0; row<rows;row++){
        printf("a[%d] ",row);
        for(col=0; col<cols;col++){
        printf("%9.3f",a[row][col]);
        if((col+1)%10 == 0)printf(" ");
        }
        printf(" ");
}


        b = (double*)calloc((size_t)rows, sizeof(double *));
        c = (double*)calloc((size_t)rows, sizeof(double *));

               for(row=0; row<rows; row++)
          for(col=0; col<cols; col++) fscanf(infile, " %lf", b + col);

        printf("b[] ",row);
        for(col=0; col<cols;col++){
        printf("%9.3f",b[col]);
        if((col+1)%10 == 0)printf(" ");
        }
printf(" ");
         for(row=0;row<rows; row++){
          for(col=0,sum=0.0; col<cols; col++)
               sum += a[row][col]*b[col];
          c[row]=sum;
        }
        //print c[]
        printf("c[]={");
        for(row=0; row<rows;row++) printf(" %9.3f", c[row]);
        printf(" } ");
{
        free(infile);
        for(i=0; i<rows;i++){
               free(a[i]);
}
free(a);
free(b);
free(c);
exit(0);
}

}

this is my error:

q.c:54: error: `i' undeclared (first use in this function)
q.c:54: error: (Each undeclared identifier is reported onlyonce
q.c:54: error: for each function it appears in.)

Explanation / Answer

//Hope this will help you.. //Don't forget to rate it.. #include #include #include //#define comes here //Function prototypes come here int main(void) {         int rows, cols, row,col;         double **a, *b,*c,sum;         FILE *infile;         infile =fopen("matrix5.dat", "r");         fscanf(infile, "%d %d",&rows, &cols);        printf("rows=%d    cols=%d ", rows, cols);           a = (double**)calloc((size_t)rows, sizeof(double *));         for(row=0; row