Saturday, October 1, 2022

C Programming Questions Collection - SEE Computer Science 2079

 1.      Write a program in C language to ask length, breadth and height and display volume of box.

2.      Write a program in c language to calculate simple interest.

3.      Write a program in C language that asks a number and check whether it is odd or even.

4.      Write a C program that asks a number and check whether it is negative, positive or zero. [SEE 2078], [MODEL SET 2]

5.      Write a program in C language to input a number then check whether the number is fully divisible by 5 or not.

6.      Write a program in C language to input a number then check whether the number is divisible by 5 and 7 or not. [SEDIPS 2078]

7.      Write a program C language that asks any two numbers and displays the greatest among them.

8.      Write a program in C language to display the series with their sum.1, 2, 3, 4 upto 10th terms.

9.      Write a program in C language to display first 10 odd numbers. [SEE 2078]

10.   Write a C program to find the sum of first 10 natural numbers.

11.   Write a program in C language to display the series 2, 4, 6, 8 up to 10th terms.

12.   Write a program in C language to display the series 1, 1, 2, 3, 5, 8 upto 10th terms.

13.   Write a program in C language to print series1, 8, 27, 64………..up to 10th terms.

14.   Write a program in C language to display the below series: 5, 10, 15, 20, ….50.

15.   Write a program in C language to display the series with their sum; 100, 95, 90, 85…..upto 10th term. [SEDIPS 2078]

16.   Write a program to print the numbers from 1 to 100 using while loop in C language.

17.   Write a program in C language to generate the series using SUB …… END SUB : -10, -18, -6, -4, ………. Up to 20th term.

 

We will not punish mistakes and errors. Mistakes are how we learn.

 

 

QBasic File Handling Programming Questions Collection 2079 - SEE Computer Science 2079

 1.      Write a program to create a sequential data file “salary.dat” to store programmer’s name, salary and post according to the need of the user. [SEE 2078]

2.      Write a program in QBASIC to create a file "EMP.DAT" and store employees Name, Address, Salary and Telephone number on the basis of user choice.

3.      Create a sequential data file “std.dat” to store name and marks obtained in English, Math and Science subjects for a few students. [SEE MODEL 2065]

4.      Write a program to store records regarding the information of Book Number, Book’s name and Writer’s name in a sequential data file called “Library.dat”. [SLC 2065 R]

5.      Write a program to create a sequential  data file “Employee.dat” to store employees’ name, address, age and gender.

6.      Write a program to create a data file “teldir.dat” to store name, address and telephone number of employees according to the need of the user. [SLC 2069 R]

7.      Create a data file to store the records of few employees having Name, Address, Post, Gender and Salary fields. [SEE 2073]

8.      Write a program to store Roll no., Name, Class and Address of any five students.

9.      Write a program to create a sequential data file "salary.data" to store programmer's Name, salary and post according to the need of the user. [SEE 2075 S2]

10.   Students Name, Class, Section and Address are stored in a data file called “STUDENT.dat”. Write a program to print all the records of students.

11.   A sequential data file called “MARKS.DAT” contains roll no., name, English, nepali and maths fields. Write a program to display all the contents of data file.

12.   A sequential data file “Staff.dat” contains the name, address, post and salary of the employees. Write a program to read and display all the records stored in the above file. [SLC 2069 S]

13.   A sequential data file called “Marks.dat” contains name, english, nepali, maths and science fields. Write a program to display all the contents of that data file.

14.   A sequential data file “Record.dat” has records with field name, addres, age and salary. Write a program to display only those records whose age is greater than 26. A sequential data file called “Marks.dat” contains NAME, AGE, CITY AND TELEPHONE fields. Write a program to display all the contents of the data file.

15.   A sequential data file called “Record.dat” has stored data under the field heading Roll No., Name, Gender, English, Nepali, Maths and Computer. Write a program to display all the information of those students whose marks in English is more than 40. 

16.   A sequential data file “emp.dat” contains employee’s name, address, gender and salary. WAP to display all the information of employees whose salary is more than Rs. 20,000 [NPABSON PRE BOARD 2078]

17.   A sequential data file called “Record.txt” has stored data under the field heading Roll No., Name, Gender, English, Nepali, Maths and Computer. Write a program to display all the information of those students whose gender is “F” and obtained marks in computer is more than 90. [MODEL SET 1]

18.   Write a program to update the rate by increasing 10% from a sequential data file "Data.dat" that store item name, rate and quantity. [PABSON PRE BOARD 2078 - 2]

19.   A data file “LIB.TXT” consists of Book’s name, Author’s name and price of books. Write a program to count and display the total number of records present in the file.

