Programming Languages - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Programming Languages

Description:

III Gen: Procedural languages. Basic, Fortran, Cobol, .... Compile Link ... Visual Basic. Event Driven Language. What to do under various events is specified ... – PowerPoint PPT presentation

Number of Views:51
Avg rating:3.0/5.0
Slides: 24
Provided by: longisland
Category:

less

Transcript and Presenter's Notes

Title: Programming Languages


1
  • Programming Languages
  • I Generation Machine Language
  • II Gen Assembly Language
  • III Gen Procedural languages
  • Basic, Fortran, Cobol, .
  • Compile ? Link Edit ? Execute
  • IV Gen PowerBuilder, HTML
  • Object Oriented ProgrammingC, Java, Small Talk

2
  • Object Information and operations that can be
    performed on that information.
  • Object Bank Account
  • Information 3,000 in the bank account
  • Operations Balance, withdraw, deposit
  • Object encapsulates (packages) data with
    operations.

3
  • Linking Applications
  • OLE Object Linking and Embedding
  • Linking Points to the object in another
    application
  • Embedding Copies the object of other application
    into this object.

4
  • Basic Programming
  • Early Language (60s)
  • Developed by undergrads
  • Easy
  • Small Set of Commands

5
.0
  • Procedural Languages
  • Before GUI
  • Execution of the program statements is from
    top to bottom
  • Text-based
  • Qbasic comes with M operating systems.

6
  • Visual Basic
  • Event Driven Language
  • What to do under various events is specified
  • Events Moves mouse, click a button,
  • double click, menu selection,
  • GUI
  • Users May not do things in the same order
  • Order of program execution is dictated by user.

7
VisualBasic
  • Event-Driven What the program does depends on
    user actions
  • User scrolls on Horizontal/vertical scroll bars
  • User clicks on a button
  • User checks a selection box. .
  • User Clicks on a command button.

8
  • Variables
  • Name must begin with a letter
  • In many programming languages length may be a
    restriction.
  • Short but mnemonic
  • No spaces in variable names. Use or _ to
    improve readability. Currentwages or
    current_wages but not current wages
  • Number1 for the amount invested may not be
    mnemonic. Principal is better.
  • Not a reserved word like print, input, end .

9
  • Variable Types
  • Integer (whole numbers -32768 to 32767)
  • Long (Larger whole numbers than above)
  • single (decimal numbers with 6 digits of
    accuracy)
  • double (decimal numbers with 14 digits of
    accuracy)
  • currency, Date
  • string (Alpha numeric data)
  • variant (any numeric)
  • Boolean (true or false)
  • You specify the variable type by
  • DIM my_variable as double

10
  • Assignment of a value to a variable and
    Arithmetic
  • Dim principal as double
  • Assignment of value
  • principal 100
  • Arithmetic add 10 to principal
  • principal principal 10

11
  • Arithmetic Operations
  • principal principal principal interest
  • This says multiply principal by interest and add
    to old principal and assign to principal
  • If values of principal is 1000 and interest is .2
    before the above statement is executed, the
    statement is equivalent to
  • Principal 1000 1000 .2
  • The vale of principal after execution of the
    statement is 1200

12
  • Order of Arithmetic
  • 2 4 10 ? 60 or 42?
  • - (negation) (exponentiation) ( /) ( -)
  • Comparisons
  • lt gt lt gt ltgt (lt and gt
    together)
  • Logical Comparisons
  • Not And Or XOR

13
  • Order of Arithmetic
  • Exercise 4 -2 8 5 / 2
  • Could be very confusing.
  • Use parentheses to specify order of arithmetic.
  • Stuff in parentheses are evaluated first.
  • If parentheses are nested, inner to outer set of
    parentheses.
  • Above operation can be written as
  • ((4 -2) 8) (5 / 2) 1/16 8 2.5 3

14
  • Decisions
  • If-Then-Else
  • Syntax
  • If condition Then true-task else false-task end
    if
  • If quantity gt 100 then price 4 else price 5
    end if
  • condition true-tak
    false-task
  • If prin gt 1000000 then print you are rich!
  • Why no ,? What does this do?

15
  • Program Flow
  • Usual program flow is from top to bottom, but it
    can be changed.
  • For .. Next Loop repeats execution of a group
    statements as many times as we need.
  • For index 1 to 1000
  • ..
  • ..
  • Next index
  • The statements .. Will be repeated 1,000 times.
  • The value of index will increase by 1 each time
    for statement is executed.

16
  • Program Flow
  • Do While Loop
  • Do While prin gt0 and prin lt 1000
  • .
  • .
  • Loop
  • How many times will the statements in the loop be
    executed? Depends!
  • Infinite Loop

17
  • Exercise 20 for first 100 units, 15 for
    additional units.
  • If units lt 100 then bill units 20 else bill
    10020 (units 100) 15

18
  • Same result can be accomplished many ways.
  • An alternative
  • If units gt 100 then bill 15 units 500
  • Else bill 20 units
  • End If

19
  • Exercise To add numbers 1 thru 10
  • For Next Loop
  • sum 0
  • for numb 1 to 10
  • sum sum numb
  • next numb
  • numb is an index. It starts at 1 and goes up to
    10. The value of it is increased by 1 every time
    for statement is executed.
  • First time thru the loop, numb is 1, next time 2,
  • How many times will the loop be executed?

20
Sum 0For numb 1 to 10sum sum numbNext
numb
21
  • Exercise
  • Compute FICA deductions.
  • FICA (Social Security) withholdings are 7.65 of
    your gross wages up to 72,600
  • Have cumulative to last paycheck (cum_wage) and
    current period gross income (gross_wage)
    available. Compute FICA deduction.
  • Write the code on a sheet of paper and turn it in
    with your name.

22
  • Flow Chart of FICA Problem

Gross Cum lt 72600
Fica .0765 gross
T
F
Cum gt 72600
Fica 0
T
F
Fica (72600- cum) .0765
23
  • Suggested Solution 1
  • If gross_wage cum_wage lt 72600 Then fica
    0.0765 gross_wage
  • If gross_wage cum_wage gt 72600 And cum_wage lt
    72600 Then fica (72600 - cum_wage) 0.0765
  • If cum_wage gt 72600 Then fica 0
  • Suggested Solution 2
  • If gross_wage cum_wage lt 72600 Then
  • fica 0.0765 gross_wage
  • ElseIf cum_wage gt 72600 Then
  • fica 0
  • Else fica (72600 - cum_wage) 0.0765
  • End If
  • Both of them give the same results.
Write a Comment
User Comments (0)
About PowerShow.com