100% found this document useful (1 vote)
402 views

Quick Basic

The document provides an introduction to QBasic programming including: - QBasic allows writing, editing, debugging and executing basic programs. - Key commands include PRINT to display output, INPUT to receive user input, and END to end a program. - Variables are used to store data in memory and must match the declared data type. - Mathematical expressions and string manipulation can be performed with variables. - Proper use of variables, data types, and commands are essential to avoid errors.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
402 views

Quick Basic

The document provides an introduction to QBasic programming including: - QBasic allows writing, editing, debugging and executing basic programs. - Key commands include PRINT to display output, INPUT to receive user input, and END to end a program. - Variables are used to store data in memory and must match the declared data type. - Mathematical expressions and string manipulation can be performed with variables. - Proper use of variables, data types, and commands are essential to avoid errors.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 95

QBasic Programming

QBasic Programming
1. QBasic Extension
2. QBasic Introduction
3. QBasic Installation
4. QBasic Screen
5. Getting Started – Welcome PRINT program
6. More about PRINT Command or PRINT Formatting
7. Shortcut ? for PRINT Command
8. Printing Math
9. Expressions
10. Variables
11. Variables with expressions
12. Variables with Strings
13. INPUT Command
QBasic Extension
Basic Full Form: Beginner's All-Purpose Symbolic Instruction Code.

What is Basic?

BASIC is only used to teach the fundamentals of any programming. 

QBasic Full Form: QuickBasic

What is QBasic?

QuickBasic (QB) is the compiler for the BASIC.

QBasic Introduction
 QuickBasic (QB) is the compiler for the BASIC.
 It was developed by Microsoft in 1985 which runs mainly on DOS
 It was launched by Microsoft in the year 1991.
 IT is considered to be one of the most ideal language for absolute
beginners.
 It is an integrated development environment (IDE) to write, edit, debug
and execute basic programs.

QBasic Advantages
 Easy to learn
 Fun to practice
 Called as People’s language
 Suitable for mathematical and business application
 Program development is quick.
 Debugging is easy.
 Modification of program is quite easy.

QBasic Installation
 QB64 is compatible with QBasic.
 Download QB64 latest version from www.qb64.org website.
 It gives you a zip file, first unzip the file.
 Double click on the qb64.exe file and run the file.

-----xxx completes the installation xxx------

QBasic Screen
Getting Started – Welcome Print Program
 Double click on the QB64 icon on the desktop to start programming, which
is compatible with QBasic.
 Type the program and Press F5 to run the program.
Exercise1: Welcome Print Program:

Commands:
CLS: Clear Screen => Used to clear screen.
PRINT: Used to display any message or output of a program. (OR)
Used to print something.
END: It’s a command tells the QBasic that the program ends here.
Press F5 to run the program.
Output:

Press any key to continue.


Save => Saving to your User Drive “F” Go to the FILE menu – then click
on SAVE - Type the path and filename as displayed below:
F:\QBasic\print_program.bas
click OK.

***********
“F:” is your user drive;
“\’s” are separators;
“QBasic” is the name of the folder;
and print_program is the filename.

**********
More about PRINT Command
or
PRINT Formatting
You can use multiple print statements in your program.

2 basic separators:
1. Semicolon => displays output next to each other.
2. Comma => displays output in columns.

To place World onto the previous line, place a semi-colon after PRINT "Hello".

Also, if you put a comma instead of a semi-colon on the first line, the program
will insert spaces between the two words.
Exercise2: print formatting.

Output:

Exercise3: print Calculation.

Shortcut ? for PRINT on QBasic


Shortcut ? : Type ? (i.e, shift / ) and press Enter => this gives you PRINT on
QBasic, which is used to display any message or output of a program.

Exercise4: print shortcut of ?.

Output:

Printing Math
Math Operators:
Add => +
Subtraction => -
Multiply => *
division =>/
Modulus => Mod
power => ^

Math Functions:
Absolute value => ABS
Square root => SQR

Exercise5: print math operations and functions.

Expressions
Commands: Also called as instructions. A "command" tells the QBasic
interpreter to do something.
The PRINT command tells the QBasic interpreter to print something to the
screen.

Exercise6: print strings.

Save => Ctrl +S => F:\qb\print_strings.bas


To run => Press F5

With the PRINT command, you can also print numbers and expressions to the
screen.
Exercise7: print numbers / expressions.

Exercise8: print math with expressions.


Output:

Data Types
The computer can hold data in memory. The programmer must tell the computer
what type of data to hold. This is called a data type.

String => Text and characters


Example: This line is an example of a string

Integer => Non-floating-point numbers from -32,768 to 32,767


Examples: 67, -34, -100, 203, 1022, -1, 0

Long => Non-floating-point numbers from -2,147,483,648 to 2,147,483,647


Examples: 560005, 3, -2, 0, -867000, 14, 8, -10

Single => Floating-point numbers from -3.37x10^38 to 3.37x10^38


Examples: 4.3, 25.4567, -35.87, 0.35, -3.14

Double =>Floating-point numbers from -1.67x10^308 to 1.67x10^308


Examples: 745663.90596, -98.12, 4859903.094491

Note: In QBasic 1.1, the Double may not work properly on some
computers.

64 Bit Data Types (QB64 Only):

_INTEGER64 => -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807


_FLOAT  => ±1.18E−4932, ±1.18E+4932

Variables
 A variable is a piece of data kept in the computer's memory (RAM).
 The location of a variable in RAM is called the "address."
 Hold data in memory.
 Are assigned a data type.
 The data can change throughout the program’s operation.
 The data entered must be the same data type as assigned to the variable.

A variable name is a name that is given to the data.


The name must not start with a number or character that is not a letter.
Also, the name of the variable must not be a reserved name like PRINT, INPUT,
LET, ABS, BEEP, etc.

There are two ways to declare a variable in QBasic / QB64.

First way to declare a variable: To put a data type symbol after the name.
$ String
% Integer
& Long
! Single
# Double
&& _INTEGER64 (QB64 Only)
## _FLOAT

Examples:
MyName$
Num1%
Num2!
Answer!

Exercise9: Var’s and Dt’s first way.

Second way to declare a variable: is the preferred way DIM; DIM is used to
make variables of a data type. 
DIM [Variable Name] As Data Type
DIM [Variable Name] AS STRING
DIM [Variable Name] AS INTEGER
DIM [Variable Name] AS LONG
DIM [Variable Name] AS SINGLE
DIM [Variable Name] AS DOUBLE
DIM [Variable Name] AS _INTEGER64
DIM [Variable Name] AS _FLOAT

Examples:

DIM MyName AS STRING


DIM Num1 AS INTEGER
DIM Num2 AS SINGLE
DIM Answer AS Double
Exercise10: Var’s and Dt’s second way.

How a variable stores in RAM?


Exercise11: Assigning value to the variable.

Since
The variable x hasn't been assigned a number, the value of the variable x is 0.
The variable y has assigned a number as 10, the value of the variable y is 10.
So, the output of the program is: 0 and 10

As in the programs above, a variable is accessed by calling its name. Variable


names can have a combination of letters and numbers.

The following are valid variables:


Y
num
VALUE
xYz
abc123
Also, you can use multiple variables in your program.

Exercise12: Multiple variables in a program.

Variables with Expressions


If you pass an expression to a variable, the expression is evaluated and the
variable is set to that value.

Exercise13: Expression Variables in a program.

x = 500 + (10 * 7)
PRINT x
Output:
570

You can also use variables as expressions.

Exercise14: Variables as expressions in a program.


rate = 50
time = 2
distance = rate * time
PRINT distance

Output:
100

Plus, you can have both variables and numbers in an expression.

Exercise15: Program for Variables and numbers in an expression.

X = 100
Y=X*7
PRINT Y

Output:
700

Variables with Strings or String Variable

If you add a dollar sign ($) to the end of a variable, the variable is a string.

Exercise16: Variables with strings in a program.

X$ = "Hello World!"
PRINT X$

Output:
Hello World!

If you try to set a string to a non-string variable, an error occurs.

X = "Hello World!"

The QBasic interpreter says "Type mismatch" when you try to run the above
program.

Exercise17: Program for adding string to the end of an existing string


variable.
X$ = "Hello"
X$ = X$ + "World"
PRINT X$

Output:
HelloWorld

You can also add variable strings together.

Exercise18: Program for adding variable strings together.

a$ = "String1"
b$ = "String2"
c$ = "String3"
d$ = a$ + b$ + c$
PRINT d$
Output:
String1String2String3

Type Mismatch other Data Type Errors


It is very important that the data matches the data type of the variable.

If the data does not match the data type then a type mismatch occurs.

If the computer is expecting an integer and gets a floating-point number, the


computer will round.
If the variable name is wrong in PRINT command, it does not put error, it
returns variable value as “0”.
INPUT Command
The command to receive user input is named INPUT.
INPUT will prompt the user to input data and then place the inputted data into a
variable.
INPUT’s string and the variable must be separated by either a comma or a
semicolon.

Ex19: INPUT’s string and the variable separation by a comma.

Ex20: INPUT’s string and the variable separation by a semicolon.


Ex21: Usage of separations by a comma and semicolon via INPUT
command.
Strings

If you add a dollar sign ($) to the end of a variable, the variable is a string.

X$ = "Hello World!"

PRINT X$

Output:

Hello World!

If you try to set a string to a non-string variable, an error occurs.

X = "Hello World!"
The QBasic interpreter says "Type mismatch" when you try to run the above
program.

A string can be added to the end of an existing variable string.

X$ = "Hello" X$ = X$ + "World"

PRINT X$

Output:

HelloWorld

You can also add variable strings together.

a$ = "String1" b$ = "String2" c$ = "String3"

d$ = a$ + b$ + c$

PRINT d$

Output:
String1String2String3

The IF and THEN commands


The IF and THEN commands are used to compare an expression and then
perform some task based on that expression.

x=5

IF x = 5 THEN PRINT "x equals 5"

Since X does equal 5 in this case, the program outputs:

x equals 5

Expression signs

You can also enter the following statements, instead of the equals sign:

x < 5 (x is less than 5)

x > 5 (x is greater than 5)

Run the following:

x = 16

IF (x > 5) THEN PRINT "x is greater than 5"

Output:

x is greater than 5

You can also combine the signs like this:

x <= 5 (x is less than or equal to 5)

x >= 5 (x is greater than or equal to 5)

x <> 5 (x does not equal 5)

Run the following example:

CLS

x=5

IF (x >= 5) THEN PRINT "x is greater than or equal to 5"

IF (x <= 5) THEN PRINT "x is less than or equal to 5"


IF (x <> 5) THEN PRINT "x does not equal 5"

Output:
x is greater than or equal to 5
x is less than or equal to 5

LAB PROGRAMS
1)Write a program to enter your name and print it .

CLS
Input 'Enter you name';n$
Print 'The name is';n$
End

2)Write a program to enter your name, city, country, age and print them.

CLS
Input " Enter the name ";N$
Input " Enter the city";C$
Input " Enter the country";CO$
Input " Enter the age";A
Print " The name is ";N$
Print " The city is ";C$
Print " The country is ";CO$
Print " The age is ";A
End

3)Write a program to find the area of rectangle.

Cls
Input " enter the length " ;l
Input " enter the breadth " ;b
let A = l*b
Print" the area of rectangle=" ;a
End

4)Write a program to find the area of the triangle.

Cls
Input " enter the base" ;b
Input " enter the height" ;h
let T = 1/2*b*h
Print" The area of triangle=" ;T
End

5)Write a program to find the area of the circle.

Cls
Input" Enter the radius " ;R
Let C=22/7*R^2
Print " The area of circle =" ;C
End

6)Write a program to find the circumference of the circle.

Cls
Input" Enter the radius " ;R
Let Circumference=22/7*R*2
Print " The area of circle =" ;Circumference
End

7)Write a program to find the area of the square.

Cls
Input" Enter the number" ;n
Let square= n^2
Print" The area of square=" ;Square
End
8)Write a program to find the area of the square and cube.

Cls
Input" Enter the number" ;n
Let square= n^2
Let Cube = n^3
Print" The area of square=" ;Square
Print" The area of cube=" ; Cube
End

9)Write a program to find the volume of the box.

Cls
Input " enter the length " ;l
Input " enter the breadth " ;b
Input " enter the height " ;h
Let Volume= l*b*h
Print" The volume of box =" ;Volume
End

10)Write a program to convert the weight from kilogram to pounds.

CLS
Input"Enter the weight in kilogram";K
Let P=K*2.2
Print "The pound is ";P
End

11)Write a program to convert the distance from kilometer to miles.


Cls
Input"Enter the length in kilometer";K
Let M= K / 1.6

Print "The length in miles =";M


End

12)Write a program to convert the distance from miles to kilomiles.

Cls
Input " Enter the length in miles";M
Let K=M*1.6
Print" The length in kilo miles=";K
End

13)Write a program to enter the initial mileage(m1) and final mileage (m2) then calculate
the distance traveled.

CLS
Input "Enter the Initial Mileage";M1
Input "Enter the Final Mileage";M2
Let D= M2-M1
Print " The distance covered=";D
End

14)Write a program to find out the simple Interest.

Cls
Input " Enter the Principal";P
Input " Enter the Rate";R
Input " Enter the Time";T
Let I = P*T*R/100
Print " The simple Interest = ";I
End

15)Write a program to find out the simple Interest and the Amount.

Cls
Input " Enter the Principal";P
Input " Enter the Rate";R
Input " Enter the Time";T
Let I = P*T*R/100
Let A= P + I
Print " The simple Interest = ";I
Print " The amount=";A
End

16)Write any number and find it's half.


Cls
Input "Enter the desired number "; N
Let H = N/2
Print "The half of the number = ";H
END

17)Write a program to find the area of four walls of a room.

Cls
Input"Enter the height ";H
Input"Enter the length "; L
Input"Enter the Breadth";B
Let A= 2 * H * (L+B)
Print " The area of four walls =";A
End
18)Write a program to find the perimeter of a rectangle.

Cls
Input " enter the length " ;l
Input " enter the breadth " ;b
Let P=2*(l+b)
Print" The perimeter of rectangle=" ;P
End

19)Write a program to enter any three numbers,sum and the average.

Cls
Input " Enter any number" ;A
Input " Enter any number" ;B
Input " Enter any number" ;C
Let Sum = A+B+C
Let Average =Sum/3
Print" The sum=" ;Sum
Print" The Average is " ;Average
End

20)Write a program to enter any two numbers their Sum,Product and the Difference.

