FinalExam - UNIVERSITY AT BUFFALO EAS 230 Final Examination...

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

View Full Document Right Arrow Icon
UNIVERSITY AT BUFFALO EAS 230 Final Examination Part I December 8, 2008 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 3 double x=2.0, y=3.0; cout << pow(x,y) – pow(y,x) << endl; a. -1 b. 0 c. 1 d. 8 Question 1 int i=7, j=6; cout << (i--)%(--j) << endl; a. 0 b. 1 c. 2 d. 5 Question 2 int i=2, j=3; double x=0.5; cout << setprecision(4)<< (j/i)*sin(x) << endl; a. 0.7191 b. 0.008727 c. 0.01309 d. 0.4794 Question 4 double x=4.4, j=2.0; cout << pow(sin(x),j)+pow(cos(x),j) << endl; a. -1.2589 b. 1 c. 1.0738 d. 0.8111 Question 5 int i, j=3; for (i=2; i<10; i+=j){ if (i>6) { j++; } } cout << i << endl; a. 2 b. 4 c. 12 d. 11
Background image of page 1

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

View Full DocumentRight Arrow Icon
Question 6 int i=1, j=6; int ctr=0; while (i%j != 0) { i++; j--; ctr++; } cout << ctr << endl; a. 3 b. 4 c. 5 d. 6 Question 7 int n = 0; int m = 3; for (int i=0; i<m; i++) { m--; n++; } if (++n < 3) m--; if (n == 3) { m++; } else { m+=2; } cout << m << endl; a. -1 b. 0 c. 1 d. 2 Question 8 for (int i=0; i<2; i+=2) { cout << i-- << endl; cout << i << endl; } Enter the output in the box below 0 -1 1 0 Question 9 Content of "gas.txt" 200 4.5 620 5.0 825 5.5 int main() { double liter, price; double total=0; ifstream fin("gas.txt"); fin >> liter >> price; while(!fin.fail()) {
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 / 8

FinalExam - UNIVERSITY AT BUFFALO EAS 230 Final Examination...

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