Monday, September 25, 2017

Looping Structure - Find Output [22 Programs] SEE Qbasic Practice PART I

1.      DECLARE SUB Result()
CLS
CALL Result
END
SUB Result
A=1
FOR I = 1 TO 5
PRINT I*A
A=A+(10^I)
NEXT I
END SUB

2.      DECLARE SUB SHOW ()
CLS
CALL SHOW
END
SUB SHOW
X=30
Y=10
FOR C= 1 TO 2
PRINT X; Y;
X=X\Y
Y=X-Y
NEXT C
END SUB

3.      DECLARE SUB Show ( )
CLS
CALL Show
END
SUB Show
C=3
B=2
FOR I=2 TO 8 STEP 2
PRINT C,
SWAP B, C
B=C+1
NEXT I
END SUB

4.      DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES ( )
FOR J = 8 TO 2 STEP-2
PRINT D;
SWAP D, B
D = B + 1
NEXT J
END SUB

5.      DECLARE SUB SERI ( )
CLS
CALL SERI
END
SUB SERI ( )
N=1
FOR I=1 TO 10
PRINT N;
N=N+2
NEXT I
END SUB

6.      DECLARE SUB Series()
CALL Series
END
SUB Series
X=1
Y=1
FOR Z=1 TO 4
PRINT X;
Y=Y+1
X=X*10+Y
NEXT Z
END SUB

7.      DECLARE SUB Series( )
CALL Series
END

SUB Series
A=2
B=2
For ctr=1 to 2
PRINT A; B;
A= A+B
B=A+B
Next ctr
END SUB

8.      DECLARE SUB Result ( )
CALL Result
END

SUB Result
For I = 1 to 9 STEP 2
Sum=Sum +I^2
Next I
PRINT Sum
END SUB

9.      DECLARE SUB SERIES()
CLS
CALL SERIES
END

SUB SERIES( )
X=11111
FOR I= 1 TO 5
PRINT X^2
X = (X - 1) / 10
NEXT I
END SUB



10.   DECLARE SUB SER ( )
CALL SER
END

SUB SER
A=1
B=1
FOR I=1 TO 10 STEP 2
PRINT A*B
A=A*10 + 1
B=B+1
NEXT I
END SUB

11.   DECLARE SUB num ( )
CLS
CALL num
END

SUB num
F = 2
S = 1
FOR K = 5 TO 1 STEP -1
A = A + S
PRINT A
S = S + F
NEXT K
END SUB

12.   DECLARE SUB skill( )
CLS
CALL skill
END

SUB skill
LET N=5
LET A=4
FOR  J = 1 TO 5 STEP 1
PRINT N
N=N*10+A
A=A+1
NEXT  J
END SUB

13.   DECLARE SUB RESULT ( )
CLS
CALL RESULT
END

SUB RESULT ( )
Z = 3
FOR A = 1 TO 10
PRINT (A^2)*Z
NEXT A
END SUB

14.   DECLARE SUB SHOW( )
CLS
CALL SHOW
END

SUB SHOW ( )
A = 15
FOR I = 1 TO 4
PRINT A MOD I + 2
SUM = SUM + A \ 10
A = A – 1
NEXT I
PRINT SUM
END SUB

15.   DECLARE SUB SERI()
CLS
CALL SERI
END

SUB SERI()
FOR I= 1 TO 4
FOR J=1 TO I
PRINT (I+J)*10;
NEXT J
PRINT
NEXT I
END SUB

16.   DECLARE SUB CHECK ()
CALL CHECK
END

SUB CHECK
CLS
FOR K = 1 TO 5
FOR I = 5 TO K STEP -1
PRINT I;
NEXT I
PRINT
NEXT K
END SUB

17.   DECLARE SUB FIND(N)
CLS
N=654
CALL FIND(N)
END

SUB FIND(N)
WHILE N < > 0
R= N MOD10
P= P*10 + R
N= N \ 10
WEND
PIRNT P
END SUB

18.   DECLARE SUB SERIES()
CALL SERIES
END

SUB SERIES()
R=2
M=5
WHILE M>=1
PRINT R
R=R*10+2
M=M-1
WEND
END SUB

19.   DECLARE SUB SERU ()
CALL SERU
END
SUB SERU ()
X =2
C =1
WHILE C <=10
S =X^C
PRINT S
C =C+1
WEND
END SUB

20.   DECLARE SUB PER(P)
P=15
CALL SER(12)
END

SUB SERIES (P)
M=3
WHILE M<7
PR=M*P
PRINT PR,
M=M+2
WEND
END SUB

21.   CLS
X=0
Y=0
C=1
WHILE C<=10
CALL Variance ((X), Y)
C=C+1
WEND
END

SUB Variance (A,B)
A=A+10
B=B+10
PRINT A, B
END SUB

22.   DECLARE SUB RESULT()
CALL RESULT
END