CLS
Input " Enter any number" ;A
Input " Enter any number" ;B
Let Sum = A+B
Let Difference= A-B
Let Product = A*B
Print" the sum =" ;Sum
Print" the Difference =" ;Difference
Print" the Product =" ; Product
End
21)Write a program to find the average of three different numbers.

Cls
Input" Enter the number " ;A
Input" Enter the number " ;B
Input" Enter the number " ;C
Let Avg= (A+B+C)/3
Print" The average=" ;Avg
End

22)Write a program to input student's name,marks obtained in four different subjects,find


the total and average marks.

Cls
Input" Enter the name " ;N$
Input" Enter the marks in English" ;E
Input" Enter the marks in Maths" ;M
Input" Enter the marks in Science" ;S
Input" Enter the marks in Nepali" ;N
Let S=E+M+S+N
Let A=S/4
Print " The name of the student is" ;N$
Print " The total marks is" ;S
Print " The Average marks" ;A
End

23)Write a program to find 10%,20% and 30% of the input number.

Cls
Input" Enter any number" ;N
Let T=10/100*N
Let Twe=20/100*N
Let Thi=30/100*N
Print " 10%of input number=" ;T
Print " 20%of input number=" ;Twe
Print " 30%of input number=" ;Thi
End

24)Write a program to convert the distance to kilometer to miles.

Cls
Input" Enter the kilometer" ;K
Let M=K/1.6
Print " The miles = " ;M
End

25)Write a program to find the perimeter of square.

Cls
Input “Enter the length”; L
Let P =4 * L
Print “ The perimeter of square=”;P
End

26)Write a program to enter the Nepalese currency and covert it to Indian Currency.

CLS
Input “Enter the Nepalese currency” ;N
Let I = N * 1.6
Print “the Indian currency=”;I
End

27)Write a program to enter the Indian currency and covert it to Nepalese Currency.

CLS
Input “Enter the Indian currency” ;N
Let N = I / 1.6
Print “the Nepalese currency=”;I
End

28)Write a program to enter any number and find out whether it is negative or positive.

CLS
Input “Enter the number”; N
If N>0 Then
Print “ The number is positive”
Else
Print “The number is negative”
EndIf
End

29)Write a program to enter any number and find out whether it is even or odd using select
case statement.

Cls
Input “Enter any number” ;N
R=N mod 2
Select case R
Case = 0
Print “The number is Even number”
Case Else
Print “The number is odd number”
End Select
End

30)Write a program to check the numbers between 1 & 3.


Cls
Input “Enter the numbers between 1-3”;N
Select case N
Case 1
Print “It’s number 1”;
Case 2
Print “It’s a number 2”;
Case 3
Print “It’s a number 3”
Case else
Print “It’s out of range”;
End select
End

31)Write a program to enter any alphabet and test alphabet is ‘a’ or not using the select
case statement.

Cls
Input “Enter the alphabet”;A$
A$=UCase$ (A$)
Select Case A$
Case ‘A’
Print “It’s alphabet A”
Case Else
Print “It’s not alphabet A”
End Select
End

32)Write a program to enter any alphabet and find out whether the number is vowel or
alphabet.

Cls
Input “Enter Letters/Alphabet”;A$
A$ = UCase $ (A$)
Select case A$
Case “A”, “E”, “I”, “O”, “U”
Print “Its’ a vowel”
Case Else
Print “ It’s not a vowel”
End Select
End

33)Generate the following numbers using For….Next…..Loop.


1,2,3,4,…,50

CLS
For I = 1 to 50 Step 1
Print I
Next I
End

34)Generate the following numbers using For….Next…..Loop.


1,3,5,7,9,....99

Cls
For I = 1 to 99 Step 2
Print I
Next I
End

35)Generate the following numbers using For….Next…..Loop.


2,4,6,8,10,…50

Cls
For I = 2 to 50 Step 2
Print I
Next I
End

36)Generate the following numbers using For….Next…..Loop.


1,3,5,7,…99

ClsFor I = 1 to 99 Step 2

Print I
Next I
End

37)Generate the following numbers using For….Next…..Loop.


5,10,15,…90

Cls
For I = 5 to 90 Step 5
Print I
Next I
End

38) Generate the following numbers using For….Next…..Loop.


10,20,30,40,…100.

Cls
For I = 10 to 100 Step 10
Print I
Next I
End

39)Write a program to print numbers stated below USING WHILE…WEND STATEMENT.

Cls
I=1
While I<=100
Print I ;
I=I+1
WEND
END

40)Generate the following numbers using For….Next…..Loop.


2,4,6,8,10….50

CLS
I=2
While I < =50
Print I;
I=I+2
WEND
END

41)Write a program to print numbers stated below USING WHILE…WEND STATEMENT.


1,3,5,7,9,…99

CLS
I=1
While I <=99
Print I;
I=I+2
WEND
END

42)Write a program to print numbers stated below USING WHILE…WEND STATEMENT.


1,4,9,…upto 10th term.

CLS
I=1
While I < =10
Print I^2;
I=I+1
WEND
END

WRITE THE PROGRAMS FOR THE FOLLOWINGS


1. WRITE A PROGRAM TO INPUT THREE DIFFERENT NUMBERS AND PRINT THEIR SUM AND PRODUCT.
CLS
INPUT "ENTER FIRST NUMBER";N1
IPNUT "ENTER SECOND NUMBER";N2
IPNUT "ENTER THIRD NUMBER";N3
PRINT "SUM = ";N1+N2+N3
PRINT "PRODUCT = ";N1*N2*N3
END
2. WRITE A PROGRAM TO INPUT THE LENGTH AND PRINT THE PERIMETER OF A SQUARE
CLS
IPNUT "ENTER LENGTH";L
PRINT "PERIMETER = ";4*L
END
3. WRITE A PROGRAM TO INPNUT NEPALI CURRENCY AND CONVERT IT INTO INDIAN CURRENCY.
CLS
INPUT "ENTER NEPALI CURRENCY";N
PRINT "EQUIVALENT INDIAN CURRENCY =";N/1.6
END
4. WRITE A PROGRAM TO ENTER A NUMBER AND CHECK WHETHER TH NUMBER IS PALINDROME OR NOT.
CLS
INPUT "ENTER A NUMBR";N
T=N
WHILE N>0
                        R=N MOD 10
                        REV=REV*10+R
                        N=INT(N/10)
WEND
IF T=REV THEN
                        PRINT "THE NUMBER IS PALINDROME"
ELSE
                        PRINT "THE NUMBER IS NOT PALINDROME"
END IF
END
5. WRITE A PROGRAM TO INPUT A NUMBER AND CHECK WHETHER THE NUMBER IS ARMSTRONG OR NOT.
CLS
INPUT "ENTER A NUMBER";N
T=N
WHILE N>0
                        R = R MOD 10
                        ARM = ARM + R ^ 3
                        N = N \ 10
WEND
IF ARM = T THEN
                        PRINT "THE NUMBER IS ARMSTRONG"
ELSE
                        PRINT "THE NUMBER IS NOT ARMSTRONG"
END IF
END
6. WRITE A PROGRAM TO CHECK WHETHER A STRING IS PALINDROME OR NOT.
CLS
INPUT "ENTER A WORD";W$
FOR I = LEN(W$) TO 1 STEP -1
                        REV$ = REV$ + MID$(W$,I,1)
NEXT I
IF W$ = REV$ THEN
                        PRINT "PALINDROME"
ELSE
                        PRINT "NOT PALINDROME"
