Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP102 Lab 021 COMP 102 Programming Fundamentals I Presented by : Timture Choi.

Similar presentations


Presentation on theme: "COMP102 Lab 021 COMP 102 Programming Fundamentals I Presented by : Timture Choi."— Presentation transcript:

1 COMP102 Lab 021 COMP 102 Programming Fundamentals I Presented by : Timture Choi

2 COMP102 Lab 022 Software Development Process Requirement analysis Specifications Design and architecture Coding Testing Documentation Maintenance

3 COMP102 Lab 023 Arithmetic Operators + - * / Note: Precision problem  int/int -> int Truncates instead of round-off E.g. 3 / 2 => 1 % (modulus/remainder) E.g. 10 % 3 => 1

4 COMP102 Lab 024 Operator Precedence Evaluation order of operators ( ) *, / +, - Left associativity  Evaluate from left to right if same precedence E.g. (1 + 2) * 3 – 4 / 5 1. 1 + 2 => 3 2. 3 * 3 => 9 3. 4 / 5 => 0.8 4. 9 – 0.8 => 6.2

5 COMP102 Lab 025 Assignment Statement Syntax = ; E.g. a_var = (1 + 2) * 3 – 4 / 5;

6 COMP102 Lab 026 Assignment Conversions Implicit E.g.  float z = 2.7;  int y = 3;  y = z;// y will be set to 2 Explicit Syntax  var_1 = type (var_2);  var = type (expression); E.g.  int x = 1, y = 2;  double z;  z = double (x)/double (y);// z will be set to 0.5

7 COMP102 Lab 027 Standard I/O Include the “iostream” Input cin >> … Output cout << … Special output characters  \a  \t  \n  \\

8 COMP102 Lab 028 Structured Programming Subset of procedural programming Based upon the concept of procedure call  Procedure/routine/subroutines/method/function Removing or reducing reliance on the GOTO statement Often associated with top-down design approach An overview of the system is formulated Each part of the system is then refined by designing it in more detail Each new part may then be refined again Until the entire specification is detailed enough to validate the Model

9 COMP102 Lab 029 SUMMARY By the end of this lab, you should be able to: Use arithmetic operators Evaluate expression with standard operator precedence order Write assignment Identify rules of division Apply assignment conversions Employ standard I/O functions  cin / cout


Download ppt "COMP102 Lab 021 COMP 102 Programming Fundamentals I Presented by : Timture Choi."

Similar presentations


Ads by Google