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

Write a C program to read in a 2-dimestional arrays and store this array in ARY

ID: 3659704 • Letter: W

Question

Write a C program to read in a 2-dimestional arrays and store this array in ARY whose dimensions M and N are read in. Write a function called COPYR that will copy all the elements of the given double array ARY row by row to a single array called VCTR Write a function called COPYC that will copy all the elements of the Given double array ARY column by column to a single array called VCTC Write a function called POLYNOMIAL that will calculate all the elements of the double array ARY one by one with the given polynomial function called POLY. You will store the new double array values to CALCULATED double arrays. POLY(X) =2X3 + 5X2 + 3Sin(X) - 4COS(X) The double array ARY given as: ARY Display the given matrix and calculated matrix and arrays with a proper formatting.

Explanation / Answer

please rate -thanks

#include <stdio.h>
#include<conio.h>
#include <math.h>
void print(double[10][10],int,int,char[]);
void copyr(double[10][10],int,int,double[100]);
void copyc(double[10][10],int,int,double[100]);
void printa(double[100],int,int,char[]);
void polynomial(double[10][10],int,int,double[10][10]);
int main()
{int n,m,i,j;
printf("How many rows in your matrix? ");
scanf("%d",&m);
printf("How many columns in your matrix? ");
scanf("%d",&n);
double ary[10][10],vctr[100],vctc[100],poly[10][10];
printf("Enter the array:");
for(i=0;i<m;i++)
    {for(j=0;j<n;j++)
        {printf("ary[%d][%d]: ",i+1,j+1);
        scanf("%lf",&ary[i][j]);
        }
     }
print(ary,m,n,"Original Matrix");
copyr(ary,m,n,vctr);
printa(vctr,m,n,"as a row array");
copyc(ary,m,n,vctc);
printa(vctr,m,n,"as a column array");
polynomial(ary,m,n,poly);
print(poly,m,n,"Polynomial Matrix");
getch();
return 0;       
}
void polynomial(double a[10][10],int m,int n,double poly[10][10])
{int i,j;
for(i=0;i<m;i++)
   for(j=0;j<n;j++)
       poly[i][j]=2*pow(a[i][j],3)+5*pow(a[i][j],2)+3*sin(a[i][j])-4*cos(a[i][j]);
}
void copyr(double ary[10][10],int m,int n,double vctr[100])
{int i,j,c=0;
for(i=0;i<m;i++)
    {for(j=0;j<n;j++)
          {vctr[c]=ary[i][j];
          c++;
          }
     }
}
void copyc(double ary[10][10],int m,int n,double vctc[100])
{int i,j,c=0;
for(i=0;i<n;i++)
    for(j=0;j<m;j++)
          vctc[c++]=ary[i][j];
}
void printa(double a[100],int m,int n,char mess[])
{int i;
printf("%s ",mess);
for(i=0;i<m*n;i++)
    printf("%5.2f ",a[i]);

printf(" ");
}
void print(double ary[10][10],int m,int n,char mess[])
{int i,j;
printf("%s ",mess);
for(i=0;i<m;i++)
    {for(j=0;j<n;j++)
           printf("%5.2f ",ary[i][j]);
    printf(" ");
    }
printf(" ");
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote