Wednesday, July 25, 2018

QBASIC Program to calculate loss or profit percentage

Q. Write a QBasic program using user defined function pp(sp,cp) to input selling price and cost price in parameter. then calculate profit or loss percentage. use the function to return the profit pr loss percentage.

DECLARE FUNCTION PP(SP,CP)
CLS
INPUT "ENTER SELLING PRICE"; SP
INPUT "ENTER COST PRICE"; CP
PL= PP(SP, CP)
END

FUNCTION PP (SP, CP)
IF SP > CP THEN
    P = ((SP - CP)) / CP * 100
    PRINT "PROFIT PERCENTAGE="; P
ELSE
    L = ((CP - SP)) / CP * 100
    PRINT "LOSS PERCENTAGE="; L
END IF
END FUNCTION

QBASIC Program Display Prime Number

QBASIC PROGRAM [ SEE / SLC NEPAL]
Q. Write a 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 FACTOR(N)
CLS
INPUT "ENTER ANY NUMBER"; N
A = FACTOR(N)
PRINT "TOTAL NO. OF FACTORS"; A
PRINT "PRIME NUMBERS FROM 12 TO 35 ARE";
FOR J = 12 TO 35
    IF FACTOR(J) = 2 THEN PRINT J;
NEXT J
END

FUNCTION FACTOR (N)
FOR I = 1 TO N
    IF N MOD I = 0 THEN C = C + 1
NEXT I
FACTOR = C
END FUNCTION


Sunday, July 8, 2018

MAAF First Term Exam 2075 Computer Science Questions Solved

MAAF First Term Exam 2075 Computer Science Questions Solved 

Group A [Fundamentals - 30 Marks]

1. Answer the following questions: [7x2=14]
    a) What is telecommunication? Write 2/2 advantages and disadvantages of computer                        network.
     Ans: Telecommunication is a system of transmission of sounds, images, texts or data in the form of  electronic signals.
                Any two advantages of computer network are as follows:
          i) The computers on a network can share hardware devices like printer, hard disk, scanner   etc.
          ii) Software packages can be shared between network connected computers.
               Any two disadvantages of computer network are as follows:
          i) The sharing of information may leak the privacy of other clients.
          ii) If any computer system in a network gets affected by computer virus, there is a big chance of spreading computer viruses on other computers on the network.
b) What do you mean by transmission medium? Write its types.
Ans: Transmission medium is a pathway through which data are transmitted in a network. Its types are:
          i) Guided transmission medium  
               ii)Unguided transmission medium
     c) Define network protocols with some examples.
      Ans: A network protocol is a set of rules by which computers on the network communicate with each other. Some examples of protocols are: TCP/IP, SMTP, POP, HTTP etc.
     d) Define the terms: MODEM and Router.
      Ans: MODEM is a device which is used to transfer the data of one computer to another computer using telephone lines.
               A router is an intelligent network device which connects multiple networks that uses the same protocol and forwards data packets from one network to another.
     e) What is E-mail? Write its advantages.
     Ans: E-mail (Electronic mail) is one of the most popular services provided by the internet which exchanges messages between the computers over the internet. Its advantages are:
               i) It allows to send and receive message across the world at very low cost.
               ii) Multiple copies of same message can be sent to many people.
     f) What is internet? Explain its any two services.
      Ans: Internet is an interconnection of several thousands of computers of different types belonging to the various networks all over the world. Any two services of internet are:
               IRC: Internet Relay Chat is one of the important services provided by the internet which allows the user to communicate with other people in real time.

               E-Commerce: It is the buying and selling of goods over the internet.
    g) What do you mean by uploading and downloading?
     Ans: Uploading refers to copying files or documents, programs or data from the user computer to the internet server.
              Downloading refers to the copying files or document or program or data from the internet server to the user computer.
2. a) Perform the following binary calculations: [3x1=3]
        i) (10101 + 11101) - 1011


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

-
1
0
1
1
1
0
0
1
1
1

\ (10101 + 11101) - 1011 = 100111


       ii) (11011 x 111)




1
1
0
1
1




´
1
1
1



1
1
0
1
1


1
1
0
1
1
´

1
1
0
1
1
´
´
1
0
1
1
1
1
0
1

\(11011 x 111) = 10111101


      iii) (1011011) / (101)
1
0
1)
1
0
1
1
0
1
1(
1
0
0
1
0



1
0
1










     

´
´
´
1
0
1












1
0
1












´
´
´
1














0














1





\Quotient = 10010
    Remainder = 1

b) Perform as indicated: [3x1=3]
    i) (364)8 into Decimal
       Soln:
       = 3´82 + 6´81+4´80
       = 3´64 + 6´8 + 4´1
       =192 + 48 + 4
       =244
      \(364)8 = (244)10 

   ii) (945)10 into Hexa

16
945
Remainder
16
59
1
16
3
11
16
0
3

\(945)10 = (3B1)16 

  iii) (101101011)2 into Octal

Soln:
Converting Binary to Octal,
101 = 5
101 = 5
011=3
 =553
\(101101011)2 = (553)8 
 3. Match the following:[4x0.5=2]
     Group A                        Group B
a) Node                            i) powerful computer
b) Protocol                       ii) prevents gaining access
c) Scan disk                      iii) checking for disk error
d) Firewall                       iv) workstation
                                         v) rules for network communication

Answers:
Group A                        Group B
a) Node                            i) workstation
b) Protocol                       ii) rules for network communication
c) Scan disk                      iii) checking for disk error
d) Firewall                       iv) prevents gaining access

