discussion2

discussion2 - CS31: Introduction to Computer Science I...

Info iconThis 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 ( pwais@cs.ucla.edu ) Discussion Section 1L Information TA: Paul Wais ( pwais@cs.ucla.edu ) 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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. 2
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 note was uploaded on 07/06/2011 for the course CS 31 taught by Professor Melkanoff during the Spring '00 term at UCLA.

Page1 / 12

discussion2 - CS31: Introduction to Computer Science I...

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