END IF
END
7. WRITE A PROGRAM TO CHECK WHETHER AN INPUT NUMBER IS PRIME OR COMPOSITE.
CLS
INPUT "ENTER A NUMBER";N
FOR I = N -1 TO 2 STEP -1
                        IF N MOD I = 0 THEN
                                                PRIME = 0
                                                GO TO DOWN
                        ELSE
                                                PRIME =1
                        END OF
NEXT I
DOWN:
IF PRIME = 1 OR N =1 OR N =2 THEN
                        PRINT "PRIME"
ELSE
                        PRINT "COMPOSITE"
END IF
END
8. WRITE A PROGRAM TO DISPLAY "SWARNIM PUBLICATION PVT LTD" 10 TIMES USING WHILE....WEND
CLS
I=1
WHILE I<=10
                        PRINT "SWARNIM PUBLICATION   PVT LTD"
                        I = I + 1
WEND
END
9. WRITE A PROGRAM TO PRINT FIRST 25 NUMBERS USING DO...LOOP
CLS
I=2
DO
   PRINT I,
   I = I + 2
LOOP WHILE I <= 50
END
10. WRITE A PROGRAM TO FIND OUT FACTORIAL OF A GIVEN NUMBER USING FOR... NEXT
CLS
INPUT "ENTER A NUMBER";N
F=1
FOR I = 1 TO N
   F = F * I
NEXT I
PRINT N;"! = ";F
END
11. WRITE A PROGRAM TO INPUT MARKS OF ALL YOUR SUBJECTS AND PRINT TOTAL, PERCENTAGE, RESULT
AND DIVISION
CLS
INPUT "MARKS IN NEPALI";N
INPUT "MARKS IN SCIENCE";S
INPUT "MARKS IN SOCIAL";SO
INPUT "MARKS IN ENGLISH";E
INPUT "MARKS IN MATHS";M
INPUT "MARKS IN OPT";O
INPUT "MARKS IN HPE";H
INPUT "MARKS IN COMPUTER";C
IF N>=40 AND S>=40 AND SO>=40 AND E>=40 AND M>=40 AND O>=40 AND H>=40 AND C>=40 THEN
                        RESULT$="PASS"
ELSE
                        RESULT$="FAIL"
END IF
TOTAL = N + S + SO + E + M + O + H + C
PERCENT = (TOAL / 800) * 100
IF PERCENT >=80 THEN
                        DIV$ = "DISTINCTION"
ELSEIF PERCENT >=60 THEN
                        DIV$ = "FIRST"
ELSEIF PERCENT >= 45 THEN
                        DIV$ = "SECOND"
ELSE
                        DIV$ = "THIRD"
END IF
PRINT "TOTAL: ";TOTAL
PRINT "PERCENT: ";PERCENT
PRINT "DIVISION: ";DIV$
PRINT "RESULT: ";RESULT$
END
12. WRITE A PROGRAM TO FIND THE AREA OF A CUBE. [HINT: A=6L2]
CLS
INPUT "ENTER THE LENGTH";L
PRINT "AREA = "; 6 * L ^ 2
END
13. WRITE A PROGRAM TO FIND THE CURVED SURFACE AREA OF A SQUARE.[A=2πRH]
CLS
PI = 22/7
INPUT "ENTER THE RADIUS";R
INPUT "ENTER THE HEIGHT";H
PRINT "CURVED SURFACE AREA = ";2 * PI * R * H
END
14. WRITE A PROGRAM TO FIND THE TOTAL SURFACE AREA OF A CYLINDER.[A=2πR(R+H)]
CLS
PI = 22/7
INPUT "ENTER THE RADIUS OF BASE OF CYLINDER";R
INPUT "ENTER THE HEIGHT OF THE CYLINDER";H
PRINT "SURFACE AREA = "; 2 * PI * R * (R + H)

END
15. WRITE A PROGRAM TO CALCULATE THE DISTANCE TRAVELLED BY BODY. [S=UT+1/2AT 2]
CLS
INPUT "ENTER THE INITIAL VELOCITY"; U
INPUT "ENTER TIME";T
INPUT "ENTER ACCELERATION";A
PRINT "DISTANCE TRAVELLED = "; U * T + (1/2) * A * T ^ 2
END
16. WRITE A PROGRAM TO INPUT THE TEMPERATURE IN FAHRENHEIT AND DISPLAY IN DEGREE CELSIUS.
CLS
INPUT "TEMPERATURE IN FAHRENHEIT";F
PRINT "TEMPERATURE IN CELCIUS = "; ((F - 32) * 5)/9
END

6. WRITE PROGRAM TO GENERATE FOLLOWING SERIES


A. 2, 4, 6, 8......... UP TO 10TH TERM
CLS
FOR I = 2 TO 20 STEP 2
PRINT I;
NEXT I
END
B. 1, 8, 27, 64, .......... UP TO 10TH TERM
CLS
FOR I = 1 TO 10
PRINT I^3;
NEXT I
END
C. 100, 98, 96, 94.... UP TO 10TH TERM
CLS
I=1
A = 100
WHILE I<=10
PRINT A;
A=A-2
I=I+1
WEND
END
D. 1, 4, 9, ......... UP TO 10TH TERM
CLS
FOR I = 1 TO 10
PRINT I ^ 2;
NEXT I
END
E. 5, 25, 125 .......... UP TO 10TH TERM
CLS
FOR I = 1 TO 10
PRINT 5 ^ I;
NEXT I
END
F. 1, 2, 3, 6, 11, 20, 37.... UP TO 10TH TERM
CLS
A=1
B=2
C=3
FOR I = 1 TO 10
D=A+B+C
SWAP A, B
SWAP B, C
SWAP C, D
PRINT D;
NEXT I
END
G. 5, 16, 8, 4, 2, 1, 4, 2, 1, 4
CLS
A=5
FOR I = 1 TO 10
PRINT A;
IF A MOD 2 = 0 THEN
A=A\2
ELSE
A=A*3+1
END IF
NEXT
END
H. 66666, 6666, 666, 66, 6.
CLS
A = 66666
FOR I = 1 TO 5
PRINT A;
A = A \ 10
NEXT I
END
I. 2, 8, 18, 32, ........ UP TO 10TH TERM
CLS
A=2
B=6
FOR I 1 TO 10
PRINT A;
A=A+B
B=B+4
NEXT I
END
J. 7, 22, 11, 34, 17, 52, 26, 13, 40, 20.
CLS
A=7
FOR I = 1 TO 10
PRINT A;
IF A MOD 2 = 0 THEN
A=A\2
ELSE
A=A*3+1
END IF
NEXT I
END
K. 1/2, 2/3, 3/4, ...... UP TO 10TH TERM
CLS
FOR I = 1 TO 10
PRINT I; "/"; I + 1;
NEXT I
END
7. WRITE A PROGRAM TO DISPLAY THE GICEN OUTPUT.
A. 54321
   4321
   321
   21
   1
CLS
FOR I = 5 TO 1 STEP -1
FOR J = I TO 1 STEP -1
PRINT J;
NEXT J
PRINT
NEXT I
END

B. 11111
   2222
   333
   44
   5
CLS
FOR I = 1 TO 5
FOR J = 5 TO I STEP -1
PRINT I;
NEXT J
PRINT
NEXT I
END

C. 5
   54
   543
   5432
   54321
