{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
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).
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern