Tuesday, 16 June 2020

SEE Solution Computer Science: 2070 to 2073

SEE Solution Computer Science: 2070 to 2073
SLC 2070 (Solved)
Computer Fundamental (22 marks)
Answer the following questions:                                      2×5=10
1.       a) What is network topology? Write any one advantage of star topology.
Ans: A network topology is the arrangement of computers, cable and other components on a network.
Any one advantage of star topology is:
i) Easy to add new computer and remove existing one. So, it is flexible.

b) Give any two advantages of E-mail over traditional mail.
Ans: Any two advantages of E-mail over traditional mail are
i) It is the cheapest and fastest means of communication as compared to our conventional postal mail.
ii) Email can be accessed from any part of the world and at any time.

c) List any two main aims of formulating cyber law in Nepal.
Ans: The two main aims of formulating cyber law in Nepal are:
i) To legalize the transaction through electronic media to control various types of electronic frauds
ii) To punish a person who does criminal activities through electronic means especially on computers.

d) Give any two symptoms of virus attack.
Ans: The two symptoms of virus attacks are:
i) Increased use of disk space and growth in file size
ii) Computer system slows down, files disappear.

e) Give the importance of UPS to the computer system.
Ans: The importance of UPS in computer security system is that it controls fluctuation of electric voltage and provides enough backup electric power to the computer system in the event of power failure of the source which protects the computer system and our valuable data.

a) Convert as instructed:                                                  0.5×2=1
i) (BED)16 into binary              
Converting Hexadecimal to Binary equivalent value
B
E
D
1011
1110
1101
Thus, (BED)16 = (101111101101)2
ii) (1010111)2 into octal
Converting Binary to Octal equivalent value
Making group of three bits from extreme right
001
010
111
Octal equivalent
1
2
7
Thus, (1010111)8    =(127)8
b) Perform the binary calculations                                 0.5×2=1
i) 1010 *10
     1 0 1 0
         *1 0
0 0 0 0
  1 0 1 0   .
1 0 1 0 0
ii) 10101 / 11
11)     10101 ( 111
-11
100
 – 11
    11
   -11
     00
Q = 111                          R = 0

3.       Match the following                                             0.5×4=2
Group A                                                         Group B
i) Combination of several media                a) Multimedia
ii) POP                                                        b) Protocol used in e-mail
iii) UTP                                                       c) Guided Media
iv) UPS                                                       d) Power Protection Device

4. Choose the correct answer                                   0.5×4=2
a) Which of the following is an audio output device?
i) Microphone  ii) Speaker iii) Monitor      iv) Printer
b) Which one is not a type of virus?
i) Message Carrying virus       ii) Boot sector virus
iii)System virus                       iv)Special Purpose Application Infector
c) Which one is bounded media?
i) Fibre optics ii) Microwave              iii) Infrared                  iv)Laser
d) Which one is an operating system software?
i) MS-Word     ii) MS-Excel    iii) Firefox       iv) MS-DOS

5.       Give an appropriate technical term for the following.  0.5×4=2
a) A program that can disinfect a file from virus               [Antivirus Software]
b) A person who steals or destroys other’s data, information and program 
    [Hacker]
c) A company that provides internet service  [ISP (Internet Service Provider)]
d) A computer in a network which can provide services to other computer.    [Server]

6 . Write the full forms of:                                                     0.5×4=2
a) TCP/IP    = Transmission Control Protocol / Internet Protocol
b) LAN       = Local Area Network
c) UPS        = Uninterruptible Power Supply
d) FTP        = File Transfer Protocol
Group B
Database (10 marks)
7.       Answer the following:                                                        2×3=6
a) Define data and information.
Ans: Data can be numbers, letters or symbols representing facts and figures which may or may not give any meaning.
Information is an organized collection of related data which gives a complete meaning.

b) What is report? Give its importance.
Ans: Report is an object of database which displays the output in an effective way to present the data in a printed format.
The importance of report are:
i) It displays the information the way we want to view it.
ii) It presents the information in designed layouts by adding necessary titles, setting font colour or font size, etc.

c) Name any four data types that can be defined in MS-Access.
Ans: Any four data types that can be defined in MS-Access are:
i) Text              ii) Memo          iii) Number      iv) Date/time

