programming language
programming language
programming language
Pseudo code
BEGIN
READ the values of A and B
COMPUTE C by multiplying A with B
PRINT the result C
END
Selection Logic
It is used for making decisions and for selecting the proper path
out of two or more alternative paths in program logic.
It is also known as decision logic.
Selection logic is depicted as either an IF..THEN or an IF…
THEN..ELSE Structure.
Example : Greatest of two numbers
BEGIN
READ the values of A and B
IF A is greater than B THEN
DISPLAY “A is greater”
ELSE
DISPLAY “B is greater”
END IF
END
Iteration Logic
BEGIN
GET the value of N
INITIALIZE I to 1
FOR I less than or equal to N DO
PRINT the value of I
INCREMENT I by 1
ENDFOR
END
Advantages
Main function:
Step1: Start
Step2: Get n
Step3: call factorial(n)
Step4: print fact
Step5: Stop
Functions
A function is a block of organized, reusable code that is used to perform a single, related
action. Functions provide better modularity for your application and a high degree of
code reusing.
Other Terms: methods, sub-routines , procedure
27
Functions:
28
Example:
29
30
The three building blocks are Sequence, Selection, and Iteration.
An Action is one or more instructions that the computer performs in sequential
order (from first to last).
Example: Compute 10 plus 30.
A Decision is making a choice among several actions.
Example: If value of A is greater than B, then print “A is Greater” otherwise
print “B is Greater”
A Loop is one or more instructions that the computer performs repeatedly.
Example: Print "HAVE A GOOD DAY" 50 times.
Sequence Action
Selection Decision
31
Programming Language
Programming Language
1. Machine language
2. Assembly language
3. High level language
Types of programming languages
1. Machine Level Language
Machine language is only understand by the
computers.
Data is represented in binary format (0s and 1s).
It is very difficult to understand by the human
beings.
Modifications and error fixing cannot be done.
Machine language is very difficult to memorize.
Machine Level Language
Execution is fast in machine language because all data is already
present in binary format.
Machine language is hardware dependent.
2. Assembly language
Algorithm
Step1 : Start
Step2 : Get A, B, C
Step3 : if (A > B) goto Step4 else goto Step5
Step4 : if (A > C) print A else print C
Step5 : if (B > C) print B else print C
Step6 : Stop
To check greatest of three numbers
Pseudocode
BEGIN ELSE
READ a, b, c IF(b>c) THEN
IF (a>b) THEN DISPLAY b is greater
IF(a>c) THEN ELSE
DISPLAY a is greater DISPLAY c is greater
ELSE END IF
DISPLAY c is greater END IF
END IF END
To check greatest of three numbers
Flowchart