20.   A sequential data file “EMP.DAT” contains name, post and salary fields of information about employees. Write a program to display all information of employees along with tax amount also.(Tax is 15% of salary)

21.   A sequential data file called “student.dat” contains some records under the fields Name, English, Nepali and computer. Write a program to add some more records in the same sequential data file. [SLC 2068 R]

22.   Write a program 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 2068 S]

23.   A data file “Salary.dat” contains the information of employee regarding their name, post and salary/ Write a program to display all the information of employee whose salary is greater than 15000 and less than 40000. [SLC 2071 R]

24.   A sequential data file called “Marks.dat” has stored data under the field heading Roll No, Name, English, Nepali and maths. Write a program to display all the information of those students whose marks in Nepali is more than 50. [SLC 2071 S]

25.   A data file "STAFF. dat" has stored records of few employees with EmPID, First name, Lastname, post and salary. Write a program to display all the records of the employees whose salary is more than  40,000.

26.   A Sequential data file called "SEE.DAT" has stored data under the field heading Symbol No., Name, English, Nepali, Maths and Computer. Write a program to display all the information of those students whose marks in Computer is more than 80.

27.   A sequential data file “person.txt” contains information such as name, address and DOB of 20 people. Write a program to display only those records whose age is below 18 and address is Lalitpur.

28.   A data file “Staff.dat” has stored records of few employees with EmpID, name, address, post and salary. Write a program to display all the records of the employee whose address is Butwal and salary is more than 40,000.

29.   Write a program to update the rate by increasing 10% from a sequential data file “data.dat” that storte item name, rate and quantity.

30.   A sequential data file “Employee.rec” consists of numerous records of employees of a company on the following fields: employee’s name, post, salary and status (i.e. permanent or temporary). Write a program to read records of the “Employee.rec” file and display the records of permanent employees whose post is manager.

31.   Write a program to open a sequential data file “STAFF.DAT” which will display students’ name, roll no., gender, class and section of class of ten students on the screen.

32.   A sequential data file “employee.rec” contains employee no, employee name, employee address, designation, salary and Date of join. WAP to count and display those records of employees whose DOJ (Date Of Join) is on January 1st.

33.   Write a program that asks student’s name and marks in English, Math and Computer and stores into “pass.dat” only those records that are passed in all the subjects. The user will be asked whether to input another record or not.

QBASIC Modular Programming Questions Collections 2079 - SEE Computer Science 2079

 MODULAR PROGRAMMING

1.      Write a program in QBASIC that asks length, breadth of a room and calculate its area and perimeter. Create a user defined function to calculate area and sub program to calculate perimeter.

