Exam2solution - CGS 2421 C+ Exam 2 FALL 2009-MULTIPLE...

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

View Full Document Right Arrow Icon
CGS 2421 C++ Exam 2 FALL 2009-MULTIPLE CHOICE SECTION Form A This exam is OPEN BOOK, OPEN NOTES, CLOSED NEIGHBOR, CLOSED LAPTOP. Cheaters will receive a ZERO on the exam. All multiple choice answers should be bubbled in on the scantron. Fill in the name, UFID , and form code on the scantron. Sign the signature section on the bottom of the scantron agreeing you have not cheated. Only turn in the scantron and the free response section (last four pages of this handout). Include your username (3 letter username starting with “I”) and name on the free response. 1. Code double a[2] = {1.1, 1.2}; /* A */ double* p = a; /* B */ *p = 2.4; /* C */ cout << *p; /* D */ delete [] p; /* E */ is compliable but contains a serious run-time problem that will likely lead to crash. Identify the line which causes this problem 2. Code: #include<iostream> #include<fstream> using namespace std; int main() { ofstream out("temp.txt"); for(int i=1;i<=3;i++) out <<i<<" "<<i/2; out.close(); ifstream in("temp.txt"); double sum=0.0; for(int i=1;i<=3;i++) { double x; in >> x; sum+=x; } in.close(); cout << sum; return 0; } will print
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. 3 B. 3.5 C. 4 D. 4.5 E. 16 3. Code: char* number="999"; cout << atof(number+1);
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.

Page1 / 6

Exam2solution - CGS 2421 C+ Exam 2 FALL 2009-MULTIPLE...

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