Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Monday, March 21, 2022

programming structures or logic in QBASIC

 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:

 


 Example: Display the average of given two numbers

 


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:


1. To input any three subjects marks and display the average marks
Algorithm:

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:


2. To display the greatest number among the input three numbers.


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:



3.  To display the series of number 9, 7, 5……..1

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

Flowchart








No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages