Monday, September 30, 2019

Write a Qbasic Program to find the sum of square of odd digits using function procedure.

Ashoj 13 - Program 05
Write a Qbasic Program to find the sum of square of odd digits using function procedure.


DECLARE FUNCTION SUMODD (N)
CLS
INPUT "ENTER ANY NUMBER"; N
SU = SUMODD (N)
PRINT "SUM OF SQUARE OF ODD DIGITS"; SU
END
FUNCTION SUMODD (N)
S = 0
WHILE N < > 0
R = N MOD 10
IF R MOD 2 = 1 THEN S = S + R ^ 2
N = N \ 10
WEND


SUMODD = S
END FUNCTION

Friday, September 27, 2019

Solved Computer Science MAAF Mid Term Examination 2076


MUTUAL ACADEMIC ACTIVITIES FORUM (MAAF)
Kathmandu, Nepal
Mid Term Examination 2076
Class : 10
Subject Computer Science
Full Marks: 50
Time: 1:30 hrs
Group A [Fundamentals – 22 Marks]

1. Answer the following questions.   [5×2=10]

a)     What do you mean by transmission media? Writes it types.
Ans: Transmission medium is a channel through which data or signals can be transmitted from one point to another. Its types are Guided Medium and Unguided Medium.

b)     Define e-mail with its two advantages.
Ans: E-mail (Electronic mail) is one of the most popular services provided by the internet which sends and receives mail through the internet.
The two advantages of email are:
i) It allows to send and receive message across the world at very low cost.
ii) It is very fast compared to postal system.

c)     What is computer security? List some hardware security measures.
Ans: The security given to the computer for the protection of hardware, software and data from being lost or damaged due to accidental or intentional harm is known as computer security.
Some of the hardware security measures are:
i) Regular maintenance
ii) Insurance Policy
iii) Power Regulator Device
iv) Fire detectors

d)     Write any four effects of computer viruses.
The effects of computer virus are:
i) Virus can change the contents of file, and codes of program.
ii) Degrade the overall performance of computer system.
iii) Change in size of file by adding or removing text accordingly.
iv) Corrupting the system’s data.

e)     Write the importance of multimedia technology in classroom teaching.
Ans: The role of multimedia in classroom teaching is that it allows user to manipulate subject matters according to user’s wish in different forms to make more interactive and effective explanation of the related subdject matter to the students by the use of presentation.








2.a)  Perform as indicated:   [2×1=2]
            i) (974)10 into octal

8
974
Rem
8
121
6
8
15
1
8
1
7

0
1

(974)10 = (1716)8

ii) (B52)16 into binary.
Soln:
Converting hexadecimal to binary
B = 1011
5 = 0101
2 = 0010
(B52)16 = (101101010010)2

b) Perform the following binary operations:           [2×1=2]
     i) (1011 + 10100) – (1001)

1
1
0
1
1
+
1
0
1
0
0
1
0
1
1
1
1

-
1
0
0
1
1
0
0
1
1
0

         (1011 + 10100) – (1001) = (100110)

c) 1100101 ¸ 101

101
1100101
10100

101


00101


    101


          01


           0


          01


Q = 10100
R = 01






3. Match the following:         [4×0.5=2]

a)     Graphics                                 checking for disk error
b)     SMTP                                      prevents gaining access
c)     Scandisk                                 moving images
d)     Firewall                                  network protocol
Still frame pictures

Answers:
a)     Graphics                                 Still frame pictures
b)     SMTP                                      network protocol
c)     Scandisk                                 checking for disk error moving images
d)     Firewall                                              prevents gaining access


4. Select the correct answer.            [4×0.5=2]

a)     A network device that amplifies the incoming signal creates a new copy of it and transmits.
i) Hub                          ii) Bridge                                iii) Repeater                iv) Router
Ans: Repeater

b)     Which is the multimedia software ?
i) Photoshop                           ii) MS Power point                 iii) VLC Player           iv) All of them
Ans: All of them
c)     A virus that damages the master boot record .
i) Macro                      ii) Boot sector             iii) script                    iv) program
Ans: Boot sector
d)     The hardware components of a network.
i) NOS                         ii) LAN                       iii) Switch                               iv) All of them
Ans: Switch
 
5. Give the appropriate technical terms of the following.  [4×0.5=2]

a)     The data handling capacity of communication system.
Ans: Bandwidth
b)     The process of transferring data/file from users computer to the Internet server.
Ans: Upload 
c)     Online postal services.
Ans: E-mail
d)     The artificial environment created by computer technology to entertain user.
Ans: Virtual Reality

6. Write the full form of the following:        [4×0.5=2]

a)     MPBS: Mega Bytes Per Second
b)     BNC: British Naval Connector
c)     CCTV: Closed Circuit Television
d)     CAD: Computer Aided Designing

Group ‘B’ [Database Management System  - 10 Marks]

7. Answer the following questions.   [3×2=6]

