AERO 220 Introduction to Aerospace Engineering Computation - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

AERO 220 Introduction to Aerospace Engineering Computation

Description:

Time: Tuesdays and Thursdays,11:10 AM 12:25 PM. Place: SSC 102 B. http: ... C 's built-in ... 3.45 is called the mantissa. 6 is called the exponent ... – PowerPoint PPT presentation

Number of Views:73
Avg rating:3.0/5.0
Slides: 19
Provided by: Kau66
Category:

less

Transcript and Presenter's Notes

Title: AERO 220 Introduction to Aerospace Engineering Computation


1
AERO 220 Introduction to Aerospace Engineering
Computation
Meetings Time Tuesdays and Thursdays,1110 AM
1225 PM Place SSC 102 B http//imechanica.org/n
ode/6727 9/10/09
2
Objectives
  • Variables
  • Cs built-in integer type char and bool
  • Cs built-in floating point types (float,
    double and long double)
  • The cfloat file
  • Numeric constants of floating-point type
  • Arithmetic operators and type conversion

3
The char and bool types
  • char type is to store characters, such as letters
    and digits
  • Number code for characters
  • char type is another integer type, typically
    smaller than short
  • bool variables represent either true or false
  • bool isready true
  • int ans true // ans assigned 1
  • int promise false // promise assigned 0

4
The ASCII Character set
Extended ASCII Character Chart
American Standard Code for Information
Interchange (ASCII) See appendix c of the test
book
http//www.rtis.com/nat/user/toolbox/oldmacs/MacEu
doraManual/man151172.GIF
5
(No Transcript)
6
The const qualifier
  • Symbolic name for constants
  • const int MONTHS 12 // MONTHS is the symbolic
    constant for 12
  • General form for creating a constant
  • const type name value
  • const int toes // value of toes undefined at
    this point
  • toes 10 // too late!

7
Floating-point number
  • Represents number with a fractional part
  • For example 2.5, 3.14159 and 122245.6567
  • Writing floating point number
  • Standard decimal-point notation
  • 12.34
  • 0.003
  • 8.0
  • E notation
  • 5.37E16 ( 5.37x1016)
  • 2.53e8 (can use E or e)
  • 7E5 (same as 7.0E5, is a floating point
    number even if no decimal point is used)
  • 8.33e-4 (exponent can be negative)

8
Floating-point number and floating point types
  • 3.45E6 3.4x106
  • 3.45 is called the mantissa
  • 6 is called the exponent
  • Floating point types
  • float (at least 32 bits)
  • double (at least 48 bits)
  • long double (at least 48 bits)
  • Always use double!
  • cfloat header file

9
Floating point constants
  • 1.234f // a float
  • 3.45e5 //a double
  • 2.345E5 // a double
  • 4.56L // a long double (dont use lower case L )

10
(No Transcript)
11
(No Transcript)
12
C Arithmetic operators
  • C a b
  • a b is an expression
  • a and b are operands, is the operator
  • Five basic operators
  • The operator (add)
  • The operator (subtract)
  • The operator (multiplication)
  • The / operator (division)
  • The operator (modulus operator), produces the
    reminder of dividing the first by the second
    operands. E.g., 19 6 is 1. Operands must be
    integers.

13
Operator precedence and associativity
  • int flyingpings 3 4 5 // flyingpings 23
    or 35?
  • float logs 120 / 4 5 // longs 150 or 6?
  • int dues 20 5 24 6

14
(No Transcript)
15
Modulus operator
16
Type conversion
  • Assigning a value to a type with a greater range
    usually poses no problem
  • long so_long
  • short thirty
  • So_long thirty // assigning a short to a long

17
Type conversion
18
Type casts
  • General form
  • typeName (value)
  • Examples
  • int number
  • number int (19.99) int (11.99)
Write a Comment
User Comments (0)
About PowerShow.com