8.       Choose the best answer.                                                               0.5×4=2
a) The columns in database tables are called:
i) Record         ii) Field iii) Report        iv) Memo
b) Which is suitable data type to store video?
i) Text              ii) Number       iii) Hyperlink   iv) OLE object
c) Text data type can store maximum of ___characters
i) 250               ii) 350              iii) 255 iv) 355
d) Which of the following is database application?
i) MS-Word     ii) MS-Access iii) MS-Excel   iv) QBASIC


9.       Match the following                                                               0.5×4=2
Group A                              Group B
i) Indexing Data                   a) Searching Fast
ii) Form                                b) Graphical interface for data entry
iii) Field                                c) Column of datasheet
iv) OLE object                     d) Size upto 1 GB

Group C
Programming (18 marks)
a) What is a variable?                                                                                 1
Ans: Variable are the data item whose value may change during the execution of a program.
b) Name any two data types used in C language.                                     1
Ans: Any two data types used in C language are:
i) int                             ii) float

c) Give the functions of:                                                                          0.5×2=1
Ans:     i) NAME AS : The NAME statement renames a file on a disk.
ii) CLOSE : The CLOSE statement is used to close one or all open files.

11.   Rewrite the following program after correcting the bugs:       2
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=10
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:   1×2=2
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.
Ans: The numerical variables used in the above program are A, B and S.

b) Will the program run if the first line (i.e. DECLARE….) is deleted?
Ans: Yes, the program will run even 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 TEMP (C)
CLS
INPUT “ENTER TEMPERATURE IN CELCIUS”; C
PRINT “TEMPERATURE IN FAHRENHEIT=”; TEMP (C)
END
FUNCTION TEMP (C)
F = 9  * C / 5 + 32
TEMP = F
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 REVERSE (N$)
CLS
INPUT “ENTER ANY STRING”; N$
CALL REVERSE(N$)
END
SUB REVERSE (N$)
FOR I = 1 TO LEN(N$)
B$ = MID$(S$, I, 1) + B$
NEXT I
PRINT “REVERSED STRING IS “; B$
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”
DO WHILE NOT EOF(1)
INPUT #1, N$, E, N, M, S
PRINT N$, E, N, M, S
LOOP
CLOSE #1
END


SLC 2071 (Solved)
Computer Fundamental (22 marks)
1.       Answer the following questions:
    a. Give two-two difference between peer-to-peer and client/server network architecture.
Ans:These are the differences between peer-to peer and client/server network architecture:
Peer-to peer
Client/server
1.The type of network architecture in which
all the connected computers acts as both client and server is known as Peer-to-Peer network architecture.
1.The type of network architecture in which
all other computers in a network known as clients are handled or controlled by a single computer known as server is known as Client/Server.
2.It doesn’t have centralized server.
2.It contains  a separate centralized server.
3.It is expensive to setup and less secure.
3.It is cheaper to setup and more secure.

b. What is the function of file transfer protocol (FTP)?
Ans:The functions of File Transfer Protocol(FTP) are:
i.It enables the downloading and uploading of files into the internet.
ii.It manages the interaction between the computers on internet.

c. What is cyber crime? Give any two examples.
Ans:The crimes done through the misuse of computers , network and internet is known as cyber crime.
The two examples of cyber crime are:
i.Hacking
ii.Phishing

d. Write any four preventive measures for computer hardware security.
Ans:Any four Preventive measures for solving Hardware security problems are:
i.Insurance
ii.Regular maintenance
iii.Protection from dusts.
iv.Use of Power protection device

e. Write any two medium for transmission of computer virus.
Ans:Any two mediums for transmission of computer virus are:
i.Downloading of malicious files through internet and use of corrupted files.
ii.Sharing infected files through portable storage devices like pen drives.

2. a.Convert as indicated:
i.(108)10 into binary
Ans:
2
108
Remainder
2
54
0
2
27
0
2
13
1
2
6
1
2
3
0

1
1

 (108)10=(1101100)2