a)     What is database? Give some examples.
Ans: Database is a collection of related and organized information that can be used for different purpose.
Two examples of database are:
i) Dictionary
ii) Telephone Directory

b)     What is primary key? Write its importance
Ans: Primary key is a field that uniquely identifies the record.
Ans: The importance of Primary key is:
i) It reduces and controls duplication of record in a table.
ii)It sets the relationship between tables.

c)     Define query with its types
Ans: Query is an object of Ms-Access which extracts and arranges information from a table in a manner that is specified.
The different types of query are:
i) Select query
ii) Action query
In action query, we have update query, append query, delete query and make-table query.


8. Choose the correct answer.          [4×0.5=2]
a)     Date& time data types occupies     bytes of memory.
i) 4                  ii) 2                             iii) 8                iv) 16
Ans: 8
b)     Fields are referred to as
i) Tables                      ii) tuples         iii) relations                iv)  columns
Ans: Columns
c)     The maximum number of characters that can be used in field name.
i) 255              ii) 3048                       iii) 50              iv) 64
Ans: 64
d)     A field property that specifies an expression and check for the invalid data.
i) Invalid Rule      ii) Validation Rule           iii) Input Mask         iv) Format
Ans: Validation Rule

9. Match the following.          [4×0.5=2]
a)     Hyperlink                    label for a field
b)     Fox pro                       data type
c)     Memo                          DBMS
d)     caption                        long text  
search fast


Answers
a)     Hyperlink                    data type
b)     Fox pro                       DBMS
c)     Memo                          long text
d)     caption                        label for a field  

10 a) Why is QBASIC is also called modular programming languages?    [1]
Qbasic is also called modular programming because it divides program into many small, manageable, logical and functional modules or blocks.

b) Write difference between SUB and FUNCTION procedures.   [1]
Ans:
SUB-procedure
FUNCTION-procedure
i) SUB-procedure does not return value.
i) FUNCTION-procedure must return a value.
ii) SUB-procedure is called by CALL statement.
ii) FUNCTION-procedure is called by statement and expression method.


c) Write the function of the following statements   [2×0.5=1]
   Writes #  -  It sends one or more data items to the specified file.
    INT – It rounds and returns the largest integer less than or equal to a numeric expression.

11. Rewrite the given program after correcting the bugs. [2]

REM To check the input no.  is perfect square or not
DECLARE FUNCTION chk$ (a)
CLS
INPUT “Enter the number :”; a
CALL chk$ (a)
END

FUNCTION chk$(a)
m=SQUARE (a)
n=INT (m)
IF m=a   THEN
c$=”Perfect Square”
ELSE
c$=”Not Perfect Square”
END IF
C$=chk$
END FUNCTION 

Debugged Program
REM To check the input no.  is perfect square or not
DECLARE FUNCTION chk$ (a)
CLS
INPUT “Enter the number :”; a
PRINT chk$ (a)
END

FUNCTION chk$(a)
m=SQR (a)
n=INT (m)
IF m=n   THEN
c$=”Perfect Square”
ELSE
c$=”Not Perfect Square”
END IF
chk$ = c$
END FUNCTION 

12. Write the output of the following program.       [2]

DECLARE SUB NUM( )
CLS
CALL NUM
END

SUB NUM
A=3: B=7
FOR I =1 TO 5 STEP 2
PRINT A;
SWAP B, A
B=A+1
NEXT I
END SUB

Output:
3    7    8

13. Study the following program and answer the given questions. [2×1=2]

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?
Ans: The main function will be executed 4 times.

b)     List the relational operators used in the above proram?
Ans: The relational operators used are : = and < >

14
a)     Write a program using SUB procedure to print series 1,2,3,5,8……………….13th terms. [3]

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
A = 1
B = 2
FOR I = 1 TO 13
PRINT A;
C = A + B
A = B
B = C
NEXT I
END SUB


b)     Write a program to count number of non vowels character present on the supplied string using a FUNCTION procedure.         [3]

DECLARE FUNCTION COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
PRINT "TOTAL NO. OF NON VOWEL CHARACTERS= "; COUNT(S$)
END

FUNCTION COUNT (S$)
CC = 0
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
C$ = UCASE$(B$)
IF C$ <> "A" AND C$ <> "E" AND C$ <> "I" AND C$ <> "O" AND C$ <> "U" THEN
CC = CC + 1
END IF
NEXT I
COUNT = CC
END FUNCTION




c)     Write a program to store some students “registration no name class and phone number in sequential data file “record.dat “.          [3]

OPEN “record.dat” FOR OUTPUT AS #1
DO
CLS
INPUT “Enter Registration number”; R
INPUT “Enter Name”; N$
INPUT “Enter Class”; C
INPUT “Enter Phone Number”; P#
WRITE #1, R, N$, C, P#
INPUT “Do you want to continue (Y / N)”; CH$
LOOP WHILE UCASE$ (CH$) = “Y”
CLOSE #1
END