Programming structures or Logic in QBASIC
Following are the three types of flowchart structures.
a) Sequence structure
b) Selection/conditional structure
c) Looping /Iteration structure
a) Sequence Structure:
A sequential structure is a logic
that executes statements one after another sequentially from top to bottom.
Syntax:
b) Selection/ Conditional structure:
A selection structure is a logic
that depends upon a condition and makes a choice between two alternate paths.
Syntax:
Example: To check whether result is pass or fail. (Assume pass percentage is 40)
c) Looping / Iteration Structure:
The looping structure is used
when one or more instructions may be executed several times depending on some
conditions.
We can pass loop structure in two
ways.
Syntax:
Some examples:
STEP –
1 Start
STEP –
2 Input first subject marks
STEP –
3 Input second subject marks
STEP –
4 Input third subject marks.
STEP – 5 Calculate the total of all 3 subjects
STEP – 6 Calculate average by dividing total by 3
STEP –
7 End
Flowchart:
Algorithm:
STEP 1: Start
STEP 2: Input any three numbers
STEP 3: If a>b then
If a>c then
Print “a” is greatest
Else
Print “c” is greatest
Else
If b>c then
Print “B” is greatest
Else
Print
“c” is greatest
STEP 4: End
Flowchart:
Algorithm
STEP-1: Start
STEP-2: Assign value
of x is 9
STEP-3: Display x
STEP-4: Decrease the value of x by 2
STEP-5 Is the value of x is greater than
equal to 1
If “yes” then goto step 3 and repeat
it.
If “no” then GOTO step 6
STEP-6 End
No comments:
Post a Comment