QBASIC Programs ( Class 7 & 8 )
Write a program for the following.
a. To calculate area of a rectangle.
REM PROGRAM TO DISPLAY AREA OF RECTANGLE
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
A = L * B
PRINT “AREA OF RECTANGLE”; A
END
b. To calculate perimeter of a rectangle.
REM PROGRAM TO DISPLAY PERIMETER OF A RECTANGLE
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
P=2(l+b)
PRINT “AREA OF RECTANGLE ”; P
END
c. To calculate area of a circle.
REM PROGRAM TO DISPLAY AREA OF CIRCLE
CLS
INPUT “ENTER RADIUS”; R
A = 3.14 * R ^ 2
PRINT “AREA OF CIRCLE ”; A
END
d. To calculate perimeter of a circle.
CLS
REM PROGRAM TO DISPLAY PERIMETER OF A CIRCLE
INPUT" ENTER THE RADIUS " ;R
LET PERIMETER =22/7*R*2
PRINT " THE AREA OF CIRCLE =" ;PERIMETER
END
e. To calculate sum of two different numbers.
REM PROGRAM TO DISPLAY SUM OF TWO NUMBERS
CLS
INPUT “ENTER THE FIRST NUMBER”; A
INPUT “ENTER THE SECOND NUMBER”; B
C = A + B
PRINT “SUM OF TWO NUMBERS ”; C
END
F. To calculate product of two different numbers.
REM PROGRAM TO DISPLAY PRODUCT OF TWO NUMBERS
CLS
INPUT “ENTER THE FIRST NUMBER”; A
INPUT “ENTER THE SECOND NUMBER”; B
C = A * B
PRINT “PRODUCT OF TWO NUMBERS ”; C
END
g. To calculate difference of two different numbers.
REM PROGRAM TO DISPLAY DIFFERENCE OF TWO NUMBERS
CLS
INPUT “ENTER THE FIRST NUMBER”; A
INPUT “ENTER THE SECOND NUMBER”; B
C = A - B
PRINT “DIFFERENCE OF TWO NUMBERS ”; C
END
H. To input three different numbers and decide the smallest number amongst the three using IF…THEN statement.
REM program to enter any three numbers and find the smallest number
CLS
INPUT "ENTER THE FIRST NUMBER"; A
INPUT "ENTER THE SECOND NUMBER";B
INPUT "ENTER THE THIRD NUMBER"; C
IF A<B AND A<C THEN
PRINT "FIRST NUMBER IS SMALLEST";A
ELSEIF B<A AND B<C THEN
PRINT "SECOND NUMBER IS SMALLEST";B
ELSEIF C<A AND C<B THEN
PRINT "THIRD NUMBER IS SMALLEST";C
ELSE
PRINT "ALL ARE EQUAL"
ENDIF
END
I . To input days of a week and decide "school day" or "holiday" using IF ….THEN statement.
REM PROGRAM TO ENTER ANY DAY FROM SUNDAY TO SATURDAY AND PRINT "SCHOOL DAY" OR "HOLIDAY".
CLS
INPUT "ENTER ANY DAY";DAY$
IF DAY$="SUNDAY" THEN
PRINT "SCHOOL DAY"
ELSEIF DAY$="MONDAY" THEN
PRINT "SCHOOL DAY"
ELSEIF DAY$="TUESDAY" THEN
PRINT "SCHOOL DAY"
ELSEIF DAY$="WEDNESDAY" THEN
PRINT "SCHOOL DAY"
ELSEIF DAY$="THURSDAY" THEN
PRINT "SCHOOL DAY"
ELSEIF DAY$="FRIDAY" THEN
PRINT "SCHOOL DAY"
ELSEIF DAY$="SATURDAY" THEN
PRINT "HOLIDAY"
ELSE
PRINT "INVALID INPUT"
ENDIF
END
J. To decide whether an input number is divided by 5 and 3 or not?
CLS
INPUT "ENTER THE NUMBER";N
IF N/5=0 AND N/3=0 THEN
PRINT "DIVISIBLE"
ELSE
PRINT "NOT DIVISIBLE"
END IF
END
k. To input any number from 0 to 9 and check whether it is single digit number or not using SELECT CASE statement.
CLS
INPUT"ENTER THE NUMBER";N
SELECT CASE N
CASE 0
PRINT "It is single"
CASE 1
PRINT "It is single"
CASE 2
PRINT "It is single"
CASE 3
PRINT "It is single"
CASE 4
PRINT "It is single"
CASE 5
PRINT "It is single"
CASE 6
PRINT "It is single"
CASE 7
PRINT "It is single"
CASE 8
PRINT "It is single"
CASE 9
PRINT "It is single"
CASE ELSE
PRINT "It is not single"
END SELECT
END
l. To input name of the SAARC country and print name of their capital city using SELECT CASE statement.
CLS
INPUT "ENTER THE SAARC COUNTRY NAME";C$
SELECT CASE C$
CASE "NEPAL"
PRINT "KATHMANDU"
CASE "AFGANISTAN"
PRINT "KABUL"
CASE "INDIA"
PRINT "DELHI"
CASE "PAKISTAN"
PRINT ISLAMABAAD
CASE "BANGLADESH"
PRINT "DHAKA"
CASE "BHUTAN"
PRINT "THIMPU"
CASE "MALDIVES"
PRINT "MALE"
CASE "SRI LANKA"
PRINT "COLOMBO"
CASE ELSE
PRINT "ERROR"
END SELECT
END
3. WAP to perform the following using library function.
a. Write a program to return MAN form the word KATHMANDU.
CLS
C$="KATHMANDU"
PRINT MID$(C$,5,3)
END
b. Write a program to return NEP form the word NEPAL.
CLS
C$="NEPAL"
PRINT LEFT$(C$,3)
END
c. Write a program to return PAL form the word NEPAL.
CLS
C$="NEPAL"
PRINT RIGHT$(C$,3)
END
d. Write a program to return ASCII value of letter 'a'.
CLS
PRINT ASC("a")
END
f. Write a program to return RETUPMOC form the word COMPUTER.
REM PROGRAM TO REVERSE A STRING
CLS
C$="COMPUTER"
FOR J=8 TO 1 STEP -1
M$=MID$(C$,J,1)
REV$=REV$+M$
NEXT J
PRINT "REVERSED STRING IS ";REV$
END
1) Write a program to enter your name and print it .
CLS
Input 'Enter your 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 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
4) 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
5) 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
6) 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
7) 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
8) 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
9)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
10) 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
11) 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
12) 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
13) 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
14) 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
15) 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
16) 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
17) 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
18) 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
19) 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
20) 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
21) 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
22) 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
23) 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
24) 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
25) 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
26) 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
Looping
To print multiplication table of INPUT number. [FOR…NEXT]
CLS
INPUT "Enter any number:";n
FOR i=1 TO 10
PRINT N; " X " ; i ; " = " ; n * i
NEXT i
END
a) To print multiplication table of 7. (7x1=7) [FOR…NEXT]
CLS
FOR i=1 TO 10
PRINT 7; " X " ; i ; " = " ; 7 * i
NEXT i
END
b) To print your mother name 15 times. [While….Wend]
CLS
c=1
while c<=15
print "Manisha"
c=c+1
wend
end
c) To print numbers from 15 to 1. [For…NEXT]
CLS
For i = 15 to 1 Step -1
Print i
Next i
End
d) To print sum of odd numbers between 2 and 20. [WHILE….WEND]
CLS
i=2
while i<=20
print i
i=i+2
wend
end
e) To print the series 1, 8, 27, upto 10th terms.
CLS
for i=1 to 10
print i^3
next i
end
f) To print the series 1, 2, 3, 5, 8, ………. upto 10th terms.
CLS
A = 1
B = 1
PRINT A; B;
FOR i = 1 TO 10
C = A + B
PRINT C;
A = B
B = C
NEXT
END
g) To print the following output:
i. 5, 10, 15……upto 50
CLS
i=5
while i<=50
print i
i=i+5
wend
end
ii. 70, 65, 60………upto 10
CLS
For i = 70 to 10 Step -5
Print i
Next i
End
iii. 5, 55, 555 upto 5th terms.
cls
num=5
for i=1 to 5
print num;
num=num*10+5
next i
end
h) Write a program to print the following output of "NEPAL".
i) Cls
s$="NEPAL"
FOR I = 1 TO LEN(S$)
PRINT LEFT$(S$, I)
NEXT I
End
i) Write a program to print input string into reverse order.
CLS
INPUT "ENTER THE TEXT";A$
FOR i=LEN(A$) TO 1 STEP -1
B$=MID$(A$,i,1)
C$=C$+B$
NEXT i
PRINT"THE REVERSE IS:";C$
END
A
ABC - Atnasoff Berry Computer
AC - Alternating Circuit
ACM - Association for Computing Machinery
ADSL - Asymmetric Digital Subscriber Line
AI - Artificial Intelligence
ALR - Advance Logic Research
ALU - Arithmetic and Logic Unit
ANSI - American National Standard Instruction Codes
AOL - America Online
ARCnet - Attached Resources Computer network
ARP - Address Resolution Protocol
ARPA - Advanced Research Project Agency
ASCII - American Standard Code for Information Interchange
AT - Advance Technology
ATM - Automated Teller Machine
B
B - Byte
BASIC - Beginners All Purpose Symbolic Instruction Codes
BCD - Binary Coded Decimal
BCR - Bar Code Reader
BIOS - Basic Input Output System
BMP - Bitmap
BNC - Bayone Neill Councilman
BIT - Binary Digits
BPS - Bytes Per Second
C
CA - Collision Avoidance
CAD - Computer Aided Design
CAI - Computer Aided Instruction
CAL - Computer Aided Learning
CAM - Computer Aided Manufacturing
CAN - Campus Area Network
CASE - Computer Aided Software Engineering
CBE - Computer Based Education
CBT - Computer Based Training
CD - Compact Disk ; Collision Detection
CD-R - Compact Disk Recordable
CD-RW - Compact Disk Read Write
CGA - Colored Graphics Adapter
CGI - Common Gateway Interface
CISC - Complex Instruction Set Computer
CMOS - Complementary Metal Oxide Semiconductor
COBOL - Common Business Oriented Language
COM - Computer Program for Micro Computer
COMPUTER - Commonly Operated Machine Particularly Used in Trade Education and
Research
CP/M - Computer Program For Microfilm
CPI - Character Per Inch
CPU - Central Processing Unit
CRT - Cathode Ray Tube
CSMA - Carrier Sense Multiple Access
CSU - Channel Service Unit
CU - Control Unit
CUI - Character User Interface
D
DARPA - Defense Advance Research Project Agency
DAT - Digital Audio Tape
DBMS - Data Base Management System
DNA - Digital Network Architecture
DNS - Domain Name Service
DOS - Disk Operating System
DRAM - Dynamic Random Access Memory
DSDD - Double Sided Double Density
DSHD - Double Sided High Density
DSSD - Double Sided Single Density
DSU - Digital Service Unit
DTD - Document Type Definations
DTP - Desktop Publishing
DVD - Digital Versatile/Video Disk
DVD-R - Digital Versatile/Video Disk Recordable
DVD-RW - Digital Versatile/Video Read Write
E
EBCDIC - Extend Binary Coded Decimal Interchange Code
E-Bank - Electronic Bank
E-Commerce - Electronic Commerce
EDI - Electronic Data Interchange
EDP - Electronic Data Processing
EDSAC - Electronic Delay Storage Automatic Computer
EDVAC - Electronic Discrete Variable Automatic Computer
EEPROM - Electronically Erasable Programmable Read Only Memory
E-Government - Electronic Government
E-Fax - Electronic Fascinated Exchange
E-Mail - Electronic Mail
EMI - Electro Magnetic Interface
ENIAC - Electronic Numerical Integrator and Calculator
EPROM - Electrically Programmable Read Only Memory
E-Service - Electronic Commerce
F
FAQ - Frequently Asked Question
FAT - File Allocation Table
FDDI - Fiber Distributed Data Interface
FLOPS - Floating Point Instruction Per Second
FM - Frequency Modulation
FMC - Flight Management Computer
FORTAN - Formula Translation
FTP - File Transfer Protocol
G
G2G - Government To Government
G2B - Government To Business
G2C - Government To Citizens
GaAs - Gallium Arsenide
GB - Giga Byte
GBPS - Giga Byte Per Second
GHz - Giga Hertz
GIF - Graphic Interchange Format
GIGO - Garbage-In-Garbage-Out
GL - Generation Language
GPL - General Public Language
GUI - Graphical User Interface
H
HD - High Definition
HLCIT - High Level Commission for Information Technology
HLL - High Level Language
HMD - Head Mounted Display
HTML - Hyper Text Markup Language
HTTP - Hyper Text Transfer Protocol
Hz - Hertz
I
IAB - Internet Architecture Board
IBM - International Business Machine
IC - Integrated Circuit
ICT - Information and Communication Technologies
IEEE - Institute of Electrical and Electrical Engineers
IETF - Internet Engineering Task Force
INIC - Internet Network Information Centre
IP - Internet Protocol
IPX - Internetworked Packet Exchange
IPO - Input Process Output
IRC - Internet Relay Chat
ISDN - Integrated Service Digital Network
ISP - Internet Service Provider
IT - Information Technology
IU - Input Unit
J
JPEG - Joint Picture Expert Group
JIT - Just in Time
K
KB - Kilo Byte
KBPS - Kilo Byte per Second
L
LAN - Local Area Network
LCD - Liquid Crystal For Display
LED - Light Emitting Diodes
LISP - List Processor
LLL - Low Level Language
LPM - Lines Per Minute
LSI - Large Scale Integration
M
MAC - Media Access Control
MAN - Metropolitan Area Network
MB - Mega Bytes
MBPS - Mega Bytes Per Second
MCGA - Multi Colored Graphics Adapter
MF2HD - Micro Floppy Disk Doubled Sided High Density
MHz - Mega Hertz
MICR - Magnetic Ink-Character Reader
MIDI - Musical Instrument Digital Interface
MILNET - Military Network
MLL - Machine Level Language
MODEM - Modulator And Demodulator
MOS - Metal Oxide Semiconductor
MOST - Ministry of Science and Technology
MPEG - Moving Picture Expert Group
MS - Microsoft
MSI - Medium Scale Integration
MU - Memory Unit
N
NAV - Norton Antivirus
NEC - Nippon Electronics
NIC - Network Interface Card
NOS - Network Operating System
O
OCR - Optical Character Reader
OMR - Optical Character Reader
OOP - Object Oriented Program
OS - Operating System
OSS - Open Source Software
OU - Output Unit
P
PARC - Palo Alto Research centre
PC - Personal Computer
PCB - Printed Circuit Board
PCI - Peripheral Component Interconnect
PDA - Personal Digital Assistant
PDF - Platform Independent Document Format
PKI - Public Key Infrastructure
PL - Programming Language
PM - Phase Modulation
POP - Post Office Protocol
POS - Point of Sales
POST - Power On Self Test
PROLOG - Programming Logic
PROM - Programmable Read Only Memory
PS - Personal System
PSTN - Public Switched Telephone Network
Q
QB - Q-Basic
R
R - Recordable
RAM - Read Only Memory
RDBMS - Relational Data Base Management System
RISC - Reduced Instruction Set Computer
RJ - Register Jack
ROM - Random Access Memory
RPG - Report Program Generator
RW - Read Write / Rewriteable
S
SDRAM - Synchronous Dynamic Random Access Memory
SGML - Standard Generalized Markup Language
SIMM - Single IN-Line Memory Module
SMPS - Switch Mode Power Supply
SMTP - Simple Mail Transfer Protocol
SNA - System Network Architecture
SNOBOL - String Oriented Symbolic Language
SPX - Sequenced Packet Exchange
SRAM - Static Random Access Memory
SSDD - Single Sided Double Density
SSHD - Single Sided High Density
STP - Shielded Twisted Pair
SVGA - Super Video Graphics Array
T
TB - Terra Byte
TBPS - Terra Byte Per Second
TCP - Transfer Control Protocol
TLD - Top Level Domain
TPC - Twisted Pair Cable
U
UCITA - Uniform Computer Information Transaction Act
UDT - User Data Type
UHF - Ultra High Frequency
ULSI - Ultra Large Scale Integration
ULSIC - Ultra Large Scale Integrated Circuit
UNCITRAL - United Nations Commission on International Trade Law
UNIVAC - Universal Automatic Computer
UPS - Uninterruptible Power Supply
URL - Uniform Resource Locator
USB - Universal Serial Bus
UTP - Unshielded Twisted Pair
V
VB - Visual Basic
VDT - Video Display Terminal
VGA - Video Graphics Adapter
VLSI - Very Large Scale Integration
VLSIC - Very Large Scale Integrated Circuit
VPN - Virtual Private Network
VOIP - Voice Over Internet Protocol
VSAT - Very Small Aperture Terminal
W
WAN - Wide Area Network
WMA - Windows Media Audio
WMV - Windows Media Vedio
WORM - Write Once Read More
WWW - World Wide Web
X
XML - Extensible Markup Language
XT - Extended Technology
Y
Z
Others
2D - Two Dimension
3D - Three Dimension
3G - Third Generation
4D - Four Dimension
4Gl - 4th Generation Language
because of this website i can do best in my exam
ReplyDelete