{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

10AfinalF06key

# 10AfinalF06key - PIC 10A Final Exam Answers Fall 2006 Prof...

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

PIC 10A Final Exam Answers Fall 2006 Prof. Todd Wittman 1.) [20 points] For each library listed below, give a brief description of the library and its use. Then give an example of a function in the library and what it does. The first one is done for you as an example. <cmath> Contains useful mathematical functions like exponential and trig functions. sqrt(x) -- returns the square root of a double x <iostream> Handles input / output for the console window. cout << x -- outputs the value of x to the console window <vector> Allows declaration of vector class (dynamic list) and its member functions. v.push_back(x) – adds element with value x to the end of the vector v <string> Allows use of the string class, which is used for parsing text. s.length( ) -- returns the # characters in string s <iomanip> Formats output: control spacing and number of digits reported. setw (w) -- outputs data right-justified in column of width w <fstream> Used for input / output from data files. ofstream o – creates an output file stream o for writing to a file -------------------------------------------------------------------------------------------------------------------------------- 2.) [10 points] Briefly comment each of the following lines of code. The first line is done for you. Make sure you describe the difference between the last two lines. int x = 2; //Creates integer x and assigns it value 2. int *p; //Creates a pointer p to a integer. p = &x; //Sets p pointing to the address of variable x. *p = 4; //Changes the value that p points to equal to 4. cout << p; //Prints out the address that p points to. cout << *p; //Prints out the value in the block p points to (4).

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

View Full Document
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