Friday, February 16, 2018

QBASIC Program to Generate the series 2,4,8,14,22...10th term

QBASIC Program to Generate the series 2,4,8,14,22...10th term
CLS
A = 2
B = 2
FOR I = 1 TO 10
    PRINT A
    A = A + B
    B = B + 2
NEXT I
END

Thursday, February 15, 2018

QBasic File Handling Program to Display last 50 records from 500 records

Write a Qbasic program that read the "EMP.DAT" file with Name, Address, Post and Salary columns from E: drive that has 500 records of employees and displays only its last 50 records.

OPEN "E:\EMP.DAT" FOR INPUT AS #1
CLS
FOR i = 1 TO 500
    INPUT #1, n$, a$, p$, s
    IF i >= 450 AND i <= 500 THEN PRINT n$, a$, p$, s

NEXT i
CLOSE #1
END


Monday, February 5, 2018

Qbasic File Handling Program to delete records whose bus stoppage is "Bhaktapur"





OPEN "Busrider.inf" FOR INPUT AS #1
OPEN "temp.inf" FOR OUTPUT AS #2
CLS
WHILE NOT EOF(1)
    INPUT #1, bn, n$, c, b$
    IF UCASE$(b$) <> "BHAKTAPUR" THEN
        WRITE #2, bn, n$, c, b$
    ELSE
        PRINT "Data Deleted"
    END IF
WEND
CLOSE
KILL "Busrider.inf"
NAME "temp.inf" AS "Busrider.inf"

END


Write a Qbasic program to define a function procedure having a numeric parameter which returns total number of factors of a number and use the function in a program to display prime numbers from 12 to 35.

Write a Qbasic program to define a function procedure having a numeric parameter which returns total number of factors of a number and use the function in a program to display prime numbers from 12 to 35.

DECLARE FUNCTION FAC(N)
CLS
INPUT "ENTER ANY NUMBER"; N
B = FAC(N)
PRINT "TOTAL NO. OF FACTORS="; B
PRINT "PRIME NUMBERS FROM 12 TO 35 ARE"
FOR J = 12 TO 35
    G = FAC(J)
    IF G = 2 THEN PRINT J
NEXT J
END
FUNCTION FAC (N)
FOR I = 1 TO N
    IF N MOD I = 0 THEN C = C + 1
NEXT I
FAC = C


END FUNCTION

Friday, February 2, 2018

Solved Kathmandu Pabson SEE Board Exam [Computer Science]

Group A
1a) What is centralized network? How it is different from client server network?
Ans: A centralized computing network is a network in which a central host computer performs data processing and storage on behalf of clients. It is different from client server network as client server network consists of at least one server and one or more client as well as client server provides high security of data and other resources.

b) List any three types of internet connection and define any one of them.
Ans: Any three types of internet connection are: 
i) Dial Up Connection
ii) ADSL Connection
iii) Fiber Connection
ADSL is a technology for transmitting digital information at a high bandwidth on existing phone lines to homes and businesses. Unlike regular dialup phone service, ADSL provides continuously-availbale, "always on" connection.

c) What is multimedia computer system? What are the components of multimedia?
Ans: A multimedia computer is a computer equipped with special hardware and software that makes multimedia possible. The components of multimedia are: text, graphics, video, audio and animation.

d) Why does a computer need air-conditioned room?
Ans: Computer system needs air conditioned room because the factor of climate such as temperature and humidity can pose a threat to computer security. Extremely heat can cause failure of electronic components. Excessive or very low humidity can also have an adverse effect on the computer equipment. 

e) Define computer virus. List few types of virus.
Ans: Computer virus is a program written by the programmer with the intention of destroying and damaging the data and programs residing in the computer system. The few types of virus are: boot sector virus, program virus, script virus etc.

3. Match the following.

NOS - Windows Server
Web Page - Any pages of the web site
CAT-5 - Transmission media
Spyware - Virus

4. Replace the following definitions with a technical term.
a) Medium that carries data without physical path. Unguided Media
b) Learning through electronic media. E-Learning
c) A collection of internet resources such as files, hyperlinked text, audio, video etc. WWW
d) The electronic transfer of monies with the goal of hiding its source and possibility its destination. Cyber Laundering.

5. Write the full forms: 
a) CCTV - Closed Circuit Television
b) SQL - Structured Query Language
c) .ORG - Organization
d) RGB - Red Green Blue

6. Choose the best answer.
a) Which is not the network protocol?
i) TCP/IP 
ii) STP
iii) FTP
iv) All of the above
Ans: STP

b) An important countermeasure against data corruption or loss.
i) Password Policy
ii) Backup system
iii) Scan disk
iv) Defragmentation
Ans: Backup system