CLS
FOR I = 5 TO 1 STEP -1
FOR J = 5 TO I STEP -1
PRINT J;
NEXT J
PRINT
NEXT I
END

D. 1
   13
   135
   1357
CLS
FOR I = 1 TO 7 STEP 2
FOR J = 1 TO I STEP 2
PRINT J;
NEXT J
PRINT
NEXT I
END

E. 1 2 3
   2 3 4
   3 4 5
   4 5 6
   5 6 7
CLS
FOR I = 0 TO 4
FOR J = 1 TO 3
PRINT I +J;
NEXT J
PRINT
NEXT I
END

F. 1
   33
   555
   7777
CLS
FOR I = 1 TO 7 STEP 2
FOR J = 1 TO I STEP 2
PRINT I;
NEXT J
PRINT
NEXT I
END

Program
1) WAP to print the Fibonacci series

CLS

a=1

b=1
PRINT a, b,

FOR i = 1 TO 8

c=a+b

PRINT c,

a=b

b=c

NEXT i

END

……………………………………………………………………………….

2) WAP to print the factors of a given number

REM Program to print the factors of a given number

CLS

INPUT “Enter any number”; n

FOR i = 1 TO n

IF n MOD i = 0 THEN PRINT i,

NEXT i

END

…………………………………………………………………………………

3) WAP to print the greater among ten different numbers

REM Program to print greater number among ten different numbers

CLS

INPUT “Enter first number”; g

FOR i = 2 TO 10

INPUT “Enter next number”; a

IF a > g THEN g = a

NEXT
PRINT g; ” is the greatest number”

END

………………………………………………………………………………….

4) WAP to print the greater among three different numbers

REM Program to print greater among three different numbers

CLS

INPUT “Enter first number”; a

INPUT “Enter second number”; b

INPUT “Enter third number”; c

IF a > b AND a > c THEN

PRINT a; ” is greater”

ELSEIF b > a AND b > c THEN

PRINT b; ” is greater”

ELSE

PRINT c; ” is greater”

END IF

END

…………………………………………………………………………….

5) WAP to print the greater among two different numbers

REM Program to print the greater among two different numbers

CLS

INPUT “Enter first number”; a

INPUT “Enter second number”; b

IF a > b THEN

PRINT a; ” is greater”

ELSE
PRINT b; ” is greater”

END IF

END

………………………………………………………………………………..

6) WAP to calculate the cube root of a given number

REM Program to calculate the cube root of a given number

CLS

INPUT “Enter any number”; n

c = n ^ (1 / 3)

PRINT “Cube root of “; n; ” is “; s

END

…………………………………………………………………………………..

7) WAP to calculate the square root of a given number

REM Program to calculate the square root of a given number

CLS

INPUT “Enter any number”; n

s = SQR(n)

PRINT “Square root of “; n; ” is “; s

END

…………………………………………………………………………………..

8) Program to check the given number for palindrome in qbasic using declare sub

DECLARE SUB A (N)

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A (N)
S=N

WHILE N <> 0

B = N MOD 10

R = R * 10 + B

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “IT IS PALINDROME”

ELSE

PRINT “IT IS NOT PALINDROME”

END IF

END SUB

………………………………………………………………………………..

9) Program to check given number for armstrong in qbasic using declare sub

DECLARE SUB A(N)

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A(N)

S=N

WHILE N <> 0

B = N MOD 10

R=R+B^3

N = FIX(N / 10)

WEND

IF S = R THEN
PRINT “THE GIVEN NUMBER IS ARMSTRONG”

ELSE

PRINT “IT IS NOT ARMSTRONG”

END IF

END SUB

………………………………………………………………………………….

10) Program to reverse a given string in qbasic

CLS

INPUT “ENTER A STRING”; S$

FOR I = LEN(S$) TO 1 STEP -1

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

PRINT REV$

END

………………………………………………………………………………..

11s) Program to convert decimal to binary in qbasic using declare function

DECLARE FUNCTION A$ (N)

CLS

INPUT “ENTER A NUMBER”; N

PRINT “BINARY EQUIVALENT IS”; A$(N)

END

FUNCTION A$ (N)

WHILE N <> 0
E = N MOD 2

B$ = STR$(E)

N = FIX(N / 2)

C$ = B$ + C$

WEND

A$=C$

END FUNCTION

Qbasic looping Programs


WAP TO PRINT ALL ODD NUMBER FROM 1 TO 100

CLS
A=1
B=1
DO WHILE B<=50
PRINT A
A=A+2
B=B+1
LOOP
END

WAP TO PRINT ALL EVEN NUMBERS FROM 1 TO 100

CLS
A=2
B=1
DO WHILE B<=50
PRINT A
A=A+2
B=B+1
LOOP
END

1,4,9,16,25
CLS
A=1
B=1
DO WHILE B<=5
PRINT A^2
A=A+1
B=B+1
LOOP
END

1, 9, 25….10TH TERM
CLS
A=1
B=1
DO WHILE B<=10
PRINT A^2
A=A+2
B=B+1
LOOP
END

100, 90,80,70,60
CLS
A=100
B=1
DO WHILE B<=5
PRINT A
A=A-10
B=B+1
LOOP
END

10,9,8,7,6,5,4,3,2,1
CLS
A=10
B=1
DO WHILE B<=10
PRINT A
A=A-1
B=B+1
LOOP
END
4,16,36,64,100
CLS
A=2
B=1
DO WHILE B<=5
PRINT A^2
A=A+2
B=B+1
LOOP
END

1, 8, 27……..5TH TERM
CLS
A=1
B=1
DO WHILE B<=5
PRINT A^3
A=A+1
B=B+1
LOOP
END

100, 98.5, 97, 95.5….10TH TERM


CLS
A=100
B=1
DO WHILE B<=10
PRINT A
A=A-1.5
B=B+1
LOOP
END
3, 6, 9, 12, 15………10TH TERM
CLS
A=3
B=1
DO WHILE B<=10
PRINT A
A=A+3
B=B+1
LOOP
END

1000,900,800,700,600
CLS
A=1000
B=1
DO WHILE B<=5
PRINT A
A=A-100
B=B+1
LOOP
END

-5,-4,-3,-2,-1, 0, 1, 2,3,4,5
CLS
A=-5
B=1
DO WHILE B<=10
PRINT A
A=A+1
B=B+1
LOOP
END
5, 10, 15, 20…..10TH TERM
CLS
A=5
B=1
DO WHILE B<=10
PRINT A
A=A+5
B=B+1
LOOP
END

5, 25,125……5TH TERM
CLS
A=5
B=1
DO WHILE B<=5
PRINT A
A=A*5
B=B+1
LOOP
END

1
11
111
1111
11111
CLS
A=1
B=1
DO WHILE B<=5
PRINT A
A= (A*10) +1
B=B+1
LOOP
END

WAP TO GENERATE YOUR NAME TEN TIMES


CLS
A$=”AMENDRA”
B=1
DO WHILE B<=5
PRINT A$
B=B+1
LOOP
END

10, 20,30,40,50
CLS
A=10
B=1
DO WHILE B<=5
PRINT A
A=A+10
B=B+1
LOOP
END

-10,-5, 0,5,10
CLS
A=-10
B=1
DO WHILE B<=5
PRINT A
A=A+5
B=B+1
LOOP
END
SUM OF ALL ODD NMBER FROM 1 TO 100
CLS
A=1
B=1
DO WHILE B<=50
S=S+A
A=A+1
B=B+1
LOOP
PRINT”THE SUM IS”; S
END

