Professional Documents
Culture Documents
Logic 102 and 103
Logic 102 and 103
Logic 102 and 103
PROGRAMMING LOGIC
Dr Upasana G Singh
1
COMPILERS • « accueillir à la programmation » -
• A computer cannot understand
our language
Source code
(Programming
• 01010101 01001011 01011010
language: 01001110 any guesses?
human • We cannot understand binary
readable) language
• Instructions in a programming
Executable code language (e.g. JavaScript,
(Machine VBScript, Pascal, C++) which we
readable)
learn, then the compiler converts
it into structured language that
Programming Logic (2018) - Dr UG Singh
the computer can understand.
3
INTERPRETER • An interpreter interprets
instructions and converts them
to an intermediate form for
immediate execution.
• Main advantages over a compiler:
High level
instructions – It can be tailored to a specific
programming language
– It allows program
implementation to be
Intermediate independent of the
form characteristics of the host CPU
• The main disadvantage is speed
Algorithm is a set of
steps that are
performed to solve a
problem. The example
describes an algorithm
Programming Logic (2018) - Dr UG Singh
9
THE
FLOWCHART
AND ITS
SYMBOLS
BEGIN
INPUT NUMBER
R = NUMBER/2
IF R = 0
THEN DISPLAY “NUMBER IS EVEN”
ELSE
DISPLAY “NUMBER IS ODD”
END
IN P U T n u m
FLOWCHART:
THE ‘IF’
CONSTRUCT
r = n u m M OD 2
No
r =0
Yes
D IS P L AY "N u m b e r i s E ve n "
BEGIN
INPUT NUMBER
R = NUMBER/2
IF R = 0
THEN DISPLAY “NUMBER IS EVEN”
ELSE
DISPLAY “NUMBER IS ODD”
ENDIF
END
IN P U T n u m
r = n um M O D 2
Yes No
r = 0
S TOP
BEGIN
INPUT Years
INPUT Transactions
IF Years >= 10 AND Transactions >=5000000
DISPLAY “Classified as an Gold status customer”
ELSE
DISPLAY “Target not met”
END IF Multiple
END Criteria
AND/OR
Programming Logic (2018) - Dr UG Singh
27
START
INPUT Years
INPUT Transactions
Years >= 10
AND
YES NO
Transactions
> 5000000
STOP
START
INPUT Years
INPUT Transactions
STOP
Programming Logic (2018) - Dr UG Singh
30
S TA R T
LOOPS
cn t=0
BEGIN No
cnt=0 cn t < 1 0 0 0
cnt=cnt+1
END DO cn t=c n t+1
END
S TOP