SUB RESULT
N=7
C=5
DO UNTIL C=1
PRINT N
N=N*10+7
C=C-1
LOOP
END SUB

Saturday, September 23, 2017

Selection Structure – Find Output [SEE QBASIC PRACTICE]

Write the output of the following programs: [10 Programs]



1.     DECLARE SUB TEST(NUM)
CLS
CALL TEST(-5)
CALL TEST(5)
CALL TEST(0)
END

SUB TEST(NUM)
SELECT CASE NUM
CASE IS < 0
M$ = “Negative”
CASE IS > 0
M$ = “Positive”
CASE ELSE
M$ = “Zero”
END SELECT
PRINT NUM; ”is”; M$
END SUB

2.     DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES ( )
A = 1
B = 1
PRINT A; B;
X:
LET C = A + B
PRINT C
LET A = B
LET B = C
IF C <= 8 THEN GOTO X
END

3.     DECLARE SUB MIN(A, B)
CLS
A = 5
B = 10
CALL MIN(A, B)
END

SUB MIN(A, B)
IF A < B THEN
C = A + 5
PRINT C
ELSE
PRINT B ^ 2
END IF
END SUB

4.     DECLARE SUB OUTP(A$)
CLS
A$ = “COMPUTER”
CALL OUTP(A$)
END

SUB OUTP(A$)
B = LEN(A$)
C = 1
LAB:
PRINT LEFT$(A$, C)
C = C + 1
IF C <= B THEN GOTO LAB
END SUB

5.     DECLARE SUB OUTPOOT(L, B)
CLS
LET L = 15
LET B = 10
CALL OUTPOOT(L, B)
CALL OUTPOOT(3, 6)
END

SUB OUTPOOT(L, B)
IF L < B THEN
PRINT L
ELSE
PRINT
PRINT B
END IF
END SUB

6.     DECLARE SUB FEBON(P, Q)
CLS
R = 2 : S = 1
CALL FEBON(R, S)
END

SUB FEBON(P, Q)
T = 1
PRINT P; Q;
LAB:
LET U = P + Q
PRINT U;
P = Q
Q = U
T = T + 1
IF T <=8 THEN GOTO LAB
END SUB

7.     DECLARE SUB OTP( )
CLS
CALL OTP
END

SUB OTP ( )
CLS
A = 4
B = 5
C = A ^ 3 - B ^ 2
D = C - A + B
E = C \ D
F = C MOD D
IF E > F THEN
PRINT "HOW LOGICAL"
ELSE
PRINT "NO LOGIC AT ALL"
END IF
END
END SUB

8.     DECLARE FUNCTION OUT(A, B)
CLS
D = OUT(17, 7)
PRINT D
END

FUNCTION OUT(A, B)
R = A MOD B
IF R MOD 2 = 0 THEN
C = R MOD 6 + 30
ELSE
C = R MOD 6 + 15
END IF
D = C \ 5
OUT = D
END FUNCTION

9.     DECLARE FUNCTION ABC(A, B, C)
CLS
X = 10
Y = 20
Z = 30
G = ABC(X, Y, Z)
PRINT G
END
FUNCTION ABC(A, B, C)
IF A>B AND A<C OR A<B AND A>C THEN
GG = A
ELSEIF B>A AND B<C OR B<A AND B>C THEN
GG = B
ELSE
GG = C
END IF
ABC = GG
END FUNCTION

10.  DECLARE FUNCTION amt(q, r)
CLS
READ q, r
DATA 5000, 10
PRINT “Amount=”; amt(q, r)
END

FUNCTION amt(q, r)
IF (q > 1000) THEN dis = 10
total = (q* r) – (q* r *dis / 100)
amt = total
END FUNCTION


***

Sequential Structure – Find Output [SEE Qbasic Practice]

Write the output of the following programs: [12 Programs]

1.      DECLARE FUNCTION Interest (p,q,r)
CLS
LET p = 30
LET t = 40
LET r = 6
LET d = Interest (p, t, r)
PRINT “The simple interest will be”; d
END

FUNCTION Interest (p, t, r)
answer= (p*t*r) /100
Interest=answer
END FUNCTION

2.      DECLARE FUNCTION Interest (p,t,r)
CLS
LET p = 100
LET t = 2
LET r = 5
LET d = Interest (p, t, r)
PRINT "The simple interest =" ; d
END

FUNCTION Interest (p, t, r)
ans= (p*t*r) /100
Interest=ans
END FUNCTION

3.      DECLARE FUNCTION AREA (A,B)
CLS
LET A = 30
LET B = 40
LET D = AREA(A,B)
PRINT D
END

FUNCTION AREA(A,B)
PRINT A, B
AREA=A*B
END FUNCTION

4.      DECLARE FUNCTION AREA(L, B)
LET L = 10
LET B = 5
PRINT “The area=”; AREA(L, B)
END
FUNCTION AREA(L, B)
A = L*B
AREA = A
END FUNCTION

