FinalExamS2009Pt1FinalVersionSolution

FinalExamS2009Pt1FinalVersionSolution - EAS 230 Final...

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

View Full Document Right Arrow Icon
EAS 230 Final Examination Part I May 6, 2009 Each of the 20 questions on Part I is worth 5 points. NAME ____________________________ SECTION#_______ UBIT ID (email):__________ Select the correct output from the given code fragment, or provide answer in the box, where appropriate. Assume the rest of the code is error free and does not cause either compilation or run-time errors. Question 1 int main() { double x=9.13, y=3.41; x = x+y; y = x-y; x = x-y; cout << x << " " << y << endl; system("pause"); return 0; } A. 9.13 3.14 B. 5.72 5.72 C. 9.13 9.13 D. 3.41 9.13 Question 2 int main() { double t=3.7, f=8.12; cout << fixed << setprecision(3); cout << t++*--f << endl; system("pause"); return 0; } A. 26.344 B. 38.164 C. 30.044 D. 33.464 Question 3 int main() { int i=4, j=6, k=8, m=-1; if (k%i == j/k) { m *= i*(j-j%i); } else if (k/j > j/i) { m -= k%j; } else{ m *= i%m; } cout << m << endl; system("pause"); return 0; } A. -16 B. -3 C. -1 D. 0 Question 4 void tally(double&,double); int main() { double sum=0; int i; double f; for (i=10; i>0; i-=3) { f = pow(i,sin(i))*log(i); tally(sum,f); } cout << setprecision(2); cout << sum << endl; system("pause"); return 0; } void tally(double& x,double y) { x += y; }
Background image of page 1

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

View Full DocumentRight Arrow Icon
A. 4.95 B. 6.11 C. 8.13 D. 11.5 Question 5 int main() { ifstream datain("data.txt"); double x=0.1, y=0.9; double coef[4][4]; double tot=0; for (int i=0; i<4; i++) { for (int j=0; j<=i; j++) { datain >> coef[i][j]; } } for (int i=0; i<4; i++) { for (int j=0; j<=i; j++) { tot += coef[i][j]*pow(x,i-j)*pow(y,j); } } cout << tot << endl;
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.

This document was uploaded on 09/28/2011.

Page1 / 6

FinalExamS2009Pt1FinalVersionSolution - EAS 230 Final...

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