AERO 220 Introduction to Aerospace Engineering Computation - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

AERO 220 Introduction to Aerospace Engineering Computation

Description:

Rules for naming C variables ... Calculation of Square Root via Bisection. Estimation of Pi by Throwing Darts (read the handout) ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 14
Provided by: kaush8
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/17/09
2
Review
  • Variables
  • Rules for naming C variables
  • Cs built-in integer types (unsigned long,
    long, unsigned short, short, unsigned int, int,
    unsigned char, char and bool)
  • The climits file
  • Numeric constants
  • const qualifiers

3
Review
  • 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
  • if-else construct

4
Case conversion
  • int main()
  • char inputchar, outputchar
  • ..
  • cin gtgt inputchar
  • ..
  • if (inputchar gt 64 inputchar lt 91)
  • // the inputchar is uppercase. Change it to
    lowercase
  • else
  • // the inputchar is lowercase. Change it to
    uppercase
  • return 0

5
The ASCII Character set
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
6
Flow chart
http//www.tenouk.com/Module6_files/programcontrol
001.png
7
The for loop
  • Declare an integer variable, j and set an initial
    value to -4, j -4.
  • Check the condition for j, j lt 0 true or false?
  • Print the js value.
  • Increment j by 1.
  • Repeat the iteration process until j lt 0 is
    false.
  • If the condition jlt0 is false, stop exit the
    loop and continue the execution of the next code
    if any.

8
The for loop
  • for(initial value condition iteration)
  •    //   C/C statement(s)

9
  • void main()
  •       int j
  •      
  •       for(j-4 j lt 0 jj1 )
  •      
  •             coutltltjltltendl
  •      

10
The break statement
  • void main()
  •       int j
  •      
  •       for(j-4 j lt 0 jj1 )
  •      
  •             coutltltjltltendl
  • if (condition)
  • break
  •      

If condition is true then go out of the loop
11
Start
Define integer variables i, minInteger,
maxInteger and thegauss Define a character
variable reply
Input variables minInteger and maxInteger
Guessing an integer within a given range
Initialize i 1
False
i lt 100 ?
True
Display variables minInteger and maxInteger
theguess (minmax)/2
Display theguess Ask the user if the guess is
small (s), big (b) or correct (r) Input reply
C
B
A
12
A
C
B
Display you are correct and break from the loop
reply r ?
True
False
reply s ?
True
minInteger theguess
i i 1
False
reply b ?
True
maxInteger theguess
False
End
13
  • Calculation of Square Root via Bisection
  • Estimation of Pi by Throwing Darts
  • (read the handout)
Write a Comment
User Comments (0)
About PowerShow.com