c) Which one is not the type of virus?
i) Message Carrying
ii) Boot Sector
iii) Special Purpose
iv) System infector
Ans: Special Purpose

d) E-commerce..............
i) is a type business
ii) is a type of virus
iii) Both i and ii
iv) None of the above
Ans: is a type of business

Group B
7a) What is relational database software? Give any two examples.
Ans: It is a database management system that is based on the relation model in which data is stored in the form of tables and the relationship among the data is also stored in the form of tables. 
E.g.: SQL, MS-Access, Oracle, etc.

b) What is a form? What is the purpose of preparing form in MS-Access?
Ans: Form is an object of database which provides graphical interface to enter data into the tables or multiple linked tables. The purpose of preparing form in MS-Access is to provide an interactive platform for input of data into the database as well as to display data in more presentable form than a datasheet
.
c) Identify a record, field and value from the following table structure.
Roll        Name               Marks
1             Kopila                 87
2             Rabin Rana         56  
Ans: Record = 1  Kopila  87, 2     rabin Rana    56
Field = Roll, Name, Marks
Value = 87, 56

8a) Which is the default data type of MS-Access?
i) Number
ii) Auto Number
iii) Text
iv) Currency
Ans: Text

b) Field Size, Format, Input Mask, Default Value are ...........
i) Key elements
ii) Field Properties
iii) navigation modes
iv) Data types
Ans: Field Properties

c) Primary Key does not accept..............
i) Text
ii) Number
iii) Null Value
iv) None of the above
Ans: Null Value

d) Which is not MS-Access object?
i) Form
ii) Query
iii) Caption
iv) Table
Ans: Caption

9) Match the following.
Show final output - Report
Data Entry - Form
Change the table structure - Design View
Validation Rule - Field Properties

10. a) Write any two differences between user defined function and built-in-function.
Ans:
The two differences between user defined function and built-in-function are
User Defined Function: Function which is defined by the user according to the need is called user defined function. Examples: SUM ( ) , SHOW ( ), etc.
Built-in Function: Library functions are built-in or ready made functions provided by QBASIC. E.g. SQR( ), INT ( ) etc.

b) List any two data types used in C language.
The two data types used in C language are int and char.

c) Write down function of:
i) CLOSE: It closes one or all open files.
ii) NAME AS:  The NAME statement renames a file on a diskette

 11. Write the output of the following program:
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

The Output is :
2
22
222
2222
22222

12. Rewrite the following program correcting the bugs.
REM to print only male record on the printer from the data file.
OPEN "EMP.DAT" FOR OUTPUT AS #1
DO
INPUT #4, N$, A%, S$
SELECT CASE S
CASE MALE
PRINT N$, A%, S$
END SELECT
LOOP UNTIL EOF(1)
STOP #1
END

Debugged Program


REM to print only male record on the printer from the data file.
OPEN "EMP.DAT" FOR INPUT AS #1
DO
INPUT #1, N$, A%, S$
SELECT CASE S$
CASE "MALE"
PRINT N$, A%, S$
END SELECT
LOOP UNTIL EOF(1)
CLOSE #1
END
13. 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

Questions:
a) Write the output of the above program?
Ans: The output is:
7
15
31
63
127

b) Write down the function of MOD in the above program.
Ans: The function of MOD operator is to find the remainder.

14.a) WAP to calculate the area of four walls using FUNCTION.......END FUNCTION.

DECLARE FUNCTION AREA (L, B, H)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
AR = AREA(L, B, H)
PRINT “AREA OF FOUR WALLS”; AR
END

FUNCTION AREA (L, B, H)
A = 2 * H * (L + B)
AREA = A
END FUNCTION

b) WAP that ask any number and calculate its factors using sub procedure.

DECLARE SUB FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL FACT (N)
END

SUB FACT (N)
PRINT "FACTORS OF"; N; "=";
FOR I = 1 TO N
IF N MOD I = 0 THEN PRINT I;
NEXT I
END SUB

c) Write a program to input product name, quantity and price of some items and store them in STOCK.DAT file along with serial number for each record.


OPEN "STOCK.DAT" FOR OUTPUT AS #1
DO
    CLS
    INPUT "ENTER PRODUCT NAME"; N$
    INPUT "ENTER QUANTITY"; Q
    INPUT "ENTER PRICE"; P
    C = C + 1
    WRITE #1, C, N$, Q, P
    INPUT "DO YOU WANT TO CONTINUE(Y/N)"; CH$
LOOP WHILE UCASE$(CH$) = "Y"
CLOSE #1
END