1. Fill in the blanks:
a. reserved
b. assignment statement
c. two similar
d. DATA
e. non-executable
f. explicitly
g. symbolic
h. printer
i. implicit declaration
j. 255
2. State True or fasle
a. True
b. True
c. True
d. False
e. True
f. False
g. False
h. True
3. Write the purpose and syntax of the following:
a. LET
Purpose:
LET is used to assign a value to a variable.
Syntax:
[LET] variable = value
b. INPUT
Purpose:
Execution pauses, a user can enter data from the keyword and execution continues.
Syntax:
INPUT ["input prompt"][;][,] Variable, Variable ....
c. LPRINT
Purpose:
The LPRINT statement causes the PRINT statements to be directed to the printer instead of directing to the screen.
Syntax:
LPRINT [Expression list][, or ;]
d. CONST
Purpose:
It declares one or more symbolic constants.
Syntax:
CONST CONSTNAME = EXPRESSION
e. SWAP
Purpose:
The SWAP statement is used to exchange the values of two similar types of variables or array elements.
Syntax:
SWAP variable1, variable2
f. READ ...DATA
Purpose:
When it is necessary to supply a fixed list of data then READ-DATA statements are suitable.
Syntax:
READ Variable1, Variable2,.... DATA item1, item2,....
g. DIM
Purpose:
DIM declares simple variables or array variables with their data types(integer, long integer, single precision , double precision, string) at the beginning of a program.
Syntax:
DIM Var1[Subscripts] [AS data type], Var2 [Subscripts] [As data type]
h. LINE INPUT
Purpose:
The LINE INPUT statement reads the line up to 255 characters from the keyboard or file.
Syntax:
LINE INPUT [PROMPT;] Variable$
4. Write the statements for the following:
a. To declare numeric variable 'N' explicitly
Ans: DIM N AS INTEGER
b. To assign 15 to a numeric variable "X"
Ans: X=15
c. To declare the string variable "A$" explicitly
Ans: DIM A AS STRING
d. To declare a single precision variable explicitly
Ans: DIM A AS SINGLE
e. To exchange values between two numeric variables
Ans: SWAP A,B
f. To exchange values between two string variables
Ans: SWAP A$,B$
g. To store value of PI(π) to a symbolic constant
Ans: CONST PI=3.14
h. To input Name, Post and Salary using a single INPUT statement
Ans : INPUT " Enter name, post and salary " ; NAME$ , POST$ , SALARY
i. To store a string to the string variable
Ans: N$="Rosebud"
j. To store a number to a numeric variable
Ans: N=123
5. Write algorithm and draw flowchart for the following:
a. To input the radius and to calculate the area of circle
Ans:
Algorithm to input the radius and to calculate area of circle
Step 1: Start
Step 2: Input R
Step 3: A=3.14*R*R
Step 4: Print A
Step 5: Stop
Flowchart to input the radius and to calculate area of circle
b. To input minutes and to convert it into hours and minutes
Algorithm to input minutes and to convert it into hours and minutes
Step 1: Start
Step 2: Input min
Step 3: hr=min/60 and m=min mod 60
Step 4: Print hr and m
Step 5: Stop
Flowchart to input minutes and to convert it into hours and minutes
c. To input days and convert it into months, weeks and days
Ans:
Algorihtm to input days and convert it into months, weeks and days
Step 1: Start
Step 2: Input days as d
Step 3: month=d\30 , d1=d mod 30 , weeks=d1\7 and days=d2 mod 7
Step 4: Print month, weeks and days
Step 5: Stop
Flowchart to input days and convert it into months, weeks and days
d. To input amount in US dollar and convert it into Nepali rupee
Algorithm to input amount in US dollar and convert it into Nepali rupee
Step 1: Start
Step 2: Input USD
Step 3:NPR=USD*133.31 (dated 11/28/2023)
Step 4: Print NPR
Step 5: Stop
Flowchart to To input amount in US dollar and convert it into Nepali rupee
6. write QBASIC program codes for the following:
a.Write a program to read Nepali rupees and convert it into US dollar.
CLS
INPUT NPR
USD=NPR/133.31
REM dated 11/28/2023
PRINT USD
END
b.Write a program to input length and breadth then find the area of a rectangle.(Area=L*B)
CLS
INPUT L,B
A=L*B
PRINT A
END
c.Write a program to read two different numbers.Find out the sum, product and the difference.
CLS
INPUT A,B
S=A+B
P=A*B
D=A-B
PRINT S,P,D
EMD
d.Write a program to input days then convert it into years, month and days.
CLS
INPUT D
Y=D\365
D1=D MOD 365
M=D1\30
D2=D1 MOD 30
PRINT Y,M,D2
END
e.Write a program to read minutes from the keyboard and convert it into hours and minutes.
CLS
INPUT M
HR=M\60
MIN=M MOD 60
PRINT HR,MIN
END
f.Write a program to calculate the volume of a cuboid where Vol=(L*B*H).
CLS
INPUT L,B,H
VOL=L*B*H
PRINT VOL
END
g.Write a program to calculate the volume of a cube where Vol=(L*L*L).
CLS
INPUT L
VOL=L^3
PRINT VOL
END
h.Write a program to calculate the total surface area of a cube where TSA= 6L^2
CLS
INPUT L
TSA=6*L^2
PRINT TSA
END
i.Write a program to calculate the total surface area of a cuboid where TSA= 2(lb+bh+lh).
CLS
INPUT L,B,H
TSA=2*(L*B+B*H+L*H)
PRINT TSA
END
j.Write a program to calculate the principal amount where PA= (SI*100)/(R*T).
CLS
INPUT SI,R,T
PA=(SI*100)+(R*T)
PRINT PA
END
k.Write a program to read cost price and selling price of an item using the READ-DATA statement. Find the loss percentage using the formula, where L%= ((CP-SP)/CP)*100.
CLS
INPUT SP,CP
L%=((CP*SP)/CP)*100
PRINT L%
END
l.Write a program to input degree in Celsius and convert it into Fahrenheit where F= (9*C/5)+32.
CLS
INPUT C
F=(9*C/5)+32
PRINT F
END
m.Write a program to read selling price and profit percentage using READ-DATA. Calculate the cost price using the formula CP= (SP*100)/(100+Profit%).
CLS
INPUT SP,P%
CP=(SP*100)/(100+P%)
PRINT CP
END
n.Write a program to input a number then find 10%, 20% and 30% of that number.
CLS
INPUT N
A=(N*10)/100
B=(N*20)/100
C=(N*30)/100
PRINT A
PRINT B
PRINT C
END
End of chapter-17