[Hint: [Area=LxB], [p=2(L+B]]

2.      Write a program in QBASIC that will asks the user to input length, breadth and height of a room then use SUB procedure calculate its volume and FUNCTION procedure to calculate its area of four walls.

3.      Write a program to calculate Area of circle using Function procedure and use SUB procedure to calculate its circumference in Q-Basic.[Hint: [A=Ï€r2], [C=2Ï€r]

4.      Write a program in QBASIC that ask the radius of circle. Write a program to calculate the area and circumference of a circle. Create a user defined function first (r) to calculate area and sub procedure second (r) to calculate circumference of a circle.

5.      Write a program in QBASIC that asks length, breadth and height of room and calculate its area and volume. Create a user defined function to calculate area and sub-program to calculate volume. Hint: [A=L×B], [V=L×B×H] [MODEL SET 1]

6.      Write a program in QBASIC that will asks the user to input length, breadth and height. Create a user defined function to calculate surface area of four walls and write sub program to calculate surface area of box. [Hint: surface area of for walls=2H(L+B), surface area of box=lh+bh+lb

7.      Write a program in QBASIC that allows user to enter radius of a circle. Create a user define function to find the area of circle and sub procedure to find volume of a cylinder. Hint: [A= r2        v= Ï€r2h]

8.      Write a program to define a function procedure to display area of sphere and sub procedure to display volume of sphere where user has to input the required data in the main module. [Hint: Area of sphere: 4*PI*R^2, Volume- V = 4/3 * Ï€ * r³ 

9.      Write a program in QBASIC that asks two numbers to find square of two numbers using SUB procedure and average of two numbers using FUNCTION procedure.

10.   Write a program in QBASIC that allows the user to input length, breadth and height and then calculate the area of 4 walls. Hint: [A = 2H(L+B)] [MODEL SET 2]

11.   Write a program to calculate the area of four walls using SUB…END SUB.

12.   Write a program in QBASIC to find the total surface area of a box using FUNCTION…END FUNCTION.

13.   Write a program to calculate and print the simple interest using FUNCTION procedure

14.   Write a program using FUNCTION…END FUNCTION to get temperature in celsius from the user and then print the temperature in fahrenheit. [SLC 2070 R]

15.   Write a program using FUNCTION…END FUNCTION, to find the area of triangle.

16.   Write a program in Q-Basic to find the perimeter of rectangle using Sub…END SUB procedure.

17.   Write a program using FUNCTION…END FUNCTION to find the average of any two numbers given by the user. [SLC 2066 S]

18.   Using FUNCTION…END FUNCTION Write a program to calculate the average of three numbers.

19.   Write a program to calculate the volume of a cylinder using FUNCTION….END FUNCTION

20.   Using FUNCTION….END FUNCTION, Write a program to calculate distance travelled by a body. [SLC 2065R]

21.   Write a program using SUB…END SUB to get radius of circle and then print its area.

22.   Write a program using FUNCTION module to calculate and print the volume of a box. [SLC 2066 R]

23.   Write a program using SUB…END SUB to get radius of a circle and then print its circumference. [SLC 2067 S]

24.   Using user defined function, write a program to input monthly income in parameter then computer annual tax to be paid. The tax rate is 15% if annual income is above Rs. 200000, otherwise tax rate is 1%.

25.   Write a program in QBASIC to ask a number and display sum of digits by using FUNCTION..END FUNCTION.

26.   Write a program in Q-Basic to find the largest among three number using FUNCTION procedure.

27.   Write a program that asks any three numbers and displays the difference between the greatest and the smallest value among the 3 supplied numbers using FUNCTION procedure.

28.   Write a program to ask a number and display odd or even using FUNCTION procedure.

29.   Write a program to test whether the given number is positive or negative using SUB…..END SUB. [SEE MODEL 2065 ],

30.   Using SUB…END SUB Write a program to test whether the given number is completely divisible by 13 or not. [SLC 2067 R]

31.   Write a program to input three different numbers in the main module and then find the greatest number using SUB procedure.

32.   Write a program to input a year and display whether that year is a leap year or not. [divisible by 4 but not 100] using sub procedure.[Y MOD 4 = 0 AND Y MOD 100 <> 0 OR Y MOD 400 = 0]

33.   Write a sub program to find whether the given number is perfect square number or not.

34.   Using SUB…END SUB Write a program to print the following series 9,7,5,…1.

35.   Write a program using SUB…END SUB to print the series 1,1,2,3,5,8… upto ten terms.

36.   Write a program to print natural numbers from 1 to 5 using SUB…END SUB.

37.   Write a program using SUB…END SUB to print the first ten odd numbers.

38.   Write a program to print the sum of digits of a given number using SUB procedure.

39.   Write a program to generate the series using SUB …… END SUB : -10, -18, -6, -4, ………. Up to 20th term.

40.   Write a program using a SUB procedure module to print the multiplication table of any input number up to tenth termsWrite a program that asks any number and calculates its factors using a SUB procedure

41.   Write a program using FUNCTION…END FUNCTION, to get a word from the user and the print the word in reverse order.

42.   Write a program using SUB…END SUB to get a word from the user and then print it in reversed order. [SLC 2070 R], [SEE 2072]

43.   Write a program to declare SUB procedure to print only the vowels from a given word.

44.   Write a program to count the total number of vowels using FUNCTION…END FUNCTION. [SEE 2073]

45.   Write a program using FUNCTION…END FUNCTION to input a string and count the total number of consonants. [SLC 2071 R]

46.   WAP using FUNCTION procedure named extract (“Education”) to extract all the characters from the given string excluding the first and last characters only. The output of the given program is ducatio.

(Your program should not contain any if condition and looping statement.)

47.   Display the pattern using SUB procedure: (You can’t feed input as neither abcde nor in any cases given alphabets)

a

BB

ccc

DDDD

eeeee

48.   Write a program using FUNCTION... END FUNCTION to count the number of words in a sentence. [SEE 2074]

QBASIC Modular Programming - Analytical Question- SEE Computer Science 2079

 Analytical Questions

 

1. NPABSON PRE BOARD

DECLARE FUNCTION test$ (A$)

CLS

INPUT “ENTER ANY WORD”; T$

PRINT test$(t$)

END

FUNCTION test$ (A$)

FOR M = LEN(A$) TO 1 STEP -1

C$= C$+ MID$(A$, M,1)

NEXT M

Test$ = C$

END FUNCTION

a)      List the formal and actual parameters used in the program given above.

b)     List the library function used in the above program.

 

2. [SEE 2075 S2]

DECLARE   SUB TRIM (W$)

CLS

INPUT "Enter word" ; WO$

CALL TRIM  (WO$)

END

SUB TRIM (WO$)

FOR I = 1 TO LEN (W$)

PRINT LEFT$ (W$, I)

NEXT I

END SUB

a)      What will be the output if input string is "SEE" in the above program?

b)     List the real parameter used in the above program.

 

 

 

 

