COMP 102 Programming Fundamentals I - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

COMP 102 Programming Fundamentals I

Description:

COMP 102 Lab 02 (Part II) 4. Operator Precedence. Evaluation order of operators ... var = type (expression); E.g. int x = 1, y = 2; double z; ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 10
Provided by: typey73
Category:

less

Transcript and Presenter's Notes

Title: COMP 102 Programming Fundamentals I


1
COMP 102Programming Fundamentals I
  • Presented by Timture Choi

2
Software Development Process
  • Requirement analysis
  • Specifications
  • Design and architecture
  • Coding
  • Testing
  • Documentation
  • Maintenance

3
Arithmetic Operators
  • -
  • /
  • Note Precision problem
  • int/int -gt int
  • Truncates instead of round-off
  • E.g. 3 / 2 gt 1
  • (modulus/remainder)
  • E.g. 10 3 gt 1

4
Operator Precedence
  • Evaluation order of operators
  • ( )
  • , /
  • , -
  • Left associativity
  • Evaluate from left to right if same precedence
  • E.g.
  • (1 2) 3 4 / 5
  • 1 2 gt 3
  • 3 3 gt 9
  • 4 / 5 gt 0.8
  • 9 0.8 gt 6.2

5
Assignment Statement
  • Syntax
  • ltidentifiergt ltexpressiongt
  • E.g.
  • a_var (1 2) 3 4 / 5

6
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
Standard I/O
  • Include the iostream
  • Input
  • cin gtgt
  • Output
  • cout ltlt
  • Special output characters
  • \a
  • \t
  • \n
  • \\

8
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
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
Write a Comment
User Comments (0)
About PowerShow.com