ii. (765)8into decimal
Ans:
(765)8=7*82+6*81+5*80
=448+48+5
=(501)10
(765)8=(501)10
b.Perform the following binary calculations:
i. 111*11
Ans
111
*11
111
+1110
10101
111*11=10101

ii. Divide 1101 by 11
                                      11 )        1101      (100
                                                   -11         
                                                     00
                                                     -0
                                                       01
Quotient=100
Remainder=01

3.       Match the following:
E-commerce    –       Online shopping
Volt guard       –  Power protection device
Satellite link     –       WAN
Sound card      –      Multimedia

4. Choose the best answer:
a. Which of the following is remote login service?
Video conferencing          ii. FTP              iii. Telnet         iv. TCP/IP
b. Process of arranging the scattered parts of file into a contiguous manner is _______.
i. debugging           ii. Backup        iii.Defragmentation      iv. Scandisk
c. Which of the following is an audio input device?
Printer     ii. Microphone             iii. Head phone                        iv. Speaker
d. Virus is a type of ___________.
i. System program  ii.Package program    iii.Destructive program   iv. Web program

5. Technical terms:
a. The data carrying capacity of communication channel.
Ans: Bandwidth
b. The moral principles that control cybercrime.
Ans: Computer ethics
c. Buying and selling product and services online.
Ans: E-commerce
d. An integration of text, audio, graphics and video.
Ans: Multimedia

6.       Write down the full forms:
LAN : Local Area Network
VOIP : Voice Over Internet Protocol
Gbps : Giga bits per second
DVD : Digital Versatile Disk

Group B
Database (10 marks)
7. Answer the following question:
a. Write any two advantages of computerized database.
AnsThe two advantages of computerized database are:
i.Larged volume of data can be stored in managed and systematic way.
ii.Retrieving of data is also easy due to data sorting and indexing.

b. Name any four objects of MS-Access database.
AnsThe four object of MS-Access are:
1.       Table
2.       Form
3.       Query
4.       Report

c. What is data sorting?
AnsThe method of arranging and grouping the data in ascending or in descending order in a database is known as data sorting.

8. State whether the following are true or false:
1.       Graphics can also be stored in MS-Access database.  True
2.       Maximum field size of memo field is 256 characters. False
3.       A form is an object of MS-Access used for entering data. True
4.       An action query makes changes in a table. True

9. Match the following:
1.       Indexing data   –      Searching fast
2.       Report               –       Final output
3.       Yes/No              –      Data type
4.       Select query     –       View data


10. Answer the following:
a. Mention the types of procedures used in QBasic.
AnsThe types of procedure used in QBasic are:
1.       Sub procedure
2.       Function procedure

b. Write two characteristics of C language.
AnsThe two characteristics of C language are:
i.It can be used for making large and powerful programmes.
ii.It’s easy for programming since it is a High Level Programming Language.

c. Write down the function of:
SHAREDThe function of SHARED is to declare a variable globally.
CALLThe function of CALL statement is to call sub procedure for performing specific task.

11. Re-write the following correcting the bugs:
Ans:
DECLARE SUB CUBE(N)
CLS
FOR I = 1 TO 5
READ No
CALL CUBE(No)
NEXT I
DATA 3, 5, 2, 6, 4
END
SUB CUBE(N)
PRINT N^3
END SUB


12. Write down the output:
DECLARE FUNCTION AVGE(A,B,C)
X=10
Y=5
Z=15
AV= AVGE(X,Y,Z)
RPINT “Average of three numbers”; AV
END
FUNCTION AVGE(A, B, C)
S=A+B+C
AVGE = S/3
END FUNCTION
Ans: 10

13. Study the following program and answer the following:
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.
AnsThe library function used in the above program is MID$.

b.List the conditional statement used in the above program.
AnsThe conditional statement used in the above program is:
IF …. THEN

14. a. Write a program using FUNCTION….END FUNCTION to input a string and count the total number of consonants.
AnsDECLARE FUNCTION COUNT(W$)
CLS
INPUT “Enter a Word”; W$
PRINT “The total numberr of consonant is”; COUNT(W$)
END
FUNCTION COUNT (W$)
C = 0
FOR I = 1 TO LEN(W$)
B$ = MID$(W$, I, 1)
C$ = UCASE$(B$)
IF C$ <> “A” AND C$ <> “E” AND C$ <> “I” AND C$ <> “O” AND C$ <> “U” THEN C = C + 1
NEXT I
COUNT = C
END FUNCTION

b. Write a program using SUB……END SUB to find the area of circle.
AnsDECLARE SUB AREA(R)
CLS
INPUT “Enter radius”; R
CONST PI=3.14
CALL AREA(R)
END
SUB AREA(A)
A=PI*R^2
PRINT “The area of circle=”; A
END SUB

c. 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.
AnsOPEN “Salary.Dat” FOR INPUT AS #1
CLS
WHILE NOT EOF(1)
INPUT #1, N$, P$, S
IF S>15000 AND S<40000 THEN PRINT N$, P$, S
WEND
CLOSE #1
END


SLC 2072 COMPUTER SCIENCE SOLVED PAPER
Group – A
(Computer fundamentals)
1.       Answer the following questions.
a)      Define LAN topology. Draw star topology.
Ans: The arrangement or connection pattern of nodes or computers and other devices of the network is called LAN topology.

