practice-final-w08s

practice-final-w08s - Questions from the CPS125 Final Exam...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Questions from the CPS125 Final Exam - Winter 2008 Question 1 (5 marks): Write a complete C program consisting only of a main program that will read from a file (named pairs.txt ) pairs of numbers: a double followed by an integer. We do not know how many pairs there are but all pairs are complete. Your program must calculate pair by pair the division of the double by the integer and print on a separate line each quotient with three decimals precision. Finally your program will display on a separate line the number of pairs followed by the word “pairs.”. For example if the file contains 4.5 3 6.6 2 , your program will display 1.500 3.300 2 pairs. #include <stdio.h> int main (void) { int npairs=0, integer; double doubl; FILE *in; in = fopen ("pairs.txt", "r"); { npairs = npairs + 1; printf ("%.3lf\n", doubl/integer); } fclose (in); return (0); }
Background image of page 1

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

View Full Document Right Arrow Icon
Question 2 (4 marks): Complete the function only (no main program) that will take two matrices (up to 5x5 in size) and give their multiplication. Assume that the matrices coming from the main program are
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 4

practice-final-w08s - Questions from the CPS125 Final Exam...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online