BSCS1350-3
BSCS1350-3
1
Lecture Outline
• Introduction
• How a Program Works
• From Machine Language to Assembly Language
• High-Level Languages
• Key Words, Operators, and Syntax
• Compilers and Interpreters
• Designing a Program
• Pseudocode
• Flowcharts
• Class Exercise
Introduction
• Computers can be programmed:
• Designed to do any job that a program tells them to
5
How a Program Works
• Program must be copied from secondary memory to RAM each
time CPU executes it
Rectangles are
processing symbols
Ovals are
terminal symbols
Problem Solving – Example 1
• Problem: Add two numbers entered by the user.
Print sum
• Problem: Calculate the gross pay of an employee Initilise Hours =0, payrate = 0,
grossPay = 0
Step 1: write the algorithm (Pseudocode) Print “Enter hours
• Declare variable grossPay, Hours, PayRate worked (H) and hourly
pay rate (P)”
(process)
• Print “Enter hours worked and hourly pay Read hours worked (H)
Read hourly pay rate (P)
rate”
• Read hours worked (I/O)
grossPay = H*P
• Read hourly pay rate (I/O)
• Multiply hours worked by hourly pay rate and
Print grossPay
store in grossPay (process)
• Display grossPay (I/O)
End
Step 2: draw flowchart
Problem Solving – Example 4
• Problem: Check if the student passed or failed:
Read grade
YES NO
Is grade >= 60?
End
Flowcharts – Example 5 (Facebook Login)
36