Quick Basic
Quick Basic
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?
What is QBasic?
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.
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:
***********
“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:
Output:
Printing Math
Math Operators:
Add => +
Subtraction => -
Multiply => *
division =>/
Modulus => Mod
power => ^
Math Functions:
Absolute value => ABS
Square root => SQR
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.
With the PRINT command, you can also print numbers and expressions to the
screen.
Exercise7: print numbers / expressions.
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.
Note: In QBasic 1.1, the Double may not work properly on some
computers.
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.
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!
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:
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
x = 500 + (10 * 7)
PRINT x
Output:
570
Output:
100
X = 100
Y=X*7
PRINT Y
Output:
700
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!
X = "Hello World!"
The QBasic interpreter says "Type mismatch" when you try to run the above
program.
Output:
HelloWorld
a$ = "String1"
b$ = "String2"
c$ = "String3"
d$ = a$ + b$ + c$
PRINT d$
Output:
String1String2String3
If the data does not match the data type then a type mismatch occurs.
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!
X = "Hello World!"
The QBasic interpreter says "Type mismatch" when you try to run the above
program.
X$ = "Hello" X$ = X$ + "World"
PRINT X$
Output:
HelloWorld
d$ = a$ + b$ + c$
PRINT d$
Output:
String1String2String3
x=5
x equals 5
Expression signs
You can also enter the following statements, instead of the equals sign:
x = 16
Output:
x is greater than 5
CLS
x=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
Cls
Input " enter the length " ;l
Input " enter the breadth " ;b
let A = l*b
Print" the area of rectangle=" ;a
End
Cls
Input " enter the base" ;b
Input " enter the height" ;h
let T = 1/2*b*h
Print" The area of triangle=" ;T
End
Cls
Input" Enter the radius " ;R
Let C=22/7*R^2
Print " The area of circle =" ;C
End
Cls
Input" Enter the radius " ;R
Let Circumference=22/7*R*2
Print " The area of circle =" ;Circumference
End
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
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
CLS
Input"Enter the weight in kilogram";K
Let P=K*2.2
Print "The pound is ";P
End
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
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
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
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
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
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
Cls
Input" Enter the kilometer" ;K
Let M=K/1.6
Print " The miles = " ;M
End
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
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
CLS
For I = 1 to 50 Step 1
Print I
Next I
End
Cls
For I = 1 to 99 Step 2
Print I
Next I
End
Cls
For I = 2 to 50 Step 2
Print I
Next I
End
ClsFor I = 1 to 99 Step 2
Print I
Next I
End
Cls
For I = 5 to 90 Step 5
Print I
Next I
End
Cls
For I = 10 to 100 Step 10
Print I
Next I
End
Cls
I=1
While I<=100
Print I ;
I=I+1
WEND
END
CLS
I=2
While I < =50
Print I;
I=I+2
WEND
END
CLS
I=1
While I <=99
Print I;
I=I+2
WEND
END
CLS
I=1
While I < =10
Print I^2;
I=I+1
WEND
END
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
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
……………………………………………………………………………….
CLS
FOR i = 1 TO n
NEXT i
END
…………………………………………………………………………………
CLS
FOR i = 2 TO 10
IF a > g THEN g = a
NEXT
PRINT g; ” is the greatest number”
END
………………………………………………………………………………….
CLS
PRINT a; ” is greater”
PRINT b; ” is greater”
ELSE
PRINT c; ” is greater”
END IF
END
…………………………………………………………………………….
CLS
IF a > b THEN
PRINT a; ” is greater”
ELSE
PRINT b; ” is greater”
END IF
END
………………………………………………………………………………..
CLS
c = n ^ (1 / 3)
END
…………………………………………………………………………………..
CLS
s = SQR(n)
END
…………………………………………………………………………………..
8) Program to check the given number for palindrome in qbasic using declare sub
CLS
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
ELSE
END IF
END SUB
………………………………………………………………………………..
9) Program to check given number for armstrong in qbasic using declare sub
CLS
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
END IF
END SUB
………………………………………………………………………………….
CLS
M$ = MID$(S$, I, 1)
REV$ = REV$ + M$
NEXT I
PRINT REV$
END
………………………………………………………………………………..
CLS
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
CLS
A=1
B=1
DO WHILE B<=50
PRINT A
A=A+2
B=B+1
LOOP
END
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
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
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
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
CLS
A=1
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
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, 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
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
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
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
CLS
A=1
B=1
DO
PRINT A
A=A+2
B=B+1
LOOP UNTIL B>50
END
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
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, 25,125……5TH TERM
CLS
A=5
B=1
DO
PRINT A
A=A*5
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
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
CLS
A=1
B=1
10:
PRINT A
A=A+2
B=B+1
IF B<= 50 THEN GO TO 10
END
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, 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
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
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
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
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
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
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
CLS
A=1
B=1
START:
PRINT A
A=A+1
B=B+1
IF B<=100 THEN GO TO START
END
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
AMENDRA
AMENDRA
AMENDRA
AMENDRA
AMENDRA
AMENDRA
AMENDRA
AMENDRA
AMENDRA
AMENDRA
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
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
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
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
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
CLS
A=1
B=1
WHILE B<=50
PRINT A
A=A+2
B=B+1
WEND
END
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
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, 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
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
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