Flow Charts
Flow Charts
Flow Charts
3.3 Example
Here is a very simple example:
Looking at the example above you could ask “Do I really need to create a plan for
such easy tasks? In practice – no, but when learning – yes. First of all, in practice
as a programmer you will not solve such easy tasks. These examples will be just
a very small fraction of the program. Then why do them? Because “you have to
learn to walk, before you start running”.
Step 1: Start
Step 4: Add num1 and num2 and assign the result to sum.
sum←num1+num2
Step 6: Stop
Step 1: Start
Step 4: If a>b
If a>c
Else
If b>c
Else
Step 5: Stop
Step 1: Start
D←b2-4ac
Step 4: If D≥0
r1←(-b+√D)/2a
r2←(-b-√D)/2a
Else
rp←b/2a
ip←√(-D)/2a
Step 5: Stop
Step 1: Start
factorial←1
i←1
5.1: factorial←factorial*i
5.2: i←i+1
Step 7: Stop
Step 1: Start
Step 2: Declare variables n,i,flag.
flag←1
i←2
flag←0
Go to step 6
5.2 i←i+1
Step 6: If flag=0
else
Display n is prime
Step 7: Stop
Step 1: Start
Step 2: Declare variables first_term,second_term and temp.
5.1: temp←second_term
5.3: first_term←temp
Step 6: Stop
Algorithm is not the computer code. Algorithm are just the instructions which
gives clear idea to write the computer code.
File: simple.c
1. #include <stdio.h>
2. {
3. void main()
4. printf("Hello ");
5. }
2) Expanded source code is sent to compiler which compiles the code and
converts it into assembly code.
3) The assembly code is sent to assembler which assembles the code and
converts it into object code. Now a simple.obj file is generated.
4) The object code is sent to linker which links it to the library such as header
files. Then it is converted into executable code. A simple.exe file is generated.
A linker is a computer program that takes one or more object files generated by
a compiler and combines them into one, executable program. Computer
programs are usually made up of multiple modules that span separate object
files, each being a compiled computer program.
5) The executable code is sent to loader which loads it into memory and then it
is executed. After execution, output is sent to console.