3. [SQE 2075K]

DECLARE SUB SERIES(A, R, N)
CLS

INPUT "ENTER FIRST TERM"; X
INPUT "NUMBER OF TERMS TO BE GENERATED:"; Z
CALL SERIES (X,Y,Z)
END
SUB SERIES (A, R, N)
FOR I = 1 TO N
PRINT A
A=A*R
NEXT
END SUB

a)      What will be the output if the user input 3, 2 and 4 for variables X, Y and Z variables?

b)     What type of parameter X, Y and Z are?

 

4. [SLC 2069]

DECLARE  SUB EXAM (N$)

INPUT "Enter Word", WO$

CALL EXAM (WO$)

END

SUB EXAM(N$)

FOR I=1 TO LEN (N$)

PRINT RIGHT$(N$,1)

NEXT I

END SUB

a)      Write the names of two built in functions used in the program.

b)     List the real parameter and formal parameter in the program.

 

5. SET

DECLARE SUB SEQUENCE (A,B,C)

CLS

X=10

Y=20

Z=30

CALL SEQUENCE (X,Y,Z)

END

SUB SEQUENCE (C,B,A)

PRINT A,B,C

END SUB

a)      List the formal parameters and actual parameters used in the above program.

b)     Will the above program execute if the position of parameter is to be changed? If ‘yes’ then which sequence of number list will it print either 10,20,30 or 30,20,10?

6. MAAF MT 2079

DECLARE FUNCTION count(bs)

INPUT a$

num=count (a$)

PRINT num

END

 

FUNCTION count (b$)

FOR K=1 to LEN (bs)

aS=MIDS(b$, K, 1)

IF UCASES(a$)="D" THEN

c=c+1

END IF

NEXT K

count = c

END FUNCTION

a)      What is the name of FUNCTION procedure used in above program?

b)     List out the formal and actual arguments from the above program.

 

7. [SLC 2065]

DECLARE FUNCTION xyz(N)
FOR I = 1 TO 5
READ N
Z=xyz(N)
S=S+Z
NEXT I
PRINT S
DATA 10,13,15,4,6
END
FUNCTION xyz(N)
IF N MOD 2=0 THEN xyz=N
END FUNCTION

a)      What is the name of the function used in the above program?

b)     How many times the function will be called in the above program?

 

8. SEE 2078

DECLARE FUNCTION TEST(X)

X=100

Z=TEST(X)

PRINT Z

END

 FUNCTION TEST(X)

FOR R=1 TO X

S=S+I

NEXT R

TEST=S

END FUNCTION

a)      How many parameters are used in the above program?

b)     How many times does the statement S=S+I execute in the above program?

 

9. [SLC 2068 S]

DECLARE SUB ABC(X,Y,Z)

FOR P=1 TO 3

READ A,B,C

CALL ABC(A,B,C)

NEXT P

DATA 5,4,3,2,1,6,7,8,4

END

SUB ABC(X,Y,Z)

T=X+Y+Z

IF T MOD 2 = 0 THEN

PRINT T

END IF

END SUB

a)      List any two variables used in the above program.

b)     How many times SUB-procedure will be called when program is executed?

10. [SEE 2074 U]

DECLARE   FUNCTION   TEST (X)

X = 100

Z = TEST (X)

PRINT Z

END

FUNCTION TEST (X)

FOR I = 1 TO X       

S = S +I

NEXT I

TEST = S

END FUNCTION.

a)      How many parameters are used in the above program?

b)     How many times does the statement S=S+I get executed in the above program.

 

11. [MM 2076]

DECLARE FUNCTION SUM (N)

FOR I = 1TO 4

READ N

DATA 15 ,25, 69

PRINT SUM (N)

NEXT

END

FUNCTION SUM(N)

S=0

WHILE N<>0

R=N MOD 10

S=S+R

N=INT (N\10)

WEND

SUM=S

END FUNCTION

a)      How many times the main function will be executed in the above program?

b)     List the relational operators used in the above program?

 

12. SEE Grade Promotion 2078 - 1

DECLARE FUNCTION SUM(N)

CLS

INPUT”Enter any number”: N

X=SUM(N)

PRINT”The sum of individual digit is “; X

END

FUNCTION SUM(N)

WHILE N<>0

R=N MOD 10

S=S+R

N=INT(N/10)