b)      Give any two symptoms of virus attacks.
Ans: The symptoms of virus attacks are:
 i)   Program takes more time to load, fail to load or hang frequently.
 ii) Unexpected messages or images appear suddenly on the screen.

 c)      Write one advantage and one disadvantage of multimedia.
Ans: The advantage of multimedia is:
 i)     One can present ideas, information to others in effective ways.
The disadvantage of multimedia is:
 i)    The cost of developing a multimedia product is high.

d)     Write any two ways of protecting computer software.
Ans: The two ways of protecting computer software are:
i)Antivirus Software
ii)Backup System

e)      Write any two services of internet.
Ans: The two services of internet are:
i) WWW (World Wide Web)
ii)E-mail


2.       a)Convert as indicated:
i)(208)10 into Binary
2
208
2
104
0
2
52
0
2
26
0
2
13
0
2
6
1
2
3
0
1
1













 (208)10=(11010000)2
ii)(104)8 into decimal
Converting octal to decimal,
=1*82+0*81+4*80
=1*64+0*8+4*1
=64+0+4
=68
(104)8=(68)10

b) Perform the binary calculations:
i)1011+1101
1011
  +  1101
11000
1011+1101=11000
ii)110*11
110
   *11
110
   + 110x
10010
110*11=10010

3.       Match the following:
a)      Microwave        :           Unguided media
b)      UTP                   :           Guided media
c)      UPS                   :           Power protection device
d)     SMTP                :            Protocol

4.       State whether the following statements are true or false:
a)      Walky-talky is an example of full duplex mode.
Ans: False
b)      Data transfer rate is higher in optical fiber cable than in co-axial cable.
Ans: True
c)      The computer security refers to hardware security only.
Ans: False
d)     Sound Card is one of the components of multimedia.
Ans: True

5.       Write the appropriate technical terms of the following:
a)      A program that can disinfect a file from virus. Antivirus software
b)      A person who steals or destroys other’s data, information, files and program.  Hacker
c)      A company which provides the internet facilities.   ISP
d)     A computer which provides services to other computers in a network.
       Server Computer 

6.       Write the full forms of:
i)URL              : Uniform Resource Locator
ii)HTTP           : HyperText Transfer Protocol
iii)LAN            :Local Area Network
iv)MODEM     :Modulator-Demodulator

Group – B
(Database)
7.       Answer the following questions:
a)      Write any four data types used in Ms-ACCESS.
Ans: Four data types used in Ms-ACCESS are:
i)     Text                 ii)   Number          iii) Currency        iv) Date/Time
b)      Define database with example.
Ans: The systematic collection of organized and related information that can be used for different purposes is called database. For example: dictionary and telephone directory.
c)      What is query?
Ans: A query is one of the objects of MS-Access that allows us to retrieve the desired information from a table or multiple linked tables.

8.       State whether the following statements are true or false:
a)      A query is used to select fields and records from only one table.
Ans: False
b)      MS-ACCESS is DBMS software.
Ans: True
c)      Index decreases the speed of query and sort operations.
Ans: False
d)     Data in primary key has to be unique and not null.
Ans: True