4.  Select the correct answer: [4x0.5=2]                                    
     a) Unbounded communication medium is ...................
         i) Satetllite        ii) Dial Up        iii) Fiber Optics         iv) UTP
         Ans: Satellite
     b) The process of converting digital signals into analog signals.
         i) Modulation    ii) Demodulation     iii) Both i) and ii)         iv) None of them
         Ans: Modulation
     c) Device used to connect different type of network protocol.
         i) MODEM        ii) Gateway        iii) Bridge         iv) NIC
          Ans: Gateway
     d) Connection of computer between two different countries.
         i) WAN        ii) MAN        iii) WLAN         iv) Wi-MAX
         Ans: WAN

5. Give the appropriate technical terms of the following: [6x0.5=3]
    a) A hardware device that provide common wiring point in LAN.
        Ans: hub
    b) Protocol used to receive e-mail from mail server.
        Ans: POP
    c) The cabling structure of interconnected computers in LAN.
        Ans: Topology
    d) Protocol used to transfer files on the WWW. 
        Ans: FTP
    e) A program that allows a user to interact with web pages.
        Ans: Web browser
    f) Doing business through internet.
        Ans: E-commerce

6. Write the full form of the following: [6x0.5=3]
    a) UTP: Unshielded Twisted Pair
    b) MAC : Media Access Control
    c) URL: Uniform Resource Locator
    d) HTTP: Hyper Text Transfer Protocol
    e) ISDN : Integrated Services Digital Network
    f) ARPA : Advanced Research Projects Agency


Group B [Programming - 20 Marks]
7a) What is variable? List the Qbasic Operators. [1]
       Ans: The data items whose value changes during the execution of a program is called variable. The list of QBasic operators are:
       i) Arithmetic operators
       ii) Relational operators
       iii) Logical Operators
       iv) String operator

  b) Why QBasic is called modular porgramming? [1]
         Ans: QBasic is called modular programming because it divides program into many small, manageable, logical and functional modules or blocks.
  
c) Write any two advantages of modular programming. [1]
         Ans: The advantages of modular programming are:
             i) Different programmers can design different program modules independently, which is required in a large and complex program.
             ii) It is easy to design code and test the program modules independently.
  
d) Write the purpose of the following built - in functions. [1]
       i) MID$ ( ) : It is a string function that returns the specified number of characters from the specified location of string.
       ii) INT ( ) : It rounds and returns the largest integer less than or equal to a numeric expression.

8. Rewrite the given program after correcting the bugs. [2]
REM program to display reverse of supplied string
DECLARE SUB REVERSE (A$)
CLS
INPUT "Enter the value"; A$
CALL REVERSE$ (A$)
END

SUB REVERSE (A$)
FOR J = 1 TO LEN(A$)
B$ = MID$(A$, 1, J)
P$ = P$ + B$
NEXT J
PRINT A$
END SUB

Debugged Program:

REM program to display reverse of supplied string
DECLARE SUB REVERSE (A$)
CLS
INPUT "Enter the value"; A$
CALL REVERSE (A$)
END

SUB REVERSE (A$)
FOR J = LEN(A$) TO 1 STEP -1
B$ = MID$(A$, J, 1)
P$ = P$ + B$
NEXT J
PRINT P$
END SUB




9. Write the output of the following program. [2]
DECLARE SUB num ( )
CLS
CALL num
END

SUB num
P = 2
A = 1
FOR K = 7 to 1 STEP -2
N = N + A
PRINT N
A = A + P
NEXT K
END SUB

OUTPUT:
1
4
9
16

10. Study the following program and answer the given questions. [3x1=3]

DECLARE SUB check(a$)
a$ = "Information Communication Technology"
CALL check(a$)
END

SUB check(a$)
b = LEN(a$)
count = 2
WHILE count<=b
x$ = x$ + MID$(a$, count, 1)
count = count + 1
WEND
PRINT x$
END SUB

a) List the operators in above program.
    Ans: The operator used in the above program are: = , <=  and +

b) Write the name of sub procedure in the above program.
    Ans: The name of sub procedure is check.

c) What will be the value of 'b' in the above program?
     Ans: The value of b is 36.




11. a) Write a program using sub procedure to print series: 3, 33, 333, ...upto 5th terms. [3]

DECLARE SUB SERIES ()
CLS
CALL SERIES
END

SUB SERIES
A= 3
FOR I = 1 TO 5
PRINT A
A= A* 10 + 3
NEXT I

END SUB


    b) Write a program using SUB......END SUB to print only middle number among three supplied numbers. [Hint: Neither greater nor smaller] - [3]

DECLARE SUB MIDDLE(A, B, C)
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
CALL MIDDLE (A, B, C)
END
SUB MIDDLE (A, B, C)
IF A > B AND A < C OR A < B AND A > C THEN
PRINT A; “IS MIDDLE NUMBER”
ELSEIF B > A AND B < C OR B < A AND B > C THEN
PRINT B; “IS MIDDLE NUMBER”
ELSE
PRINT C; “IS MIDDLE NUMBER”
END IF 
END SUB


    c) Write a program using function procedure to print volume of cylinder. 
         [Hint: Volume = Pie*R^2] - [3]

DECLARE FUNCTION VOLUME (R, H)
CLS
INPUT “ENTER RADIUS”; R
INPUT “ENTER HEIGHT”; H
PRINT “VOLUME OF CYLINDER ”; VOLUME(R, H)
END

FUNCTION VOLUME (R, H)
VOLUME = 3.14 * R ^ 2 * H
END FUNCTION