Presentation is loading. Please wait.

Presentation is loading. Please wait.

Admin Office hours 2:45-3:15 today due to department meeting if you change email addresses during the semester, please unsubscribe the old one from the.

Similar presentations


Presentation on theme: "Admin Office hours 2:45-3:15 today due to department meeting if you change email addresses during the semester, please unsubscribe the old one from the."— Presentation transcript:

1 Admin Office hours 2:45-3:15 today due to department meeting if you change email addresses during the semester, please unsubscribe the old one from the mailing list cable students who can't come at regular time need to arrange a time to take the exam (on campus)

2 CS 117 Spring 2002 Review for Exam 1 Feb 6, 2002 open book, 1 page of notes

3 Material Covered Hanly –Chapter 1 –Chapter 2 –Chapter 3 Sections 1-2 Friedman-Kaufman –Chapter 1 –Chapter 2 –Chapter 3 Section 2 –Chapter 4 Sections 1-3

4 Review Problems Hanly Page 45 problems 1, 2 Page 50 problem 4 Page 55 problems 1-4 Page 60 problems 1-2 Page Problems 1-2 Friedman-Kaufman Page 48 problems 1, 3 Page 56 problems 3-5 Page 65 problems 1, 3, 4 Page 81 problems 2, 5-7 Page 93 Quick Check 1-5 Page 95 questions 2, 4, 7, 8, 11, 12 Page 118 problem 1 Page 181 problems 1, 2; programs 1, 2 Page 186 problem 1-2

5 Basic Programming Concepts Input and Output Types Declarations Operators Arithmetic expressions and evaluation math functions

6 General Syntax #include for libraries End a statement with a semicolon Comments –// for one line comments –/* …*/ for multi-line comments legal variable names –letters, digits and underscore –no initial digit

7 More Syntax Reserved words (keywords) –int, double, void –const –return –if, else Symbols –+ * / % // /* */ = {} ()

8 Input and Output include iostream input –cin is standard input stream - keyboard –>> extracts data from input stream and stores in variables output –cout is standard output stream - monitor screen –<< inserts data into the output stream

9 Types int - whole numbers double - real or floating point numbers –1.2e-3 used for scientific notation char - single character bool - true or false string - for text strings

10 Literals int23 double1.23, 4.56e-78 char'g', '9', '\n' booltrue, false string"this is a string", ""

11 string class include string declare as usual –string name; initialize when declared –string word( "the word"); –string text = "some text":

12 string class assign a value –name = "your name"; –name = text; input –get one word (whitespace delimited) with >> cin >> text; –get whole line with getline getline( cin, name); output –use << as you do for other types

13 Variables variables provide a way to store and access data assign values using = constants are variables which don't change

14 Declarations set aside memory for variable(s) –type followed by one or more variable names separated by commas int i; double x, y; –can be initialized when declared char quit = 'q'; –can be declared constant const double PI = 3.24159;

15 Operators + addition -subtraction, negation (unary) *multiplication /division –integer division discards remainder % modulus (int only)

16 Boolean Operators Comparison: = > Logical –!NOT –&&AND –||OR

17 Expressions Valid combination of variables and operators –a –a + b –a + b * c –!p –p && q –x <= y

18 Expression Type int for two integers double for one or two doubles bool for comparison and logical operators

19 Precedence parenthesized expressions unary operators: - ! * / % + - (binary) comparisons >= == != && || =

20 math.h Collection of mathematical functions –sqrtsquare root –sin, cos, …trig functions –expe x –log, log10log functions –pow(x, y)power xy –abs, fabsabsolute value

21 Selection selective execution of parts of the program if if (condition) statement; condition is a boolean expression statement is single statement or block of statements enclosed by {}


Download ppt "Admin Office hours 2:45-3:15 today due to department meeting if you change email addresses during the semester, please unsubscribe the old one from the."

Similar presentations


Ads by Google