Programming Notes111updated
Programming Notes111updated
Programming Notes111updated
Programming
DEFINITIONS
Program Language
DEFINITIONS
Program
DEFINITIONS
Program Language
a standardized communication technique for
expressing instructions to a computer. Like
human languages, each language has its own
syntax and grammar.
enable a programmer specify precisely what
data a computer will act upon, how these data
will be stored/transmitted, and precisely what
actions to take under various circumstances.
CATEGORIES OF PROGRAMMING
LANGUAGES
High Level
Low Level
READY!!
COBOL, Pascal,
Fortran, C++, BASIC,
There are many more
Which one will we be
using in class?
Who is Pascal? Do a
research on him now?
Blaise Pascal, French
Mathematician, He
invented the first
adding machine called
Pascaline.
CATEGORIES OF PROGRAMMING
LANGUAGES?
Low Level
High Level
Low Level
Machine dependent
Difficult for programmers to write
Execute machine instructions quickly
HIGH LEVEL
GENERATION OF PROGRAMMING
LANGUAGES
First
Second
Third
Fourth
Fifth
http://passcisa.blogspot.com/2008/09/fivegenerations-of-programming.html
http://www.computerhope.com/jargon/num/1gl.
htm
http://learningarea5.blogspot.com
http://passcisa.blogspot.com/2008/
09/five-generations-of-programming
.html
,
http://www.computerhope.com/jar
gon/num/1gl.htm
,
http://learningarea5.blogspot.com
FIRST GENERATION
Low level
Machine language/machine code/
Binary
SECOND GENERATION
Low level
Assembly language
THIRD GENERATION
High level
Use of English like statements
Examples:
Pascal
Cobol (Common Business Oriented Language)
BASIC (Beginners All Purpose Symbolic
Instruction Code)
C
Fortran(Formula Translation)
FOURTH GENERATION
High level
Similar to third generation and even easier to
use
user friendly offer extra help through
prompts, wizards and instructions
examples
Structured Query Language(SQL)
Visual Basic
C++
Oracle report
FIFTH GENERATION
TRANSLATION PROGRAMS
Compiler
Interpreter
Assembler
TRANSLATION PROGRAMS
TRANSLATION PROGRAMS
Interpreter is a program
that translated each line
of high level language
code into machine code
one line at a time
TRANSLATION PROGRAMS
Assembler is a program
that translates assembly
language code into
machine code
Source
Code
Compiler
Interpreter
Translator
Object
Code
Machine
Language
Flow chart
Used to illustrate data, information
and workflow by interconnection of
specialized symbol with flow lines.
The combination of symbols and
flow lines portray the logic of the
program. Each symbol indicates the
type of operation to be performed and
the flowchart graphically illustrates the
sequence in which the operations are to
be performed
Pseudocode
It represents the logic in program-like
statement written in a language you can
express the logical flow of the program.
PSEUDOCODE
Advantages:
It is easy to use and create
Very little specific syntax is required
Helps to focus on the logic of the program
which reduces the time spent in coding,
testing and debugging systems
ALGORITHM
INPUT STATEMENT
TYPES OF VARIABLES
Integer
Real
String
Constant is a value in a pseudocode that does
not change
Identifier is the name invented by a
programmer for a data item. An identifier
can be a variable or a constant.
Write a pseudocode to read input into two
variables A and B.
ASSIGNMENT STATEMENT
ASSIGNMENT STATEMENT
Rules
information between double quotation will be
printed as is
when a variable is used in a print statement the
content of the variable is printed
Variables are not included between quotes but
separated from the quoted information by comma.
III.
PRACTICE QUESTIONS
1. Prompt
2.
3. prompt
the
the user to enter the prices for two different pay per
view movies. Calculate the amount due and output it with
the following message: Amount due BCC Television Ltd
4. Prompt the user to input the number of days in a month.
Calculate and print the number of hours in the month
appropriately labelled.
ASSIGNMENT
CONTROL STATEMENTS
Used to conceptualize the program logic
Types
Sequence the processing steps are
performed in order one after another
Selection depicts the logic for selecting the
appropriate sequence of statements
Iteration/repetition/loop used to represent
the program logic when a portion of the
program is executed repeatedly until a
particular condition is met
CONTROL STATEMENTS
Selection:
If condition Then If condition Then
statement (action)
statement (action)
End If
Else
statement (action)
End If
QUESTIONS
PRACTICE QUESTIONS
1.
2.
3.
4.
5.
6.
7.
8.
9.
WORKED EXAMPLE
Design a structured algorithm that
ask the user to input two numbers.
The algorithm should accept the
numbers and calculate their sum and
average. Output the results with
suitable labels.
PSEUDOCODE
Start
PRINT Enter your first number
READ num_1
PRINT Enter your second number
READ num_2
PSEUDOCODE
Sum
Avg
num_1
CONTD
+ num_2
Sum / 2
PASCAL CODE
Program Calculate;
Uses
wincrt;
Var
PASCAL CODE
CONTD
Begin
Read (Num1);
PASCAL CODE
CONTD
End.
PSEUDOCODE
Start
Print Enter school fee
Read Fee
Print Enter Numbers of days
Read days
If days < 30 Then
Discount Fee * 10%
End if
NewFeeFee Discount
Program Schoolfee;
Uses
wincrt;
Var
days: Integer;
fee,discount,newfee:Real;
Begin
Writeln ('Enter school fee paid ');
Read (fee);
Writeln ('Enter number of days ');
Readln (days);
');