WEND
SUM=S

END FUNCTION

 

a)      Write the function of INT.

b)     How many times the WHILE…..WEND LOOP repeats if the value of N is 123?

 

13. [SLC 2071 S]

DECLARE FUNCTION JPT (N)

            FOR ctr = 1 TO 6

            READ N

            J = JPT (N)

            Sum = Sum + J

            NEXT ctr

            PRINT Sum

            DATA 10, 20, 30, 40, 50, 60

            END

 

            FUNCTION JPT (N)

            IF N MOD 2 = 0 THEN JPT = N

            END FUNCTION

a)      What is name to the function used in the above program?

b)     How many times the function will be executed in the above program?

14. SET

DECLARE FUNCTION greater(A,B)

CLS

INPUT”Enter first number”; X

INPUT”Enter second number”; Y

C = greater(X, Y)

PRINT "The greater number is " ; C

END

FUNCTION greater(A,B)

IF A>B THEN

GR = A

ELSE

GR = B

END IF

Greater = GR

END FUNCTION

a)      What will be the output of the program if X = 6 and Y = 7?

b)     How many arguments are used in above program?

 

15. PABSON FIRST TERM 2079

DECLARE FUNCTION FACT( N )

CLS
INPUT “Enter no”; N

PRINT “Factorial is”; FACT (N)

END
FUNCTION FACT (N)

F = 1

FOR X = 1 TO N

F = F * X

Next X

FACT = F

END FUNCTION

Questions:

a)      What is the name of function procedure used in the above program?

b)     What is the main objective of the above program?

16. [PMT 2075]

DECLARE SUB OT (N$)

N$ = "Computer Science"

CALL OT(N$)

END

SUB OT (N$)

B = LEN(N$)

c = 1

WHILE c <= B

m$ = MID$(N$, c, 1)

PRINT m$;

c = c + 2

WEND

END SUB

a)      What is the value of B in the above program?

b)     How many parameters are used in the above sub procedure?

17. SEE Grade Promotion 2078 - 2

DECLARE FUNCTION Prod(A,B)

CLS

INPUT “Enter first number”; A

INPUT “Enter second number”; B

PRINT “The product of the two number=”; prod(A,B)

END

FUNCTION Prod(A,B)

P=A*B

Prod=P

END FUNCTION

a)      List all the numerical variables used in the program.

b)     List the local variable/s used in the above program.

 

18. PABSON PRE BOARD-1

DECLARE SUB PC$ (N)

CLS

 INPUT "Enter a number"; N

CALL PC$ (N)

END

SUB PC$ (N)

 FOR I=2 TO N-1

 R=N MOD I

 IF C=0 THEN

PRINT "Prime number"

 ELSE

PRINT "Composite number"

 ENDIF

END SUB 

a)        What is the name of sub procedure?

b)       List the local variable.

 

19. [SEE 2073]

DECLARE FUNCTION Diff (A, B)

CLS

INPUT "Enter first number" ; A

INPUT "Enter second number" ; B

PRINT "The difference" ; Diff (A, B)

END

FUNCTION Diff (A, B)

difference = A - B

Diff = difference

END FUNCTION.

a)      List all the numeric variables used in the above program.

b)     List the local variables used in the above program.

 

20. [SEE 2067 S]

DECLARE FUNCTION Prod(A,B)

CLS

INPUT “Enter first number:”;A

INPUT “Enter second number:”;B

PRINT “the product of two number=”;Prod(A,B)

END

FUNCTION Prod(A,B)

      P=A*B

      Prod=P

END FUNCTION

a)      List all the numerical variables used in the program.

b)     List all the local variables used in the program.

 

21. [SEE 2073 U]

DECLARE FUNCTION SUM (A, B)

INPUT A

INPUT B

X = SUM (A, B)

PRINT X

END

FUNCTION SUM (A, B)

S = A+B

SUM = S

END FUNCTION.

a)          Write the name of local variable used in the above FUNCTION procedure.

b)         Write the Mathematical operator and Relation operator used in above program.

 

 

22. SET

DECLARE SUB SERIES(A, B)

DECLARE FUNCTION SUM(P,Q)

COMMON SHARED N

INPUT “Enter First Term”;X

INPUT “Enter Second Term”;Y

INPUT “Enter Number of Terms to be generated”; N

CALL SERIES(X, Y)

END

 

SUB SERIES (A, B)

FOR I = 1 TO N

PRINT A

A=SUM(A,B)

NEXT I

END SUB

FUNCTION SUM (P,Q)

SUM=P+Q

END FUNCTION

 

a)      What will the output if X=10, Y=8 and N=5.

b)     List out the local variables and global variable in the above program.

23. PABSON 2070

DECLARE SUB TEST()

DIM SHARED A$,B$,C$

CLS

FOR P= 1 TO 3

READ A$,B$,C$

NEXT P

DATA “BAGMATI” , “SAGARMATHA” , “KOSHI”

CALL TEST

END

SUB TEST

L$=A$

IF LEN(B$)>LEN(L$) THEN L$=B$

IF LEN(C$)>LEN(L$) THEN L$=C$

PRINT L$

END SUB

a)      List the global variables used in the above program.

b)     What is the output of the above program?

 

24. [SLC 2066]

DECLARE FUNCTION Num(N)
INPUT N
S=Num(N)
PRINT S
END
FUNCTION Num(N)
X=Int(17/N)
Y=15 MOD N
Num=X +Y
END FUNCTION

a)      Write the name of the function used in the above program.

b)     List out the mathematical function (Library function) used in the above program.

 

25. [SEE 2075 U]

DECLARE SUB TEST (N$ )

INPUT N$

CALL TEST ( N$ )

END

SUB TEST (N$ )

FOR P = 1 TO LEN ( N$ )

B$ = MID$ (N$, P, 1)

IF LCASE$ (B$) = “a” THEN

C = C + 1

END IF

NEXT P

PRINT C

END SUB

a)      Write the name of the sub procedure used in the above program.

b)     Write any two library functions used in the above program.

 

26. [SLC 2068]

Declare function count(N$)

Input “Enter a word”; R$

C= Count(R$)

Print C
END

Function count(N$)
For k=1 to LEN(n$)
X$=MID$(N$,K,1)
IF UCASE$(X$)=”A” then
X=X+1
End if
Next K
Count = X
End function

a)      List any two library functions used in the above program.

b)     Write the use of variable ‘C’ inline 3 [i.e. C=Count(R$)] given in the above program.

 

27. [SLC 2066 S]

DECLARE FUNCTION COUNT(A$)
Input “Enter a word”; W$
END

Function Count(A$)
B=LEN(A$)
C$=UCASE$(A$)
FOR I=1 TO B
 E$=MID$(C$,I,1)
 IF E$=”A” OR E$=”E” OR E$=”I” OR E$=”O” OR E$=”U” THEN   C=C+1
END IF
NEXT I
COUNT=C
END FUNCTION

a)      List the string Library functions used in the above program.

b)     Write down the missing statements in the main module to execute the program.

28. [SLC 2071]

DECLARE SUB Stde(N$U)

FOR Loop = 1 TO 5

READ NM$(Loop)

NEXT Loop

DATA RAMA, PRATIMA, PRASANT

DATA NISHA, RUDHRA

CALL Stde(NM$U)

END

SUB Stde(N$U)

PRINT “Name starting from P”

FOR J = 1 TO 5

C$=MID$(N$,(J),1,1)

IF C$=”P” THEN

PRINT N$(J)

END IF

NEXT J

END SUB

a)      List the library function used in the above program.

b)     List the conditional statement used in the above program.

29. [SLC 2070 S]

DECLARE FUNCTION rev$ (N$)

      INPUT "Any string"; N$

      PRINT rev$ (N$)

END

FUNCTION rev$ (N$)

      FOR X = LEN (N$) to 1 STEP -1

                  A$=MID$ (N$, X, 1)

                  B$ = B$ + A$

      NEXT X

      rev$ = B$

END FUNCTION

a)      List the library function used in the above program.

b)     What will be the maximum value of X if the N$ is equal to "Computer".

30. SET

DECLARE SUB WORD(X$)

x$ = "COMPUTER"

END

SUB WORD (N$)

L = LEN(x$)

FOR I=L To1 STEP-2

PRINT MID$(X$,I,1)

NEXT I

END SUB

a)      What statement should be added in the main module to execute the program?

b)     List numeric and string variable. 

31. NPABSON 2078

DECLARE SUB result(m$)

m$=”NPABSAN”

END

SUB result(m$)

C=LEN(m$)

B=1

WHILE B<=C

PRINT MID$(m$, b, 1);

B=B+2

WEND

END SUB

a) What is missing in above program?

b) List out the numeric and string variable in the above program.

 

32. [SLC 2070]

 

DECLARE FUNCTION Sum(A,B)

INPUT “Enter first number:”; A

INPUT “Enter second number:”; B

PRINT “The sum of the two number=”;Sum(A,B)

END

FUNCTION SUM(A,B)

S=A+B

Sum=S

END FUNCTION

a) List the numerical variables used in the above program.

b) Will the program run if the first line (i.e. DECLARE….) is deleted?

33. SET

DECLARE SUB WORD(N$)

N$=”NEPAL”

CALL WORD(N$)

END

 

SUB WORD(N$)

LET B=LEN(N$)

LET C= 1

WHILE C<=B

M$=MID$(N$,C,1)

PRINT M$;

C=C+2

WEND

END SUB

a)     What is the value of B in the above program?

b)     List out the numeric and string variable used in the above program.

34. SEDIPS 2070

DECLARE SUB ABC(A,B,C)

INPUT P, Q, R

CALL ABC(P,Q,R)

END

SUB ABC(A,B,C)

IF (A>B AND A<B) OR (A<B AND A>C) THEN

PRINT “The middle number is”;A

ELSEIF (B>A AND B<C) OR (B<A AND B>C) THEN

PRINT “The middle number is”;B

ELSE

PRINT “The middle number is”;C

END IF

END SUB

a)     What is the alternative way of invoking the SUB module.

b)     Make a list of operators and state their types.

35. [SLC 2065 S]

DECLARE FUNCTION Diff(A,B)

CLS

INPUT “Enter first number”;A

INPUT “Enter second number”;B

PRINT “The difference of the two number=”;Diff(A,B)

END

FUNCTION Diff(A,B)

D=A-B

Diff=D

END FUNCTION

 

a)      What will be the output of the program if the user enters 200 as the first number and 100 as the second number.

b)     Will the program run if the first line (i.e. DECLARE…..) is deleted?

36. NPABSON 2070

DECLARE FUNCTION BB(N)

 FOR I = 1 TO 4

READ P

Y=Y+BB(P)

NEXT I

DATA 23, 45, 60, 12

PRINT Y

END

FUNCTION BB(N)

IF N MOD 2 = 0 THEN FIND=N

END FUNCTION

a)      How many times function …….. end function execute in above program?

b)      Does the program execute, if underlined statement is removed from the main module?

37. [SLC 2069 S] [JEC 2078]

 

DECLARE FUNCTION CHK$(N)
N=57
PRINT “The number is”; CHK$(N)
END

FUNCTION CHK$(N)
FOR I = 1 TO N
IF N MOD I = 0 THEN C=C+1
NEXT I
IF C>2 THEN
CHK$=”Composite”
ELSE
CHK$=”Prime”
END IF
END FUNCTION

 

a)      Will the above program execute if “DECLARE FUNCTION….” is deleted.

b)     Why $ sign is used in the name of the above function.

38. [SQE 2074K]

DECLARE SUB PATTRA (N)

N = 7

CALL PATTRA(N)

END

SUB PATTRA(N)

FOR I = 1 to 5

PRINT N

IF N MOD 2 = 1 THEN

N = (N*2) + 1

ELSE

N = N / 2

END IF

NEXT I

END SUB

a)      Write the output of the above program?

b)     Write down the function of MOD in the above program.

39. [SEE 2074]

DECLARE FUNCTION SUM (N)

INPUT "Enter any number", N

S = SUM (N)

PRINT "The Sum of individual digit is:", S

END

FUNCTION SUM (N)

WHILE N > 0

R = N MOD 10

T = T + R

N = N\10

WEND

SUM = T

END FUNCTION.

a)      State the purpose of using variable S in line 4 in above program.

b)     Write the use of MOD in above program.

40. [SLC 2072]

DECLARE FUNCTION Prod (N)

INPUT "Any Number"; N

X = Prod (N)

PRINT x

END

FUNCTION Prod (N)

F= 1

FOR K = 1 TO N

F = F * K

NEXT K

Prod = F

END FUNCTION

a)      Write the name of the user defined function used in above program.

b)     Name the loop in above program?

41.  [SLC 2067]

DECLARE SUB SUM(N)
INPUT”ANY NUMBER”;N
CALL SUM(N)
END

SUB SUM(N)
S=0
WHILE N<>0
R=N MOD 10
S=S+R
N=N\10
WEND
PRINT “SUM”;S
END SUB

a)      In which condition the statements within the WHILE….WEND looping statement will not be executed?

b)     Will the output be the same if we place “/” instead of”\” in the above program.

 

42. [SLC 2064]

DECLARE FUNCTION CELLS$(W$)

W$=”CYBER”

PRINT CELL$(W$)

END

FUNCTION CELL$

K=LEN(W$)

FOR I = K TO 1 STEP -2

            M$=M$+MID$(W$,I,1)

NEXT I

CELLS$=M$

END FUNCTION

 

a)      Why is $(dollar) sign followed in the function name?

b)     What will be the output of the program when it is executed?

c)      What will be the output of the program when FOR loop is changed as FOR I= 1 TO K STEP 2?

