FinalExamS2009Pt1FinalVersionSolution

# FinalExamS2009Pt1FinalVersionSolution - EAS 230 Final...

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

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; }

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

View Full Document
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; system("pause"); return 0; } "data.txt" 1 1 1 1 2 1 1 3 3 1 A. 1.9 B. 4 C. 7.1 D. 0.001
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern