{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

discussion2

discussion2 - CS31 Introduction to Computer Science I...

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

View Full Document Right Arrow Icon
CS31: Introduction to Computer Science I Discussion 2 April 8, 2011 TA: Paul Wais ( [email protected] ) Discussion Section 1L Information TA: Paul Wais ( [email protected] ) NEW Office Hours: Thursdays 11:30am - 1:30pm in Boelter Hall 2432 Discusion Website: http://www.cs.ucla.edu/ ˜ pwais Notes and other resources will be posted on the Discussion Website. If you would like to meet me outside of the posted office hours, please email me. Also, if you’d like for me to cover something specific during discussion section, please send me email. If there is anything I can do to improve Discussion Section, please feel free to let me know. Announcements Office Hours have changed! Please see above. I’m still happy to meet you on Tuesday if you wish. Please also note the following important dates: The Midterm Exam is Wednesday, May 4th, from 10am-11:50am (in class). The Final Exam is Saturday, June 4th, from 3pm-6pm. Questions of the Week Why do we have to escape the question mark? On Savich pg. 18, the textbook claims that \? is the proper escape sequence for the ? symbol. For most purposes in this class, we’ll use ? instead of ’\?’ . When one writes a sequence of two question marks in a string, i.e. ?? , the compiler may interpret these question marks as the beginning of a trigraph , which is a special sequence of characters that the compiler interprets in special ways. For example, the compiler interprets ??> as a literal } character. One uses the escape sequence \? to tell the compiler that one wants a question mark rather than a trigraph. For more information, see: http://msdn.microsoft.com/en-us/library/bt0y4awe(v=vs.80).aspx 1
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
What does cout.setf(ios::showpoint); do?(!) In class we used the following code to control the formatting of how cout prints floating point numbers: #include <iostream> using namespace std; int main() { double x = 123.45600; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout << x << endl; } The above program prints 123.46 to the terminal. The ios::showpoint option forces a decimal point to appear in the output. There are other options such as ios::scientific that cause output to appear in scientific notation; using this option instead of ios::showpoint will make the above program print 1.2e+02 . For a full list of options, try to find the file ios_base.h on your system. Proper Identifier Names Quiz: Which of the following are valid identifier names? volume VALID camelCase5 VALID 5guysBurgerFries INVALID _private_variable VALID __private_variable VALID %kitten INVALID Nota bene: identifiers (e.g. variable names) must begin with a letter or an underscore. 1 1 Why an underscore? Typically only large programs use variable names that begin with an underscore. A leading underscore variable signals to software maintainers that the variable has very special meaning and should be treated with care if ever changed.
Image of page 2
Image of page 3
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