d)     What is the name of sign “+” used in the program and what operation does it perform?

 

43. SOS 2078

DECLARE SUB test(c, d)

DIM SHARED c

CLS

a=90

b=100

c=95

CALL test(a, (b))

x=x+2

PRINT a,b,c,x

END

SUB test(e,f)

SHARED x

x=12

e=e+12

f=b+3

c=c+5

PRINT x;

END SUB

 

a) What will be the output of the program?

b) What will be the output if the statement “SHARED X” is removed from the program?

 

44. SEE MODEL SET 1

 

OPEN “Detail.dat” FOR INPUT AS #1

OPEN “Temp.dat” FOR OUTPUT AS #2

INPUT “Enter name of the students”; S$

FOR I=1 TO 10

INPUT #1, Nm$, Cl, A

IF S$< >Nm$ THEN

WRITE #2, Nm$, Cl, A

END IF

NEXT I

CLOSE #1, #2

KILL “Detail.dat”

NAME “Temp.dat” AS “Detail.dat”

END

 

a)      What is the main objective of the program given above?

b)     Do you get any problem in the above program if “Kill” statement is removed? Give reason.

45. SEDIPS 2078

OPEN “BUSRIDER.TXT” FOR INPUT AS #1

OPEN “TEMP.TXT” FOR OUTPUT AS #2

CLS

WHILE NOT EOF(1)

INPUT #1, STUDENTNAME$, CLASS, BUSCOED, BUSSTOP$

IF UCASE$(BUSSTOP$) < > UCASE$(“KATHMANDU”) THEN

WRITE#2, STUDENTNAME$, CLASS, BUSCODE, BUSSTOP$

PRINT STUDENTNAME$, CLASS, BUSCODE, BUSSTOP$

WEND

CLOSE #1, #2

KILL “BUSRIDER.TXT”

NAME “TEMP.TXT” AS “BUSRIDER.TXT”

END

a) What is the main objective of the program given above?

b) Do you get any problem ion above program if “Kill” statement is removed? Give reason.

 

46. PABSON 2078 SET C

OPEN “Exam.dat” FOR INPUT AS #1

OPEN “Sample.dat” FOR OUTPUT AS #2

WHILE NOT EOF(1)

INPUT #1, Nm$, Cl, A

IF Cl < > 10 THEN

WRITE #2, Nm$, Cl, A

END IF

WEND

CLOSE #1, #2

KILL “Exam.dat”

NAME “Sample.dat” AS “Exam.dat”

END

a) What is the main objective of the program given above?

b) What is the function of EOF( ) statement in the above program?

47. SET

Open “Record.dat” for Input AS#1

WHILE NOT EOF (1)

INPUT #1, N$ , AD$ , PH#

PRINT N$ AD$ , PH#

WEND

CLOSE #1

END

a)      What is the purpose of EOF(1) in the above program?

b)     What happened if we are not using Open Statement in the above program?

48. SEE MODEL SET 2

OPEN “EMP.DAT” FOR INPUT AS #1

DO

INPUT #1, N$, A$, S

IF UCASE$(A$)=”KATHMANDU” THEN

PRINT N$, A$, S

END IF

LOOP WHILE NOT EOF(1)

CLOSE #1

END

a)      Write the use of statement “INPUT #1, N$, A$, S” in the above program.

b)     What happens if you remove “UCASE$” from the above program?

49. PABSON PRE BOARD-2

CLS

OPEN "INFO.DAT" FOR INPUT AS #5

TOP:

INPUT "ENTER NAME"; N$

INPUT "ENTER ADDRESS";A$

INPUT "ENTER PHONE NUMBER";P

WRITE #5, N$, A$, P

INPUT "DO YOU WANT TO CONTINUE (Y/N)?"; AN$

IF UCASE$ (AN$) = "Y" THEN GOTO TOP

CLOSE #5

END

Questions:

a)      List the variables used in above program.

b)     What is the name of data file used in above program?

50. SOS 2070

OPEN “DETAIL.DAT” FOR INPUT AS #1

OPEN “TEMP.DAT” FOR OUTPUT AS #2

INPUT “Name of the students”;S$

FOR I = 1 TO 10

INPUT #1,N$, C, A

IF S$<>N$ THEN

WRITE #2, N$, C, A

END IF

NEXT I

CLOSE #1,#2

KILL “DETAIL.DAT”

NAME “TEMP.DAT” AS “DETAIL.DAT”

END

a)     Will the program run if the KILL “DETAIL.DAT” is removed? Why?

b)     If the datafile “DETAIL.DAT” contains only 8 records, then the program will run? Why?