9.       Match the following:
a)      OLE                          :       Data type
b)      Validation Rule        :       Limits the value
c)      Form                         :       Data Entry
d)     Indexing                   :       Easy to search

Group – C (Programming)
10.   a) What is procedure?
Ans: The separate block of statements used by the module level code and called by any number of times is called procedure.
b) Write any two data types used in ‘c’ language.
Ans: The two data types used in the ‘c” language are:
i)     int       ii)      float

c) Write down the functions of the following statements:
i) OPEN: It opens a sequential file for one of the three possible operations i.e. reading, writing or appending.
ii) MKDIR: It makes or creates a new directory on the specified disk.

11.   Re-write the following program after correcting the bugs:
Debugged program:
DECLARE FUNCTION SUM(m,n)
Rem to print sum of two numbers
a=6
b=7
PRINT SUM(a,b)
END
FUNCTION SUM(m,n)
S=m+n
SUM=S
END FUNCTION

12.   Write the output of the following program:
DECLARE FUNCTION Interest(p,t,r)
CLS
LET p=100
LET t=2
LET r=5
LET d=Interest(p,t,r)
PRINT “The simple interest=”;d
END
[possible missing code………]
FUNCTION Interest (p,t,r)
Interest=(p*t*r)/100
End FUNCTION
OUTPUT
If the sub module is missing then error message will be displayed.
Otherwise : The Output will be:
The simple interest = 10

13.   Study the following program and answer the following questions:
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 the above program.
Ans: The name of the user defined function used   in the above program is Prod.

b)       Name the loop in the above program.
Ans: The loop in the above program is FOR…NEXT.

14.   a) Write a program using SUB…..END SUB to display reverse of input-string.
DECLARE SUB REV(A$)
CLS
INPUT “ENTER ANY STRING”;A$
CALL REV(A$)
END
SUB REV(A$)
FOR I= 1 TO LEN(A$)
B$=MID$(A$,I,1)
W$=B$+W$
NEXT I
PRINT “REVERSED STRING=”W$
END SUB

b) Write a program using FUNCTION…END FUNCTION to find area of the triangle.
DECLARE FUNCTION AREA(B,H)
CLS
INPUT “ENTER BASE”;B
INPUT “ENTER HEIGHT”;H
PRINT “AREA OF TRIANGLE”;AREA(B,H)
END
FUNCTION AREA(B,H)
AREA=0.5*B*H
END FUNCTION

c)      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.
OPEN “Marks.dat” FOR INPUT AS #1
CLS
DO WHILE NOT EOF(1)
INPUT #1, N$, A, C$, T#
PRINT N$, A, C$, T#
LOOP
CLOSE #1
END

                                           SEE 2073 COMPUTER SCIENCE SOLVED PAPER
Group – A
(Computer fundamentals)

1. Answer the following questions.
a) Write any two advantages of BUS topology.
AnsThe advantages of bus topology are:
It is easy to set up computers and other devices in bus topology, because all the devices are connected through a single wire.
It requires fewer cable media, so it is cheaper than other typologies.

b) Define computer security.
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.

c) Write any two preventive measures to protect computer system from computer virus.
Ans: Any two preventive measures are:
i) Do not install pirated software, especially computer games
ii) Scan the mail or unknown files of internet before opening in your computers.

d) What is multimedia?
Ans: Multimedia is the integration of multiple forms of media, which presents information in more interesting and understandable way.

e) Write the use/function of File Transfer Protocol.
Ans: The use of File Transfer Protocol is to transfer the file from one computer to another computer. It helps to upload and download the files.

2. a) Perform the conversion as per the direction:
            i) (BAD)16 into binary
            Soln:
            Converting Hexadecimal to Binary
            B = 1011
            A = 1010
            D = 1101
            (BAD)16 = (101110101101)2

ii) (1111001)2 into octal
Soln:
Converting Binary to octal
001 = 1
111 = 7
001 = 1
(1111001)2 = (171)8
           

3. Match the following:
a) Malicious software            virus
b) Primary storage device      RAM
c) Power protection Device    UPS
d) Intellectual property law    copyright

