Professional Documents
Culture Documents
CSE 1062 Fundamentals of Programming Lecture #5: Spring 2017
CSE 1062 Fundamentals of Programming Lecture #5: Spring 2017
Lecture #5
Spring 2017
Reading assignment
– Chapter 3 of the textbook
– Chapter 6 of the textbook
– Read about
• Function Overloading
• Default Arguments
2
Formatting Numbers for Program Output ASTU
4
Formatting Numbers for Program Output ASTU
5
Formatting Numbers for Program Output ASTU
6
Using Mathematical Library Functions ASTU
8
Using Mathematical Library Functions ASTU
9
Using Mathematical Library Functions ASTU
10
Program Input Using cin ASTU
12
Program Input Using cin ASTU
13
Program Input Using cin ASTU
14
Program Input Using cin ASTU
15
Case Study: Acid Rain ASTU
16
Case Study: Acid Rain ASTU
17
Case Study: Acid Rain ASTU
18
Case Study: Acid Rain ASTU
19
Case Study: Acid Rain ASTU
20
Case Study: Acid Rain ASTU
21
Case Study: Acid Rain ASTU
22
Step 1: Analyze the Problem ASTU
23
Step 2: Develop a Solution ASTU
24
Step 3: Code the Solution ASTU
25
Step 4: Test and Correct the Program ASTU
• First test
• Second test
• Think about
validating the user
input so that the pH
level becomes
between 0 and 14
– We need selection
statements
26
Symbolic (Named) Constants ASTU
27
Case Study: Length Conversion ASTU
28
Step 1: Analyze the Problem ASTU
29
Step 2: Develop a Solution ASTU
30
Step 3: Coding ASTU
31
Function and Parameter Declarations ASTU
32
ASTU
33
Calling a Function ASTU
34
Calling a Function ASTU
35
Calling a Function ASTU
36
Defining a Function ASTU
37
Defining and Calling Functions ASTU
38
Placement of Statements ASTU
39
Empty Parameter List ASTU
40
Returning a Value ASTU
41
Pass By Value and Pass By Reference ASTU
42
Pass By Value and Pass By Reference ASTU
43
Pass By Value and Pass By Reference ASTU
44
Pass By Value and Pass By Reference ASTU
45
Pass By Value and Pass By Reference ASTU
46
Pass By Value and Pass By Reference ASTU
47
Case Study: Rect. to Polar Coord. Conversion ASTU
48
Case Study: Rect. to Polar Coord. Conversion ASTU
49
Step 1: Define a Problem ASTU
50
Step 1: Define a Problem ASTU
𝜃 = tan−1 𝑦Τ𝑥 ; 𝑥 ≠ 0
51
Step 1: Define a Problem ASTU
52
Step 1: Define a Problem ASTU
• Initial Coding
53
Step 2: Test the Function ASTU
r=5
angle=53.1301 54
Step 3: Complete the Program ASTU
55
The Complete Program ASTU
56
The Complete Program ASTU
57
Variable Scope ASTU
58
Variable Scope ASTU
59
Variable Scope ASTU
60
Scope Resolution Operator ASTU
61
Misuse of Globals ASTU
62
Lifetime of Variables ASTU
64
Local Variable Storage Categories ASTU
65
Local Automatic Variable ASTU
66
Local Static Variable ASTU
67
Global Variable Storage Categories ASTU