Homework7-3 - Homework#7 Program Hw7_3 Written by Justin...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework #7 /* * Program Hw7_3 * Written by Justin Waters * inputs: none * Outputs: Matrix * Description: The program takes two 3X3 matrices and multiplies them together to get a new single 3X3 matrix * */ #include <stdio.h> #include <stdlib.h> #include <math.h> //prototypes void multiplier(const double x[][3], const double y[][3], double z[][3]); void explain(void); int main (void) { FILE *fpin1, *fpin2; //declares file pointers double x[3][3], y[3][3], z[3][3]; int a, b,i,j; explain(); //calls explain function fpin1 = fopen("xmatrix.txt", "r"); //opens file for x matrix //checks for file opening if(fpin1 == NULL) { printf("\n\nFile does not exist so you cannot proceed"); exit(1); } fpin2 = fopen("ymatrix.txt", "r"); //opens file for y matrix //checks for file opening if(fpin2 == NULL) { printf("\n\nFile does not exist so you cannot proceed"); exit(1);
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
} //imports values from file of x matrix (loop) for(a = 0; a < 3; a++) { for(b = 0; b < 3; b++) { fscanf(fpin1,"%lf", &x[a][b]); } } //imports values from file of y matrix (loop) for(a = 0; a < 3; a++) { for(b = 0; b < 3; b++) { fscanf(fpin2,"%lf", &y[a][b]); } } //prints x matrix to screen printf("\n\nHere is the x matrix\n\n"); for(a=0;a<3;a++) { for(b=0;b<3;b++)
Image of page 2
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern