Easy QBasic Programs for Beginners
1) To print Hello World-
CLS
PRINT "Hello World"
END
2) To enter your name and print it-
CLS
INPUT "Enter your name : ";a$
PRINT "Your name is : ";a$
END
PRINT "1. Add"
PRINT "2. Subtraction"
PRINT "3. Multiply"
PRINT "4. Division"
PRINT "5. Exit"
INPUT "Enter your choice:"; a
INPUT "Enter first number:"; x
INPUT "Enter second number:"; y
SELECT CASE a
CASE 1: PRINT "Sum = "; x + y
CASE 2: PRINT "Difference = "; x - y
CASE 3: PRINT "Product = "; x * y
CASE 4: PRINT "Quotient = "; x / y
CASE 5: PRINT "Exiting..."
SLEEP
END
CASE ELSE: PRINT "Invalid Entry"
END SELECT
END
INPUT n
a = n
s = 0
WHILE n <> 0
r = n MOD 10
s = s + r ^ 3
n = n \ 10
WEND
IF a = s THEN
PRINT a; "IS ARMSTRONG"
ELSE
PRINT a; "IS NOT ARMSTRONG"
END IF
END
5) Automorphic Number
CLS
INPUT a
s = 0
m = a ^ 2
WHILE m <> 0
s = s + 1
m = m \ 10
WEND
IF m = m mod 10 ^ s THEN
PRINT "Automorphic"
ELSE
PRINT "Not Automorphic"
END IF
END
6)Prime Number
CLS
LET M$ = "Y"
DO
INPUT "ENTER ANY NUMBER"; N
C = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN C = C + 1
NEXT I
IF C = 2 THEN
PRINT N; "IS PRIME NUMBER"
ELSEIF C = 1 THEN
PRINT N; "IS NEITHER PRIME NOR COMPOSITE"
ELSE
PRINT N; "IS COMPOSITE NUMBER"
END IF
INPUT "Do you want to continue?"; M$
LOOP WHILE M$ = "Y" OR M$ = "y"
END
7)Complex calculator (Menu Based)
CLS
DO
PRINT "1) ADD"
PRINT "2) SUBTRACT"
PRINT "3) MULTIPLY"
PRINT "4) DIVIDE"
PRINT "5) PRINT SQUARE OF THE NUMBER"
PRINT "6) PRINT CUBE OF THE NUMBER"
PRINT "7) SQUARE ROOT"
PRINT "8) CUBE ROOT"
INPUT "Enter Your Choice : ";a
ON a GOSUB 1,2,3,4,5,6,7,8
INPUT "Do you want to continue?(Y/N)";A$
LOOP WHILE A$="Y" OR A$="y"
END
1:
INPUT "Enter first number : ";a
INPUT "Enter second number : ";b
PRINT "Sum = ";a+b
RETURN
2:
INPUT "Enter first number : ";a
INPUT "Enter second number : ";b
PRINT "Differenece = ";a-b
RETURN
3:
INPUT "Enter first number : ";a
INPUT "Enter second number : ";b
PRINT "Product = ";a*b
RETURN
4:
INPUT "Enter first number : ";a
INPUT "Enter second number : ";b
PRINT "Quotient = ";a/b
RETURN
5:
INPUT "Enter number : ";a
PRINT "Square = ";a^2
RETURN
6:
INPUT "Enter number : ";a
PRINT "Cube = ";a^3
RETURN
7:
INPUT "Enter number : ";a
PRINT "Square Root = ";a^(1/2)
RETURN
8:
INPUT "Enter number : ";a
PRINT "Cube Root = ";a^(1/3)
RETURN
8) Area of rectangle, square, circle, triangle
CLS
DO
INPUT "Enter your choice (1/2/3/4)"; a
ON a GOSUB rect, squa, circ, tria
INPUT "Do you want to continue"; a$
LOOP WHILE a$ = "Y" OR a$ = "y"
END
rect:
INPUT "Enter Length:"; l
INPUT "Enter Breadth:"; b
PRINT "Area = "; l * b
RETURN
squa:
INPUT "Enter Side:"; s
PRINT "Area = "; s ^ 2
RETURN
circ:
INPUT "Enter Redius:"; r
PRINT "Area = "; 22 / 7 * r * r
RETURN
tria:
INPUT "Enter Base:"; b
INPUT "Enter Height:"; h
PRINT "Area = "; 1 / 2 * b * h
RETURN
9) Simple Interest
CLS
INPUT "Enter Principal, Rate and Time";p,r,t
PRINT "Simple Interest = ";(p*r*t)/100
END
10) Perimeter of Rectangle
CLS
INPUT "Enter Length and Breadth";l,b
PRINT "Perimeter = ";2*(l+b)
END
11) Perimeter of Square
CLS
INPUT "Enter Side";s
PRINT "Perimeter = ";s*4
END
12) Circumference
CLS
INPUT "Enter Radius:"; r
PRINT "Area = "; 2 * r * 22 / 7
END
1) To print Hello World-
CLS
PRINT "Hello World"
END
2) To enter your name and print it-
CLS
INPUT "Enter your name : ";a$
PRINT "Your name is : ";a$
END
3) Simple Menu Based Calculator
CLSPRINT "1. Add"
PRINT "2. Subtraction"
PRINT "3. Multiply"
PRINT "4. Division"
PRINT "5. Exit"
INPUT "Enter your choice:"; a
INPUT "Enter first number:"; x
INPUT "Enter second number:"; y
SELECT CASE a
CASE 1: PRINT "Sum = "; x + y
CASE 2: PRINT "Difference = "; x - y
CASE 3: PRINT "Product = "; x * y
CASE 4: PRINT "Quotient = "; x / y
CASE 5: PRINT "Exiting..."
SLEEP
END
CASE ELSE: PRINT "Invalid Entry"
END SELECT
END
4)Armstrong number
CLSINPUT n
a = n
s = 0
WHILE n <> 0
r = n MOD 10
s = s + r ^ 3
n = n \ 10
WEND
IF a = s THEN
PRINT a; "IS ARMSTRONG"
ELSE
PRINT a; "IS NOT ARMSTRONG"
END IF
END
5) Automorphic Number
CLS
INPUT a
s = 0
m = a ^ 2
WHILE m <> 0
s = s + 1
m = m \ 10
WEND
IF m = m mod 10 ^ s THEN
PRINT "Automorphic"
ELSE
PRINT "Not Automorphic"
END IF
END
6)Prime Number
CLS
LET M$ = "Y"
DO
INPUT "ENTER ANY NUMBER"; N
C = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN C = C + 1
NEXT I
IF C = 2 THEN
PRINT N; "IS PRIME NUMBER"
ELSEIF C = 1 THEN
PRINT N; "IS NEITHER PRIME NOR COMPOSITE"
ELSE
PRINT N; "IS COMPOSITE NUMBER"
END IF
INPUT "Do you want to continue?"; M$
LOOP WHILE M$ = "Y" OR M$ = "y"
END
7)Complex calculator (Menu Based)
CLS
DO
PRINT "1) ADD"
PRINT "2) SUBTRACT"
PRINT "3) MULTIPLY"
PRINT "4) DIVIDE"
PRINT "5) PRINT SQUARE OF THE NUMBER"
PRINT "6) PRINT CUBE OF THE NUMBER"
PRINT "7) SQUARE ROOT"
PRINT "8) CUBE ROOT"
INPUT "Enter Your Choice : ";a
ON a GOSUB 1,2,3,4,5,6,7,8
INPUT "Do you want to continue?(Y/N)";A$
LOOP WHILE A$="Y" OR A$="y"
END
1:
INPUT "Enter first number : ";a
INPUT "Enter second number : ";b
PRINT "Sum = ";a+b
RETURN
2:
INPUT "Enter first number : ";a
INPUT "Enter second number : ";b
PRINT "Differenece = ";a-b
RETURN
3:
INPUT "Enter first number : ";a
INPUT "Enter second number : ";b
PRINT "Product = ";a*b
RETURN
4:
INPUT "Enter first number : ";a
INPUT "Enter second number : ";b
PRINT "Quotient = ";a/b
RETURN
5:
INPUT "Enter number : ";a
PRINT "Square = ";a^2
RETURN
6:
INPUT "Enter number : ";a
PRINT "Cube = ";a^3
RETURN
7:
INPUT "Enter number : ";a
PRINT "Square Root = ";a^(1/2)
RETURN
8:
INPUT "Enter number : ";a
PRINT "Cube Root = ";a^(1/3)
RETURN
CLS
DO
INPUT "Enter your choice (1/2/3/4)"; a
ON a GOSUB rect, squa, circ, tria
INPUT "Do you want to continue"; a$
LOOP WHILE a$ = "Y" OR a$ = "y"
END
rect:
INPUT "Enter Length:"; l
INPUT "Enter Breadth:"; b
PRINT "Area = "; l * b
RETURN
squa:
INPUT "Enter Side:"; s
PRINT "Area = "; s ^ 2
RETURN
circ:
INPUT "Enter Redius:"; r
PRINT "Area = "; 22 / 7 * r * r
RETURN
tria:
INPUT "Enter Base:"; b
INPUT "Enter Height:"; h
PRINT "Area = "; 1 / 2 * b * h
RETURN
9) Simple Interest
CLS
INPUT "Enter Principal, Rate and Time";p,r,t
PRINT "Simple Interest = ";(p*r*t)/100
END
10) Perimeter of Rectangle
CLS
INPUT "Enter Length and Breadth";l,b
PRINT "Perimeter = ";2*(l+b)
END
11) Perimeter of Square
CLS
INPUT "Enter Side";s
PRINT "Perimeter = ";s*4
END
12) Circumference
CLS
INPUT "Enter Radius:"; r
PRINT "Area = "; 2 * r * 22 / 7
END
Easy Qbasic Programs For Beginners ~ Tecmk >>>>> Download Now
ReplyDelete>>>>> Download Full
Easy Qbasic Programs For Beginners ~ Tecmk >>>>> Download LINK
>>>>> Download Now
Easy Qbasic Programs For Beginners ~ Tecmk >>>>> Download Full
>>>>> Download LINK AN