5.      DECLARE FUNCTION AVGE(A, B, C)
X=10
Y=5
Z=15
AV= AVGE(X, Y, Z)
RPINT “Average of three numbers”; AV
END

FUNCTION AVGE(A, B, C)
S=A+B+C
AVGE = S/3
END FUNCTION

6.      DECLARE   FUNCTION   Area (L,B)
LET   L = 100
LET   B = 20
LET   ans = Area (L,B)
PRINT  “The area is”; ans
END

FUNTION   Area (L, B)
ar = L * B
Area = ar
END FUNCTION


7.      DECLARE FUNCTION SQUARE (number)
CLS
Number = 9
num = SQUARE (number)
PRINT num; “square=”; num
END

FUNCTION SQUARE (number)
SQUARE = number * number
END FUNCTION

8.      DECLARE FUNCTION AREA(L, B)
CLS
LET length = 50
LET breadth = 60
PRINT AREA (length, breadth)
PRINT AREA (10, 20)
END

FUNCTION AREA (L, B)
AREA = L * B)
END FUNCTION


9.      DECLARE SUB PAT (A)
A= -144
CALL PAT (A)
END

SUB PAT(A)
B=ABS(A)
C= SQR(B)
D=C MOD 2
PRINT A, B, C, D
END SUB

10.   DECLARE SUB output (N$, A)
NAME$ = “SADEEP”
AGE = 17
CALL output (NAME$, AGE)
CALL output (Sita, 20)
END

SUB output (N$, A)
PRINT “Hello”; N$
PRINT “You are”; A; “years old”
END SUB

11.   DECLARE SUB SHOW (S)
CLS
CALL SHOW (534)
END

SUB SHOW (N)
A = N MOD 10
B = N \ 10
C = B MOD 10
D = INT (N / 100)
PRINT “Ans=”; A + C + D
END SUB

12.   DECLARE SUB VOL (L, B, H)
CLS
LET L1 = 20
LET B1 = 14
LET H1 = 2
CALL VOL(L1, B1, H1)
END

SUB VOL (L, B, H)
LET V = L * B * H
PRINT “Volume=”; V
END SUB


***

Tuesday, August 15, 2017

QBASIC FILE HANDLING Program Question SLC 2065 TO SEE 2072

1     1. Create a sequential file “std.dat” to store name and marks obtained in English, math and science subjects for a few students. (74 set 1)
2.      A data file “INFO.INF” has numerous records in it with name,  address and telephone numbers in each record. WAP to scan all the records from the file and display only the records with address “bhaktapur”(74 set 2)
3.      A sequential data file “text.txt” contains students name, marks of English, math and computer. WAP to display all the records of students whose percentage is more than 60.3.
4.      WAP to add some more  records in a data file “ABC.DAT” having following fields : patient’s name, address and age. (74 set 4)
5.      A sequential data file “std.dat” contains name, class, roll no and address of some students. WAP to read records and display only those record whose name starts with alphabet “A”.(74 set 5)
6.      WAP to store records regarding the information of book’s number, name and author’s name in a sequential data file named “Library.dat”(slc 65 re-334 set 1)
7.      A sequential data file called “MARKS.DAT” contains roll no, name, English, nepali, and math field. WAP to display all the contents of the data file.(slc 65 sup set 2)
8.      WAP to create a sequential data file “Employee.dat” to store employee’s name, address, age, gender and salary.(slc 2066 re-334 set 3)
9.      A data file “LIB.TXT” contains Book’s name, author’s name and price of books. WAP to count and display total number of record present in a file. (slc 66 sup set 4)
10.   A sequential data file “EMP.DAT” contains name, post and salary fields. WAP to display all the information of employees along with tax amount i.e. 15% of salary. (slc 67 re-334 set 5)
11.   A sequential data file called “MARKS.DAT” contains roll no, name, English, nepali and maths fields. WAP to display all the contents of the data file.(slc 67 sup set – 6)
12.   A sequential data file called “student.dat” contains record under the fields name, English , nepali and computer. WAP to add some more records in the same sequential data file. (slc 68 re-334 set 7)
13.   WAP to view those records from “Employee.dat” sequential data file having employee’s name, department, appointment data and salary whose salary is more than RS. 5000.((slc 68 sup set – 8 )
14.   WAP to create a data file “teldir.dat” to store name, address and telephone number of employee’s according to the need of the user.(slc 69 re-334 set 9)
15.   A sequential data file “marks.dat” contains name, English , nepali, maths, and science fields. WAP to display all contents of data file.(slc 70 re-334)
16.   A data file “Salary.dat” contains the information of employee regarding their name, post and salary. WAP to display all the information of employee whose salary is greater than 15000 and less than 40000.(slc 71 re-334)
17.   A sequential data file called ‘marks.dat’ contains name, age, city and telephone fields. WAP to display all the records of that file.(slc 72)
 Compiled By: Amrit Poudel
                              Jagat Mandir School, Lampokhari, Chabahil