Professional Documents
Culture Documents
A computer follows the instructions given by the programmer to perform a specific job or task.
To perform a particular task, programmer prepares a sequence of instructions, known as
programs. A program written for a computer is called a computer program. Computer
programs also called software or applications are stored inside the RAM. The CPU takes one
instruction of the program at a time from the RAM and executes it. The instructions are executed
one by one in sequence and finally produce the desired result. The process or act of
writing/creating programs is called programming (also called scripting) and person who write
this programs is called a programmer (or software developer/designer).
Program can be divided into two forms syntax and semantics. Syntax means the structure
and/or flow of the program. Semantics indicates the meaning of the syntax.
Programming languages
A programming language is a language for writing programs for a computer.
Computer programming languages are any of various languages for expressing a
set of detailed instructions for a digital computer. Programming languages are
mainly used to control the performance of a computer or to express algorithms. At
present, there are thousands of programming languages have been implemented.
General speaking, we can classify programming languages into two categories:
Low-level programming languages and High-level programming languages.
1. Low-level programming languages, LLL: are those which require a
programmers to manage explicitly all of a computer’s characteristic features of
data storage and operation, i.e., the programmer has to know the architecture of the
computer. We have two types of low-level programming languages the machine
language and assembly language.
Algorithm:
Step1: Start
Step2: insert radius
Step3: calculate Area=radius*radius*3.145
Step4: print Area
Step5: end process
Flowchart:
Example 2: Write an algorithm and draw a flow chart to calculate 24.
Algorithm:
Step1:1 start
Step 2: Input Base (2), Power (4)
Step 3: Product= Base
Step 4: Product = Product * Base
Step 5: Product = Product * Base
Step 6: Product = Product * Base
Step 7: Print Product
Step 8: end process
FLOW CHART:
• Question: What happens if you want to calculate 2 to the power of 1000 (21000)
• Answer: Use a LOOP (repeated execution of the same set of instructions)
Example 3: Write an algorithm and draw a flow chart to calculate Nm using a loop
approach?
Algorithm:
Step1: Start
Step 2: Input Base (N), Power (m)
Step 3: Product = Base
Step 4: Counter = 1
Step 5: While (Counter < Power)
Repeat steps 6 through step 7
Step 6: Product = Product * Base
Step 7: Counter = Counter + 1
Step 8: Print Product step9: End process
Flowchart:
Example 5: write Algorithm and draw Flowchart to find the greater number
between two numbers?
Algorithm
Step1:1 start
Step 2: input two number(x,y)
Step 3: if(x>Y) display step4
Else display step5
Step 4: x is greater than y
Step 5: y is greater than x
Step 6: end process
Flowchart
Example 6: write Algorithm and draw Flowchart to find the greater number
between three numbers?
Algorithm
Step1:1 start
Step 2: input three number(x, y, z)
Step 3: if(x>y) go to step4
Else go to step 5
Step 4: else-if(x>z) display step6
Else display step 7
Step 5: else-if(y>z) display step8
Else display step9
Step 6: x is greater than all
Step7: z is greater than all
Step8: y is greater than all
Step9: z is greater than all
Step10: end process
Flowchart:
Example 7: Flowchart to calculate the average from 25 exam scores?
Example8: The algorithm and flowchart sums all the even numbers between 1 and 20
inclusive and then displays the sum.
Algorithm
Step1: start
Step2: sum = 0, count=1
Step3: if (count%2==0) go to and repeat step4and step5
Else go to step6
Step4: sum=sum+count
Step5: count=count+1
Step6: count=count+1 go to step3
Step7: print sum
Step8: end process
Flowchart