Lec26 - THE FINAL LECTURE: Fifty Minute Review PIC 10A Todd...

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

View Full Document Right Arrow Icon
1 THE FINAL LECTURE: Fifty Minute Review PIC 10A Todd Wittman A Look Back. .. s Take a moment to reflect on all you’ve accomplished this semester. HW1 : Cash register HW6 : Triangle Class HW2 : Ratio calculator HW7 : War Game HW3 : Tic-tac-toe HW8 : Blackjack HW4 : Valentine's cartoon HW9 : Elvish Translator HW5 : Interactive Map s Be sure to send your .exe files to your family!
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Final Exam s Sunday March 15th s 3:00-6:00 s Young Hall 76 s The final exam is worth 30% of your grade, same weight as 2 midterms. s Length is also roughly 2 midterms (2 hrs). s Very similar in style to practice exams and midterms. s Half short-answer, half long-answer. s Exam cover Ch. 1-10 + Sec 12.1 s Emphasis on material covered since last exam. s Remember to bring your student ID. Ch. 1: The Simple Program s Recall the first C++ program you wrote: #include <iostream> using namespace std; int main ( ) { cout << "Hello Middle Earth!\n"; return 0; }
Background image of page 2
3 Ch.2: Data Types s In C++, you can't use a variable until you declare its type. int x=-10; double y=3.2; char c = 'h'; s You can temporarily change a type by casting. s Remember casting a double to int chops the decimal. int a = 2; int b = 3; double c = (double) a / b; //Stores z = 0.666667 int d = (int) c; //Stores d=0. s You have to be comfortable with arithmetic operations. + - * / % s Remember dividing integers gives an integer. s The mod operator % gives the remainder after division s Other operations in <cmath> : sqrt, pow, sin, cos Ch. 2: Input/Output (I/O) s Our console I/O is defined in <iostream> . s Basic output: cout << x; Basic input: cin >> x; s Watch the arrows! s Remember the basic escape characters. b \n new line \t tab b \\ backslash \" double quote s Remember spaces won't show unless you put them there s We can chain the push/pulls. cin >> x >> y >> z; cout << " 2+2 = " << 2+2 << "\n"; s Get an entire line in string s: getline(cin,s); s Get one character in char c: cin.get(c); //Used in HW9.
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Ch. 2: I/O Formatting s The <iomanip> library has functions for formatting your output. s setw(N) -- puts the next push into a box of width N, right justified. cout << setw(10) << "2+2=" << 4;
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/19/2011 for the course PIC 10A taught by Professor Wittman during the Fall '08 term at UCLA.

Page1 / 10

Lec26 - THE FINAL LECTURE: Fifty Minute Review PIC 10A Todd...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online