Review for Midterm Exam CSCI 1380 Contents 5

  • Slides: 10
Download presentation
Review for Midterm Exam CSCI 1380

Review for Midterm Exam CSCI 1380

Contents • 5 questions (20 points each) + 1 bonus question (20 points) –

Contents • 5 questions (20 points each) + 1 bonus question (20 points) – Chapters 1~4 • Question types – Write down the output of the code – Write the code – Debug errors in the code • Review – Lecture slides – Exercises (1)~(5) in class (on the course Web page) – Review problems 2

Time & Place & Event • 5: 45 pm ~ 7: 00 pm, Feb.

Time & Place & Event • 5: 45 pm ~ 7: 00 pm, Feb. 28, Thursday • ACAS 2. 110 • Closed-book exam – You can take a piece of cheating paper with A 4 size – Write down whatever that you think is important (on both sides) with any font size 3

Chapter 1: An Overview of Computers and Programming Languages • Computer system has hardware

Chapter 1: An Overview of Computers and Programming Languages • Computer system has hardware and software • Various kinds of languages, such as machine language, assembly, high-level • Algorithm: step-by-step problem-solving process; solution in finite amount of time • Object-oriented design (OOD): a program is a collection of interacting objects – C++ is an object-oriented programming language 4

Chapter 2: Basic Elements of C++ • Special symbols, keywords, rules of identifiers •

Chapter 2: Basic Elements of C++ • Special symbols, keywords, rules of identifiers • Basic data types – int, float, double, char, string • Operators – Arithmetic operators and their precedence • +, -, *, /, %, +=, -=, *=, /= – Increment/decrement operator • ++, -- • Declaration of variables – int first=13, second=10; – char ch=' '; • Input/Output statement – cin and cout 5

Chapter 3: Input/Output • Declaration of input/output stream • Usage of cin and cout

Chapter 3: Input/Output • Declaration of input/output stream • Usage of cin and cout (as well as other istream/ostream variables) • The stream extraction operator, cin>> – Syntax and meaning of functions • • • cin. get(var. Char); cin. ignore(int. Exp, ch. Exp); cin. putback(ch) cin. peek(ch) getline(cin, str); – See examples in lecture slides 6

Chapter 3: Input/Output (cont'd) • The stream insertion operator, cout<< – endl – setprecision,

Chapter 3: Input/Output (cont'd) • The stream insertion operator, cout<< – endl – setprecision, showpoint, setw, setfill • File stream – Header: fstream 7

Chapter 4: Control Structures I (Selection) • Relational operators and precedence – Comparison operators

Chapter 4: Control Structures I (Selection) • Relational operators and precedence – Comparison operators • <, <=, >, >=, ==, != • String comparison – Logical operators • &&, | | • Evaluation of logical expression – See examples in lecture slides 8

Chapter 4: Control Structures I (Selection, cont'd) • Syntax and usage of the selection

Chapter 4: Control Structures I (Selection, cont'd) • Syntax and usage of the selection structure – One-way selection: if () { } • Compound statements – Two-way selection: if () { } else { } – Multi-way selection: switch () { } – Nested if statement – See examples in lecture slides 9

Good Luck! Q/A

Good Luck! Q/A