SUM OF ALL EVEN NMBER FROM 1 TO 100


CLS
A=2
B=1
DO WHILE B<=50
S=S+A
A=A+2
B=B+1
LOOP
PRINT”THE SUM IS”; S
END

SUM OF ALL NUMBER FROM 1 TO 100

CLS
A=1
B=1
DO WHILE B<=100
S=S+A
A=A+1
B=B+1
LOOP
PRINT”THE SUM IS”; S
END
SUMOF SQUARE NO FROM 1 TO 5
CLS
A=1
B=1
DO WHILE B<=5
PRINT A^2
S=S+A^2
A=A+1
B=B+1
LOOP
PRINT”THE SUM IS”; S
END

FIBROUS SERIES
CLS
A=2
B=2
D=1
PRINT A; B
DO WHILE D<=10
C=A+B
PRINT C
A=B
B=C
D=D+1
LOOP
END

WAP TO PRINT ALL ODD NUMBER FROM 1 TO 100

CLS
A=1
B=1
DO
PRINT A
A=A+2
B=B+1
LOOP WHILE B<=50
END

WAP TO PRINT ALL EVEN NUMBERS FROM 1 TO 100


CLS
A=2
B=1
DO
PRINT A
A=A+2
B=B+1
LOOP WHILE B<=50
END

1,4,9,16,25
CLS
A=1
B=1
DO
PRINT A^2
A=A+1
B=B+1
LOOP WHILE B<=5
END

1, 9, 25….10TH TERM
CLS
A=1
B=1
DO
PRINT A^2
A=A+2
B=B+1
LOOP WHILE B<=10
END

100, 90,80,70,60
CLS
A=100
B=1
DO
PRINT A
A=A-10
B=B+1
LOOP WHILE B<=5
END

10,9,8,7,6,5,4,3,2,1
CLS
A=10
B=1
DO
PRINT A
A=A-1
B=B+1
LOOP WHILE B<=10
END

4,16,36,64,100
CLS
A=2
B=1
DO
PRINT A^2
A=A+2
B=B+1
LOOP WHILE B<=5
END

1, 8, 27……..5TH TERM
CLS
A=1
B=1
DO
PRINT A^3
A=A+1
B=B+1
LOOP WHILE B<=5
END

100, 98.5, 97, 95.5….10TH TERM


CLS
A=100
B=1
DO
PRINT A
A=A-1.5
B=B+1
LOOP WHILE B<=10
END

3, 6, 9, 12, 15………10TH TERM


CLS
A=3
B=1
DO
PRINT A
A=A+3
B=B+1
LOOP WHILE B<=10
END

1000,900,800,700,600
CLS
A=1000
B=1
DO
PRINT A
A=A-100
B=B+1
LOOP WHILE B<=5

END

-5,-4,-3,-2,-1, 0, 1, 2,3,4,5
CLS
A=-5
B=1
DO
PRINT A
A=A+1
B=B+1
LOOP WHILE B<=10
END

5, 10, 15, 20…..10TH TERM


CLS
A=5
B=1
DO
PRINT A
A=A+5
B=B+1
LOOP WHILE B<=10
END

5, 25,125……5TH TERM
CLS
A=5
B=1
DO
PRINT A
A=A*5
B=B+1
LOOP WHILE B<=5
END

1
11
111
1111
11111
CLS
A=1
B=1
DO
PRINT A
A= (A*10) +1
B=B+1
LOOP WHILE B<=5
END

WAP TO GENERATE YOUR NAME TEN TIMES


CLS
A$=”AMENDRA”
B=1
DO WHILE B<=5
PRINT A$
B=B+1
LOOP WHILE B<=5
END

10, 20,30,40,50
CLS
A=10
B=1
DO
PRINT A
A=A+10
B=B+1
LOOP WHILE B<=5
END

-10,-5, 0,5,10
CLS
A=-10
B=1
DO
PRINT A
A=A+5
B=B+1
LOOP WHILE B<=5
END

SUM OF ALL ODD NMBER FROM 1 TO 100


CLS
A=1
B=1
DO
S=S+A
A=A+1
B=B+1
LOOP WHILE B<=50
PRINT”THE SUM IS”; S
END

SUM OF ALL EVEN NMBER FROM 1 TO 100


CLS
A=2
B=1
DO
S=S+A
A=A+2
B=B+1
LOOP WHILE B<=50
PRINT”THE SUM IS”; S
END

SUM OF ALL NUMBER FROM 1 TO 100

CLS
A=1
B=1
DO
S=S+A
A=A+1
B=B+1
LOOP WHILE B<=100
PRINT”THE SUM IS”; S
END

SUMOF SQUARE NO FROM 1 TO 5


CLS
A=1
B=1
DO
PRINT A^2
S=S+A^2
A=A+1
B=B+1
LOOP WHILE B<=5
PRINT”THE SUM IS”; S
END

FIBROUS SERIES
CLS
A=2
B=2
D=1
PRINT A; B
DO
C=A+B
PRINT C
A=B
B=C
D=D+1
LOOP WHILE D<=10
END

WAP TO PRINT ALL ODD NUMBER FROM 1 TO 100

CLS
A=1
B=1
DO
PRINT A
A=A+2
B=B+1
LOOP UNTIL B>50
END

WAP TO PRINT ALL EVEN NUMBERS FROM 1 TO 100

CLS
A=2
B=1
DO
PRINT A
A=A+2
B=B+1
LOOP UNTIL B>50
END

1,4,9,16,25
CLS
A=1
B=1
DO
PRINT A^2
A=A+1
B=B+1
LOOP UNTIL B>5
END

1, 9, 25….10TH TERM
CLS
A=1
B=1
DO
PRINT A^2
A=A+2
B=B+1
LOOP UNTIL B>10
END

100, 90,80,70,60
CLS
A=100
B=1
DO
PRINT A
A=A-10
B=B+1
LOOP UNTIL B>5
END

10,9,8,7,6,5,4,3,2,1
CLS
A=10
B=1
DO
PRINT A
A=A-1
B=B+1
LOOP UNTIL B>10
END
4,16,36,64,100
CLS
A=2
B=1
DO
PRINT A^2
A=A+2
B=B+1
LOOP UNTIL B>5
END

1, 8, 27……..5TH TERM
CLS
A=1
B=1
DO
PRINT A^3
A=A+1
B=B+1
LOOP UNTIL B>5
END

100, 98.5, 97, 95.5….10TH TERM


CLS
A=100
B=1
DO UNTIL B>10
PRINT A
A=A-1.5
B=B+1
LOOP UNTIL B>10
END
3, 6, 9, 12, 15………10TH TERM
CLS
A=3
B=1
DO
PRINT A
A=A+3
B=B+1
LOOP UNTIL B>10
END

1000,900,800,700,600
CLS
A=1000
B=1
DO
PRINT A
A=A-100
B=B+1
LOOP UNTIL B>5
END

-5,-4,-3,-2,-1, 0, 1, 2,3,4,5
CLS
A=-5
B=1
DO
PRINT A
A=A+1
B=B+1
LOOP UNTIL B>10
END

5, 10, 15, 20…..10TH TERM


CLS
A=5
B=1
DO
PRINT A
A=A+5
B=B+1
LOOP UNTIL B>10
END

5, 25,125……5TH TERM
CLS
A=5
B=1
DO
PRINT A
A=A*5
B=B+1
LOOP UNTIL B>5
END

WAP TO GENERATE YOUR NAME TEN TIMES


CLS
A$=”AMENDRA”
B=1
DO
PRINT A$
B=B+1
LOOP UNTIL B>5
END

10, 20,30,40,50
CLS
A=10
B=1
DO
PRINT A
A=A+10
B=B+1
LOOP UNTIL B>5
END

-10,-5, 0,5,10
CLS
A=-10
B=1
DO
PRINT A
A=A+5
B=B+1
LOOP UNTIL B>5
END
SUM OF ALL ODD NMBER FROM 1 TO 100
CLS
A=1
B=1
DO
S=S+A
A=A+1
B=B+1
LOOP UNTIL B>50
PRINT”THE SUM IS”; S
END

SUM OF ALL EVEN NMBER FROM 1 TO 100


CLS
A=2
B=1
DO UNTIL B>50
S=S+A
A=A+2
B=B+1
LOOP UNTIL B>50
PRINT”THE SUM IS”; S
END

SUM OF ALL NUMBER FROM 1 TO 100

CLS
A=1
B=1
DO
S=S+A
A=A+1
B=B+1
LOOP UNTIL B>100
PRINT”THE SUM IS”; S
END
SUMOF SQUARE NO FROM 1 TO 5
CLS
A=1
B=1
DO
PRINT A^2
S=S+A^2
A=A+1
B=B+1
LOOP UNTIL B>5
PRINT”THE SUM IS”; S
END

FIBROUS SERIES
CLS
A=2
B=2
D=1
PRINT A; B
DO
C=A+B
PRINT C
A=B
B=C
D=D+1
LOOP UNTIL D>10
END

1
11
111
1111
11111
CLS
A=1
B=1
DO
PRINT A
A= (A*10) +1
B=B+1
LOOP UNTIL B>5
END

WAP TO GENERATE THE FOLLOWING PATTERN

ALL ODD NUMBER FROM 1 TO 100

CLS
A=1
B=1
10:
PRINT A
A=A+2
B=B+1
IF B<= 50 THEN GO TO 10
END

ALL EVEN NUMBERS FROM 1 TO 100

CLS
A=2
B=1
10:
PRINT A
A=A+2
B=B+1
IF B<= 50 THEN GO TO 10
END

1,4,9,16,25

CLS
A=1
B=1
10:
PRINT A^2
A=A+1
B=B+1
IF B<=5 THEN GO TO 10
END
10,9,8,7,6,5,4,3,2,1

CLS
A=10
B=1
10:
PRINT A
A=A-1
B=B+1
IF B<= 10 THEN GO TO 10
END

1, 8, 27….. FIFTH TERM


CLS
A=1
B=1
10:
PRINT A^3
A=A+1
B=B+1
IF B<= 5THEN GO TO 10
END

3, 6, 9, 12, 15…….10 TH TERM


CLS
A=3
B=1
10:
PRINT A
A=A+3
B=B+1
IF B<= 10 THEN GO TO 10
END
1000,900,800,700,600
CLS
A=1000
B=1
10:
PRINT A
A=A-100
B=B+1
IF B<= 5 THEN GO TO 10
END

1, 9,25,49,81
CLS
A=1
B=1
10:
PRINT A^2
A=A+2
B=B+1
IF B<= 5 THEN GO TO 10
END

4, 16, 36…….10TH TERM


CLS
A=2
B=1
10:
PRINT A^2
A=A+2
B=B+1
IF B<= 10 THEN GO TO 10
END
5, 25,125……10TH TERM
CLS
A=5
B=1
START:
PRINT A
A=A*5
B=B+1
IF B<= 10 THEN GO TO START
END

100, 90,80,70,60
CLS
A=100
B=1
10:
PRINT A
A=A-10
B=B+1
IF B<= 5THEN GO TO 10
END

5, 10, 15, 20…. 10TH TERM


CLS
A=5
B=1
START:
PRINT A
A=A+5
B=B+1
IF B<= 10 THEN GO TO START
END

10, 20,30,40,50
CLS
A=10
B=1
10:
PRINT A
A=A+1
B=B+1
IF B<= 5 THEN GO TO 10
END
-5,-4,-3,-2,-1, 0, 1, 2,3,4,5
CLS
A=-5
B=1
10:
PRINT A
A=A+1
B=B+1
IF B<= 11 THEN GO TO 10
END

SUM OF ALL ODD NUMBER FROM 1 TO 100

CLS
A=1
B=1
10:
S=S+A
A=A+2
B=B+1
IF B<= 50 THEN GO TO 10
PRINT”THE SUM IS”; S
END

SUM OF ALL EVEN NUMBERS FROM 1 TO 100

CLS
A=2
B=1
10:
S=S+A
A=A+2
B=B+1
IF B<= 50 THEN GO TO 10
PRINT”THE SUM IS”; S
END
SUM OF ALL NUMBER FROM 1 TO 100

CLS
A=1
B=1
10:
S=S+A
A=A+1
B=B+1
IF B<= 100 THEN GO TO 10
PRINT”THE SUM IS”; S
END

100, 98.5, 97…….10TH TERM

CLS
A=100
B=1
10:
PRINT A
A=A-1.5
B=B+1
IF B<= 10 THEN GO TO 10
PRINT”THE SUM IS”; S
END

SUM OF SQUARE NO FROM 1 TO5

CLS
A=1
B=1
START:
S=S+A^2
A=A+1
B=B+1
IF B<= 5 THEN GO TO START
PRINT”THE SUM IS”; S
END

ALL NUMBER FROM 1 TO 100

CLS
A=1
B=1
START:
PRINT A
A=A+1
B=B+1
IF B<=100 THEN GO TO START
END

ALL NUMBER FROM 1 TO 100


CLS
A=1
FOR I=1 TO 100
PRINT A
A=A+1

NEXT I
END

ODD NUMBER

CLS
FOR I= 1 TO 100 STEP 2
PRINT I
NEXT I
END

EVEN NUMBER
CLS
FOR I= 2 TO 100 STEP 2
PRINT I
NEXT I
END

CLS
A=1
FOR I= 1 TO 5
PRINT A
A= (A*10) +1
NEXT I
END

OUTPUT
1
11
111
1111
11111

WAP TO PRINT YOUR NAME TEN TIMES


CLS
A$”AMENDRA”
FOR I= 1 TO 10
RINT A$
NEXT I
END

AMENDRA
AMENDRA
AMENDRA
AMENDRA
AMENDRA
AMENDRA
AMENDRA
AMENDRA
AMENDRA
AMENDRA

WRITE THE OUTPUT OF THE FOLLOWING PROGAMME

CLS
FOR I= 1 TO5
FOR J= 1 TO I
PRINT J;
NEXT J
PRINT
NEXT I
END

OUT PUT
1
12
123
1234
12345

CLS
FOR I= 1 TO5
FOR J= 1 TO I
PRINT I;
NEXT J
PRINT
NEXT I
END

OUT PUT
1
22
333
4444
55555

CLS
FOR I= 5 TO1 STEP-1
FOR J= 1 TO I
PRINT J;
NEXT J
PRINT
NEXT I
END

OUT PUT
12345
1234
123
12
1

CLS
FOR I= 5 TO1 STEP-1
FOR J= 1 TO I
PRINT I;
NEXT J
PRINT
NEXT I
END

OUT PUT
55555
4444
333
22
1

