Saturday, October 16, 2021

SLC 2070 Computer Science Programming Solution - Qbasic Coder

 Group 'C' 
Programming (18 Marks)

10.  a) What is Variable? (1)

           A variable is a named unit of data that may changes during the execution of the program. 

       b) Name any two data types in C language.     (1)

            Any 2 data types in C programming language are: 

            1) int

            2) float

       c) Give the functions of: (0.5 x 2 = 1)

   i) NAME AS

      NAME AS statement is used to rename the saved file on a disk. It changes the name of an existing file and the new name for the file. Each name may include a path.

   ii) CLOSE

        CLOSE statement is used to close the all open files. 


11. Rewrite the following program after correcting the bugs: (2)

DECLARE SUB Series(.) 
DLC 
EXECUTE Series 
END
SUB Series 
REM to generate 2 2 4 6 10 ….. upto 10th term
P=2
Q=2 
FOR Ctr=1 T0 5 
DISPLAY P, Q,
P=P+Q
Q=P+Q 
WEND 
END Series()

Debugged Program

DECLARE SUB Series( )
CLS
CALL Series
END

SUB Series
REM to generate 2 2 4 6 10 ….. upto 10th term
P = 2
Q = 2
FOR Ctr = 1 TO 5
PRINT P, Q,
P = P + Q
Q = P + Q
NEXT Ctr
END SUB


12. Write the output of the following program. 

DECLARE FUNCTION AREA(L,B)
LET L=1O
LET B=5
PRINT "The area = "; AREA(L,B)
END
FUNCTION AREA(L,B)
A=L*B
AREA = A
END FUNCTION
OUTPUT



The Area = 50


13. Study the following program and answer the questions:  (1x2=2)

DECLARE FUNCTION Sum(A,B)
INPUT "Enter first number:";  A 
INPUT "Enter second:"; 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. 

        Ans: The numeric variables used in the above program are A, B, S 


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

         Ans: Yes, the program will run if the first line (i.e. DECLARE……) is deleted. 


14. a) Write a program using Function.....End Function to get temperature in Celsius from the user and then print the temperature in Fahrenheit. (hint: F=9C/5+32).   (3) 

DECLARE FUNCTION Convert (c)
CLS
INPUT "Enter the Temperature in Celsius : "; c
F = Convert(c)
PRINT "Temperature in Fahrenheit="; F
END

FUNCTION Convert (c)
     t = 9 * c / 5 + 32
     Convert = t
END FUNCTION

b) Write a program using Sub....End Sub to get a word from the user and then print it in reverse order.    (3)

DECLARE SUB Rev(s$)
CLS
INPUT "Enter any String : "; s$
CALL Rev(s$)
END

SUB Rev (s$)
FOR i = LEN(s$) TO 1 STEP -1
     r$ = MID$(s$, i, 1)
     w$ = w$ + r$
NEXT i
PRINT "Reverse Order is : "; w$
END SUB


c) 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. (3)

OPEN "Marks.dat" FOR INPUT AS #1
CLS
PRINT "Name", "English", "Nepali", "Maths", "Science"
WHILE NOT EOF(1)
INPUT #1, n$, e, n, m, s
PRINT n$, e, n, m, s
WEND
CLOSE #1
END

No comments:

Post a Comment

If you have any doubts, Please let me know.

[Download PDF] Computer Science Book Gread-10 in Nepali Language

 If you are searching for class 10 Computer Science in Nepali pdf for free download then you are at the right page. This book is soley publi...