4. State whether the following statements are true or false:
a) Computer Network reduces the cost. True
b) WWW is an organization which controls Internet. False
c) Microwave transmission is an example of bound media. False
d) The parts of the computer which can be seen and touched are called hardware. True

5. Write the appropriate technical terms of the following:
a) A type of network in which every computer works as both client and server.   Peer-to-peer network
b) Protocol used to receive email from the mail server. POP
c) The moving graphics images.   Animation
d) The law that controls cyber crimes.  Cyber Law

6. Write the full forms:
a) LAN: Local Area Network.
b)ROM: Read Only Memory.
c) SMTP: Simple Mail Transfer Protocol.
d)NOS: Network Operating System.

7. Answer the following questions.
a) Define data and database.
Ans: Data can be numbers, letters or symbols representing facts and figures which may or may not give any sense. Database is a collection of related and organized information that can be used for different purpose.

b) What is primary key? Write its importance.
Ans: Primary key is a field that uniquely identifies the record. It is needed because it neither accepts duplicate values nor  permit null values.
The importance of Primary key are:
i) To reduce and control duplication of record in a table.
ii) To set the relationship between tables.

c) Name any four data types used in MS-Access.
Ans: Any four data types of MS-Access are:
i) Text                         iii) Memo
ii) Number                  iv) Currency

8. Select the correct answer:
a) The columns in a database table are called………………………
Ans: Field
b) Which is the suitable data type to store video?
Ans: OLE object
c) …………… object of MS-Access is used to print formatted data.
Ans: Report
d) Which is not a type of query?
Ans: Search

9. Match the following:
a) Query                     Extracts selected record for view
b) Form                       Allows view, edit, input data
c) Table                       Stores data
d) Report                    Printed format


10.
         a) What is a loop?
Ans: Loop can de defined as repeating the statement of statement blocks for a number of times.

        b) Write the functions of  NAME and CLOSE statements.
Ans: The function of NAME statement is to  renames a file on a diskette.  The function of CLOSE statement is to close one or all open files.

c) What is variable?
Ans: The data item whose value changes during the execution of a program is called variable.

11. Re-write the given program after correcting the bugs:
Debugged Program
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 of digits”;S
END

12. Write the output of the following program.
DECLARE FUNCTION AREA (L, B)
CLS
LET L = 50
LET B = 10
LET ans = “; ans
PRINT “The area=”; ans
END
FUNCTION AREA (L, B)
Ar=L*B
AREA=ar
END FUNCTION

Output
The area = 500

13. State the following program and answer the given questions:
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.
Ans: The numeric variables used in the above program are A, B and Difference

b.      List the local variables used in the above program.
Ans: The local variables used in the above program is A, B and Difference

14
a) Write a program to calculate the area of four walls using Sub….End Sub. [Hint: Area=2H(L+B)
DECLARE SUB AREA (L, B, H)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
CALL AREA (L, B, H)
END
SUB AREA (L, B, H)
A = 2 * H * (L + B)
PRINT “AREA OF FOUR WALLS”; A
END SUB

b) Write a program to input a word in the main module and count the total number of vowel characters present in the word using FUNCTION…END FUNCTION.
DECLARE FUNCTION COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
PRINT "TOTAL NO. OF VOWELS= "; COUNT(S$)
END 
FUNCTION COUNT (S$)
VC = 0
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
C$ = UCASE$(B$)
IF C$ = "A" OR C$ = "E" OR C$ = "I" OR C$ = "O" OR C$ = "U" THEN
VC = VC + 1
END IF
NEXT I
COUNT = VC
END FUNCTION

c) Create a data file to store the records of few employees having Name, Address, Post, Gender and Salary fields.
OPEN “std.rec” FOR OUTPUT AS #1
DO
CLS
INPUT “Enter Name”; N$
INPUT “Enter Address”; A$
INPUT “Enter Post”; P$
INPUT “Enter gender”; G$
INPUT “Enter Salary”; S
WRITE #1, N$, A$, P$, G$, S
INPUT “Do you want to continue”; CH$
LOOP WHILE UCASE$(CH$)=”Y”
CLOSE #1
END

No comments:

Post a Comment

MCQ Question Bank Microsoft PowerPoint