CLS
FOR I= 1 TO5
FOR J= 5 TO I STEP-1
PRINT J;
NEXT J
PRINT
NEXT I
END
OUT PUT
54321
5432
543
54
5

CLS
FOR I= 1 TO5
FOR J= 1 TO I
PRINT I
NEXT J
PRINT
NEXT I
END

OUT PUT
14
14
1
1
1

5
2
2
2
2

3
3
3

FIBROUS SERIES

CLS
A=1
B=1
PRINT A;B
FOR I= 1 TO 8
C=A+B
A=B
B=C
NEXT I
END
OUTPUT

11
2
3
5
8
13
21
34
55

WAO TO CHECK THET GIVEN NUMBER IS ARNSTRONG OR NOT

CLS
INPUT”ENTER THE NUMBER”;N
A=N
WHILE N<>0
R=N MOD 10
S=S+R^3
N=N/10
WEND
IF S=A THEN
PRINT”IT IS ARMSTRONG”
ELSE
PRINT”IT IS NOT ARMSTRONG”
END IF
END

WAP TO CHECK THE GIVEN NUMBER IS PRIME OR NOT

CLS
INPUT”ENTER A NUMBER”;N
FOR I= 1 TO N
IF N MOD I=0 THEN
C=C+1
END IF
NEXT I
IF C<=2 THEN
PRINT”THE NUMBER IS PRIME”
ELSE
PRINT”THE NUMBER IS NOT PRIME”
END
WAP TO INPUT A NUMBER (MULTIDIGIT) AND FIND ITS SUM

CLS
INPUT”ENTERS THE MULTIDIGIT NUMBER”; N
WHILE N MOD 10
R=N MOD 10
S=S+R
N=N/10
WEND
PRINT”THE SUMIS”; S
END

WAP TO INPUT A NUMBER (MULTIDIGIT) AND FIND ITS PRODUCT

CLS
INPUT”ENTERS THE MULTIDIGIT NUMBER”; N
S=1
WHILE N MOD 10
R=N MOD 10
S=S*R
N=N/10
WEND
PRINT”THE SUMIS”; S
END

WAP TO FIND IT’S OUTOUT


HAILSTROM PATTERN

CLS
A=7
FOR I=1 TO 5
PRINT A
IF A MOD 2<>0 THEN
A-A*3+1
ELSE
A=A/2
END IF
NEXT I
END
WAP TO PRINT THE MULTIDIGIT NUMBER IN REVERSE FORM

CLS
A=12345
WHILE A<>0
R=A MOD 10
S=S*10+R
A=A/10
WEND
PRINT S
END

OUTPUT
5
50+4
54*10
543*10
5432*10
54321

OUTPUT
54321
WAP TO PRINT THE SUM OF THE EVEN NUMBER OF THE MULTIDIGIT NUMBER

CLS
INPUT”ENTERS A MULTIDIGIT NUMBER”; N
WHILE N<>0
R=N MOD 10
IF R MOD 2=0 THEN
S=S+R
END IF
WEND
PRINT”THE SUM OF THE EVEN NUMBER”; S
END

WAP TO PRINT THE SUM OF THE ODD NUMBER OF THE MULTIDIGIT NUMBER

CLS
INPUT”ENTERS A MULTIDIGIT NUMBER”; N
WHILE N<>0
R=N MOD 10
IF R MOD 2<>0 THEN
S=S+R
END IF
WEND
PRINT”THE SUM OF THE EVEN NUMBER”; S
END

WAP TO PRINT ALL ODD NUMBER FROM 1 TO 100

CLS
A=1
B=1
WHILE B<=50
PRINT A
A=A+2
B=B+1
WEND
END

WAP TO PRINT ALL EVEN NUMBERS FROM 1 TO 100

CLS
A=2
B=1
WHILE B<=50
PRINT A
A=A+2
B=B+1
WEND
END

1,4,9,16,25
CLS
A=1
B=1
WHILE B<=5
PRINT A^2
A=A+1
B=B+1
WEND
END

1, 9, 25….10TH TERM
CLS
A=1
B=1
WHILE B<=10
PRINT A^2
A=A+2
B=B+1
WEND
END

100, 90,80,70,60
CLS
A=100
B=1
WHILE B<=5
PRINT A
A=A-10
B=B+1
WEND
END

10,9,8,7,6,5,4,3,2,1
CLS
A=10
B=1
WHILE B<=10
PRINT A
A=A-1
B=B+1
WEND
END

4,16,36,64,100
CLS
A=2
B=1
WHILE B<=5
PRINT A^2
A=A+2
B=B+1
WEND
END

1, 8, 27……..5TH TERM
CLS
A=1
B=1
WHILE B<=5
PRINT A^3
A=A+1
B=B+1
WEND
END

100, 98.5, 97, 95.5….10TH TERM


CLS
A=100
B=1
WHILE B<=10
PRINT A
A=A-1.5
B=B+1
WEND
END

3, 6, 9, 12, 15………10TH TERM


CLS
A=3
B=1
WHILE B<=10
PRINT A
A=A+3
B=B+1
WEND
END

1000,900,800,700,600
CLS
A=1000
B=1
WHILE B<=5
PRINT A
A=A-100
B=B+1
WEND
END

-5,-4,-3,-2,-1, 0, 1, 2,3,4,5
CLS
A=-5
B=1
WHILE B<=10
PRINT A
A=A+1
B=B+1
WEND
END

5, 10, 15, 20…..10TH TERM


CLS
A=5
B=1
WHILE B<=10
PRINT A
A=A+5
B=B+1
WEND
END

5, 25,125……5TH TERM
CLS
A=5
B=1
WHILE B<=5
PRINT A
A=A*5
B=B+1
WEND
END
1
11
111
1111
11111
CLS
A=1
B=1
WHILE B<=5
PRINT A
A= (A*10) +1
B=B+1
WEND
END

WAP TO GENERATE YOUR NAME TEN TIMES


CLS
A$=”AMENDRA”
B=1
WHILE B<=5
PRINT A$
B=B+1
WEND
END

10, 20,30,40,50
CLS
A=10
B=1
WHILE B<=5
PRINT A
A=A+10
B=B+1
WEND
END

-10,-5, 0,5,10
CLS
A=-10
B=1
WHILE B<=5
PRINT A
A=A+5
B=B+1
WEND
END

SUM OF ALL ODD NMBER FROM 1 TO 100


CLS
A=1
B=1
WHILE B<=50
S=S+A
A=A+1
B=B+1
WEND
PRINT”THE SUM IS”; S
END

SUM OF ALL EVEN NMBER FROM 1 TO 100


CLS
A=2
B=1
WHILE B<=50
S=S+A
A=A+2
B=B+1
WEND
PRINT”THE SUM IS”; S
END

SUM OF ALL NUMBER FROM 1 TO 100


CLS
A=1
B=1
WHILE B<=100
S=S+A
A=A+1
B=B+1
WEND
PRINT”THE SUM IS”; S
END

SUMOF SQUARE NO FROM 1 TO 5


CLS
A=1
B=1
WHILE B<=5
PRINT A^2
S=S+A^2
A=A+1
B=B+1
WEND
PRINT”THE SUM IS”; S
END

FIBROUS SERIES
CLS
A=2
B=2
D=1
PRINT A; B
WHILE D<=10
C=A+B
PRINT C
A=B
B=C
D=D+1
WEND
END

You might also like