CS I - Notes
CS I - Notes
CS I - Notes
July –17 Write any two important features of the following operating systems:
i) Windows 98 ii) LINUX iii) Windows NT
What is System Call? List any two system calls for Memory Management,Process Management and
July –17
Information Management.
July –17 What is GUI? State any four advantages of GUI.
July –17 What is partitioning? Explain fixed and variable partitioning.
Mar –17 State the various steps involved in the allocation of partition in case of
fixed partition memory management.
Mar –17 Discuss Virus Detection, Virus Removal and Prevention Philosophies.
What functions are performed by Memory Management of Operating System? State any four Memory
Mar –17
Management System.
Mar –17 With reference to process management, explain the following terms:
i) External Priority ii) Purchased Priority iii) Internal Priority iv) Time Slice
Mar –17 What is Computer Virus? What are the different methods by which virus can infect other programs?
July–16 Explain in short the functions of minimize, maximize and close buttons in the MS-windows environment.
July–16 Why video terminal is called memory mapped? Explain the difference between alphanumeric and graphic
memory mapped video terminal.
Oct-13 Explain any two important features for each of the following operating system :
i) Windows 98 ii) Windows NT iii) LINUX
Oct-13 What is Video RAM? Explain the use of attribute byte and data byte of Video RAM with example.
Oct-13 Explain in short the three main function to be carried out by Memory Management module of an operating
system. State any two types of Contiguous Real Memory Management System.
Oct-13 What are computer worms? Explain its modes of operation.
Oct-13 Explain the term multitasking with suitable example.
Mar-13 Explain in short the three main functions to be carried out by Memory Management Module of Operating
System. State any two types of Contiguous Real Memory Management System.
Mar-13 Explain in brief three major services provided by the operating system.
Mar-13 What is process? Explain running, ready and blocked process states of Process Management.
Oct-12 What is GUI? Explain any two essential components of GUI.
Oct-12 Explain any four features of Window-NT operating system.
Oct-12 Define the term ‘Security’ with respect to an operating system. Explain any two elements of security.
Oct-12 Define the term Process. Explain running, ready and blocked process state in a Process Management.
Oct-12 State the different services provided through Information Management Service of Operating System.
Oct-12 State various steps involved in the allocation of a partition in case fixed partition memory management.
Mar-12 What is GUI? State any four advantages of GUI.
What are different functions performed by Memory Management in an Operating System? Explain types of
Mar-12
partition in brief.
Mar-12 What is the difference between a worm and virus? Explain how these can be prevented?
Mar-12 Define a block with reference to Operating System. What are the parameters of a block of data that are
concerned with an Operating System. Explain in brief.
Mar-12 What is a Process? Explain ready, running and blocked process states in Process Management.
Oct-11 Explain the use of video RAM. Explain data byte and attribute byte.
Oct-11 Explain any four features of WINDOWS-NT Operating System.
Oct-11 Discuss virus detection, removal and prevention philosophies and methods.
Oct-11 Differentiate between paging and segmentation.
Oct-11 Explain context switching at a process level in Multi Programming System with example.
Mar-11 Explain in short the function of Menu bar and Scroll bar components of GUI
Oct-10 In case of Windows Operating System, explain the following options of File Menu:
i) Open ii) Print iii) Save as
Oct-10 Why video terminal is called as memory mapped? Explain difference between alphanumeric (character
oriented) and graphic (bit oriented) memory mapped video terminals.
Oct-10 What is Computer Worm? Explain its mode of operation.
Explain Single Contiguous and Fix Partition Memory Management System with suitable memory mapping
Oct-10
diagram.
Linux Kernel
Loadable Modules
Q) Explain the file system related to Information Management with file operations only.
The file system related to IM allows the user to defines files and directories and allocates or
deallocates the disk space to each file. A file is a collection related information. It can program or data.
File Operation in Information Management:-
The file concept is implemented by the operating system. An IM provides system calls such as create,
read, write, rewind and delete files etc.
1) Create a file :- For creating a file first whether sufficient space is available for that file is checked in disk. If it
is available then entry for new file must be made in directory.
2) Write to a file:- For writing to a file first there is command in which name of the file is given. Then operating
system searches for that file in directory entry and write to it.
3) Reading a file:- For reading a file there is a system call in which file name is specified. Then operating
system searches for that file in directory entry and read it.
4) Rewind a file:-The directory is searched for appropriate entry and file is reset to the beginning of file.
5) Delete a file :- To delete a file directory entry is searched and of file is found it releases the memory space
and that directory entry now become invalid.
Q) What is access method? Explain different access methods.
File stores information. When it is used then this information must be accessed and read into computer
memory.
Types of access methods:
There are several methods to access the information in the file
1) Sequential Access Method : Here file is accessed sequentially. In this a program skip forward or backward
„n‟ records. In this operations such as read and write.
2) Direct Access Method : Direct access is based upon a disk model of a file. Here the file viewed as a
sequence of blocks or records. In this method any block can be read or written.
A typical alphanumeric screen can display 25 lines each consisting of 80 characters i.e. 25X80=2000
characters.
1) Data Byte
All 2000 characters are stored in video RAM. To display any specific character on the screen at
a specific position all ASCII or EBCDIC code for characters is to move in video RAM.
2) Attribute Byte
There is one attribute byte for each data byte. This byte tells the video controller how the
character is to be displayed. It signifies whether the corresponding data character which is stored next
to it in the video RAM is to be displayed bold, underlined, blinking or in reverse video etc
Q) Why keyboard is referred as memory map terminal? Explain the multiple memory location involved
in the input-output operations between the keyboard and screen.
Terminals have a video RAM is generally with 2000 data bytes preceded by 2000 corresponding
attribute bytes. Anytime all the 2000 characters i.e. 25 lines X 80 columns on screen are stored in video RAM
are displayed on the screen by the video controller.
The video RAM is treated as part of the main memory only. Thus for moving any data in or out of the
video RAM ordinary load or store instructions are sufficient. So keyboard is referred as memory map terminal.
The following multiple memory locations are involved in the input-output operations between the
keyboard and screen :
1) Small memory within the keyboard itself
When character is keyboard in the 8-bit ASCII or EBCDIC code is generated which is stored
temporarily in the memory of the terminal itself.
2) The video RAM(data byte and attribute byte)
The ASCII or EBCDIC code for the character is to move to the video RAM at the corresponding
position with appropriate coordinates.
3) The operating system buffers
The operating system has one buffer for each terminal and two separate buffers for input and
output operations.
4) The Input/Output area of the application program
When the user finishes keying in the data then data is stored in operating system buffer for that
terminal is flushed out to the input/output area of the application program which wants that data.
Q) What is a process?
1) Process is a task. 2) Process is an asynchronous activity. 3) Process is an animated spirit of procedure.
4) Process is the locus of control of procedure in execution.
5) Process is defined as a program under execution which competes for CPU time and other resources.
Q)Explain the single contiguous memory management systems with a suitable memory mapping
diagram.
Operating System In single contiguous memory management system the physical memory
( Monitor ) is divided into two contiguous areas. Such as one area is permanently
allocated to the resident portion of the operating system and the other area is
User Process used for user process.
Area As shown in figure operating system may be loaded at lower addresses
i.e. 0 TO P. At any time only one user process is in the memory. This process
is run to completion and then the next process is brought in the memory.
Q) Difference between contiguous memory management and Non contiguous memory management
Contiguous Memory Management Non Contiguous Memory Management
1) This system expect the program to be loaded in 1) In this system program is divided into different
contiguous memory location. chunks and to be loaded at different portitions of
the memory.
2) Examples: 2) Examples :
i)Single contiguous memory management system. i) Paged memory management system.
ii)Fixed partition memory management system. ii) Segmented memory management system.
iii) Combined memory management system.
Q) What is partitioning? Explain different types of partitioning methods.
OR What is partitioning? Explain fixed and variable partitioning.
Partitioning means dividing main memory into various sections. These sections are called as partitions.
The partitioning is used by operating system by MM to allows multiprogramming.
Types of partitions :
There are two types of partitioning methods such as :
1) Fixed partitioning OR Static partitioning
2) Variable partitioning OR Dynamic partitioning
1) Fixed Partitioning OR Static Partitioning:
In this partitioning the size is fixed or constant. The partitioned segments are different sizes and
fixed. But once they are decided then can not be changed. In this method partitions are fixed at the time of
system generation. At this time system manager has to declare the partition time. Fixed partition is also called
as static partition. On declaring fixed partitions the operating system creates a partition description table
(PDT).
Disadvantages of fixed partitioning:
1) Fixed partitioning suffers from internal fragmentation i.e. wastage of memory space within the partition.
e.g. suppose the partition size is 200KB and a job is of 100KB then 100KB of memory will be wasted. This
wastage of memory is called as internal fragmentation.
2) Fixed partitioning reduces degree of multiprogramming.
3) Fixed partitioning restricts CPU utilization.
2) Variable Partitioning OR Dynamic Partitioning :
The fixed partition suffers form the problem of internal fragmentation i.e wastage of memory
space within partition. It also limits the degree of multiprogramming and CPU utilization. The variable partition
overcomes these problems.
In variable partitioning number of partitions and their sizes are variable. They can not defined at
the time of system generation. These partitions are created by operating system at the run time and they are
different sizes. In variable partitioning starting address of partition is not fixed.
Difference between Fixed and Variable partition
Fixed Partition Variable Partition
1) Partition created could not be changed. 1) Partition created can be changed.
2) Partition can be defined at the time of generation. 2) Partition can not be defined at the time of
generation.
3) If suffers form problem of internal fragmentation. 3) Problem of internal fragmentation is solved.
4) Number of partition and their sizes are fixed. 4) Number of partition and their sizes are variable.
Q) Define a block with reference to operating system. What are the parameters of a block of data that
are concerned with an operating system. Explain in brief.
Block : A block is a logical unit of data that operating system defines for its convenience. Thus block is
a contiguous set of bits or bytes that forms an identifiable unit of data.
Parameters of Block: An operating system has following parameters of a block:
1) File ID : It is a letter code given to each type of data file to make it easier for the operating system to
identify the files.
2) The starting position in the file: It is the address of memory location from where file will start.
3) The number of bytes to be read: It is total size of file in bytes.
4) The starting address of memory where data is to be read: It is starting address of block.Whenever
program read any data the file system translates request into reading one or more sector from disk and
instruct device driver to read these sector. Operating system keeps all its data structure in terms of block. O.S.
translates a block number into sector number. File system request to read desired blocks. It uses disk space
allocation i.e. linked list to carry out translation. File system then request deice driver to read desired block.
Device driver issues instruction to the controller for the disk to read required blocks. Controller reads data
sector by sector by sector and stores it in its own memory until desired block are read in.
Q)State the various steps involved in the allocation of a partition in case of fixed partition memory
management.
When a process is to be allocated a partition following take place
1) The long term process scheduler of the process management decides which process to be brought
into the memory.
2) Then it find out the size of the program to be loaded by consulting the information management portion
of the operating system. For this the compiler keeps track of size of the program in the header of the
executable file.
3) Then it makes a request to the partition allocation routine of the memory management to allocates a
free partition with the appropriate size. For this partition description table is useful.
4) With the help of the information management module it now loads the binary program in the allocated
partition. It then makes an entry of the partition ID in the PCB (process control block) before the PCB is linked
to the chain of ready processes by using the process management module of the operating system. Thus the
routine in the memory management now redefines partition description table (PDT) and marks the status of
that partition as allocated called ALLC. The process management eventually schedules this process.
Consider the following partition description table (PDT)
0K
P0 PDT
100 K
Partition Partition
Process A ID
P1
Starting Size Status
400 K Address
0 0 KB 100 KB FREE
Process B
P2 1 100 KB 300 KB ALLC
600 K 2 400 KB 200 KB ALLC
3 600 KB 300 KB FREE
P3 4 900 KB 100 KB ALLC
900 K
Process C
P4
1000 K
Page 1 1 4 2
3 Page 2
Page 2 2 3
4 Page 1
Page 3 3 7 5
7 Page 3
Physical Memory
When a computer program is to be executed then its pages are loaded into any available
frames and page table is defined to translate from user pages to memory frames. The page size is defined by
hardware. If is typically a power of 2.
Q) Explain various disk space allocation with their merits and demerits.
There are two major types for the allocation of disk space to files these are :
1) Contiguous Allocation: It requires each file to occupies a set of contiguous address on the disk. An
unallocated segment is called as hole. If a new file is created and there are set of holes then following
strategies is used and selects a free hole from set of holes.
i)First Fit: This allows first hole that is big enough. ii)Best Fit :This allocate the smallest hole that is big
enough. iii) Worst Fit:This allocates largest hole.
Merits :If processing is sequential and if the operating system uses buffered I/O then processing speed can
increases.
Demerits Space wastage and inflexibility.
1) Non Contiguous Allocation: In this maximum size of the file does not have to be predicted at the
beginning. The file can grows with time as per needs. This reduces wastage of space.
There are two methods of non-contiguous allocation such as
i) Chained Allocation :It is used in non-contiguous allocation. In this each file is a linked list of disk blocks
then disk block may be scattered anywhere on the disk. The directory contains a pointer to the first and last
block of the file. Create a file in this allocation is easy.
Merits :
1) There is no external fragmentation.
2) There is no need to declares size of file when it is created.
Demerits:
1) Each file requires space for pointer.
2) If a pointer is lost then it can not open file.
ii) Indexed Allocation: In this all pointer are brought together into one location is called as indexed block.
Each block has its own index block which is an array of disk block address. An index can be a list of pointers.
Index allocation support access without suffering from external fragmentation. The index block is normally on
the disk block which can be read or written by itself.
Q38) What is segmentation?
Segmentation is similar to that of paging. Pages are physical in nature and are fixed size.
Whereas segments are logical divisions of program and they are of variable sizes.
Segments are logical divisions of programs and hence are normally of variable sizes. Segmentation is a
memory management scheme which support user‟s view of memory. Each segment has number and length.
Each program is executable form can be considered to be consisting of different segments such as code, data
and stack. Each of these can be further divided into new segments.
A program normally contains main program and some subprograms and few predefined and
precompiled functions. Each of these belongs to different segments. An application programmer does not
necessarily have to declares different segments in the program. If various segments in his programs does not
defines explicitly then the compiler does it by its own
Jobs of compiler :
Followings are the different jobs performed by compiler
1) Compiler recognize different segments in program.
2) Number those segments.
3) Define segment table.
4) Produce an executable image by assigning two dimensional addresses.
Consider following examples as shown in figure there are four segments numbered from 0 To3.
The SMT ( Segment Map Table ) has separate entry for each segment giving the size and base of segment.
0 Sub Program 0 0 Data area 0
Main Program Stack area
Segment 0 Segment 1 Segment 2 Segment 3
0 999 499 499 199
500
Segment # Limit Base
1000 Segment 0
0 1000 500
Oct 2003
1) Explain with flowcharts the following control structures : ( Mar 2009, Mar 2012)
a) Sequence logic b) Selection logic c) Iteration logic
2) With suitable example show a labeled diagram for link between two nodes having the information part
and next pointer field. (Mar 2006)
3) Explain the advantage of binary search algorithm with a suitable example. State any two disadvantages
or limitations of binary search. (Mar 2007)
4) With suitable example explain pointer and pointer arrays.
Mar 2004
5) What do you mean by term searching? Which are the different types of searching algorithms? Explain
the linear searching algorithm. (Oct 2004)
6) What are records? Explain how records are represented in memory using arrays.
7) Explain what is meant by linked list with suitable example and a properly labeled diagram.
Oct 2004
8) What are data structure? What are the different operations that can be performed on data structures.
9) Explain three types of control structures used for flow of control. ( Oct 2005, Oct 2011)
Mar 2005
10) In case of data structure explain the following terms : ( Oct 2007, Mar 2009)
a) Field b) Record c) File
11) With suitable example and diagram show a link list with information elements and the link field from
start to null pointer. ( Oct 2010)
12) Explain bubble sort algorithm with a suitable example.( Oct 2005, Oct 2008, Mar 2010, Mar 2011)
13) What is a record structure? How it differs from a linear array.
(Mar 2007, Mar 2008, Oct 2009, Oct 2011)
14) What is traversing an array? Give algorithm for traversing a linear array. ( Mar 2006, Oct 2012)
Oct 2005
15) Explain stack and queue with suitable examples. ( Oct 2010, Mar 2013)
Mar 2006
16) What is data structure? Write any four different operations that can be performed on data structure.
17) Draw the tree diagram which corresponds to the following algebraic expression:
E= (2X + Y ) / (5A-B)3
Oct 2006
18) Explain the following data structure with suitable diagram : (Mar 2012)
a) Linear array b) Pointer array c) Tree
19) What is linked list? How it will be represented in memory.
20) What is searching? Explain binary search algorithm with example. ( Oct 2011, Oct 2012)
21) Explain all six operations performed on a data structure. ( Oct 2009, Mar 2010, Mar 2012, Oct 2012)
Mar 2007
22) What searching? Write algorithm for linear search.
23) What is linked list? Show linked list with a suitable example having six nodes with a properly labeled
diagram. ( Mar 2008)
Oct 2007
24) What is linked list? Show representation of linked list having three nodes in a memory. (Oct 2012)
25) Write an algorithm to delete one element from a linear array.
26) Write an algorithm for linear search method with example. (Mar 2009, Oct 2010)
March 2008
27) Explain the following data structure with suitable diagram : ( Mar 2011)
a) Linear array b) Linked list c) Tree
Oct 2008
28) What is linear array data structure? Explain with suitable diagram and notations the following terms:
a) Length of an array b) Subscript variable
29) Show representation of five records with three fields in a memory as a collection of parallel arrays.
Mar 2009
30) Write an algorithm for inserting an element to a linear array. (Mar 2011)
31) What is binary tree? With suitable example show the relationship between total number of nodes and
depth of a tree. ( Oct 2003, Mar 2006)
32) What are binary tree? Draw the binary tree structure for the following expressions :
E= ( a+ b ) / ((c*d) – e) ( Mar 2004)
33) What is binary tree? Draw the binary tree structure for the following expression
E= ( p – q ) / ((r*s) + t )
34) What is binary tree? With a suitable example explain the terminology describing family relationship
between the elements of a binary tree.
35) Explain bubble sort algorithm with suitable examples. (Mar 2008, Mar 2012)
36) Define binary tree. Draw the tree structure for the following algebraic expression:
(p*((q–r) + t ) / ((q+r)*s)
37) What is binary tree? Draw the structure for the following expression :
E = ( a- b ) / ((c*d) + e )
38) What is binary tree? Show a tree structure for the expression : Z= ( A+ B / E ) * (C+D/F)
39) What is binary tree? Draw the binary tree structure for the following expression
E = ((a+b) * c) / ((a*((b-c)+a)
40) With suitable example and labeled diagram show linked representation of binary tree in memory.
( Mar 2009)
41) What is binary tree? How it is represented in memory explain with example?
42) Explain the terms siblings and leaf in case of a tree structure. Draw tree diagram for the expression
C= ( X / Y )3 – (5A+B2)
43) What is tree structure? Draw the diagram for the given expression :
A= (P+2Q)2 – (R / 3)
44) What is record? Show representation of records in memory by considering suitable example of three
records and three fields.
45) Write the binary search algorithm with suitable example.
46) What is binary tree? Draw the tree structure for the following expression
E= ( p+q) / ( r*s) - t
47) Draw binary tree structure for the following expression:
(2A+B) (5F-D)3
Mar-20 Explain bubble sort algorithm with suitable example.
Mar-20 Explain linked representation of binary tree in memory with suitable example.
Mar-20 List any six data structure operations.
Mar-20 Define Binary Tree. Draw a Tree diagram for following expression:
Y = ((a-b-c) + (a+b-c)3 / 2
Mar-20 Define Linked List. Draw and explain labeled diagram of linked list with 5 nodes.
Aug– 18 What is Traversing? Write an algorithm to traverse the linear array with example.
July –17 Define the following terms with respect to data structures :
i) Array ii) Stack iii) Queue
July –17 Explain any six data structure operations.
July –17 Draw a binary tree structure for the following expression :
F = (a – b) / ((P*m)+h)
What is an algorithm? Write an algorithm to find the roots of a quadratic equation ax2 + bx + c = 0 , where
July –17
a # 0.
Oct–14 Explain the following control structure and their types use in data structure:
i) Selection ii) Loop
Mar-14 What is Record? How it differ from an Array?
Mar-14 Distinguish between Linear and Binary Search.
Mar-14 Write an algorithm for Binary Search.
Mar-14 Define binary tree. Draw binary tree diagram for the following expression :
(a2 + 2ab + 5c ) / (a+b)
Mar-14 What is a Linked List? Explain how it is represented in memory with the help of in example.
Oct-13 What is a Binary Tree? Draw tree diagram for the expression :
B= ( 3R / 5T ) – ( R + Q3 ).
Show the representation of records in memory, considering suitable example of three records and three
Oct-13
fields.
Mar-13 Explain stack and queue with suitable example.
What is a Linked List? Show a linked list with suitable example having five nodes with a properly labeled
Mar-13
diagram.
Mar-13 Explain Binary Search algorithm with a suitable example.
Oct-12 What is Binary Tree? Draw the tree structure for the following expression:
E=(p+q)/(r*s)–t)
Oct-12 Write an algorithm for Binary Search Technique.
Oct-11 What is Binary Tree? Draw the tree structure for the following expression:
E = ( A – B ) / ((C * D ) + E )
Show the representation of records in memory considering suitable example of three records and three
Oct-11
fields
Oct-11 Write the Binary Search Algorithm with a suitable example.
Oct-11 What is record? How it differs from a Linear Array?
Mar-11 Write a Bubble Sort Algorithm with suitable example.
Oct-10 What is a Tree Structure? Draw the diagram for the given expression:
A = ( P + 2Q)2 – ( R/3)
Oct-10 What is a Record? How it differs from a linear array.
Mar-10 Explain in brief any six data structure operations.
Mar-10 Show representation of records in memory. Consider suitable example of 4 records and 3 fields.
Mar-10 Explain bubble sort algorithm with a suitable example.
Mar-10 Explain the terms siblings and leaf in case of a tree structure. Draw tree diagram for the expression:
C = ( X / Y )3 – ( 5A + B2).
Mar-10 Explain in brief any three advantages of Linked List over Array.
v) Sorting :
Arranging records in some logical order such as ascending or descending is called as
sorting.
vi) Merging :
Merging means combining the records in two different sorted files into single sorted file
is called merging.
Q4) What is linear array? How it is represented in memory?
Linear array is a datastructure which contains finite or fixed set of ordered homogenous data
elements.
e.g. Let A is linear array having five elements as like below :
100 1) The elements array are referenced by an index set are in consecutive
200 memory locations. So that A[0], A[1], A[2], A[3], A[4]. Therefore they are
300 stored in successive memory locations.
400 2) The elements of an array can be denoted by their subscript notation as like
500 A[0]=100, A[1]=200,A[2]=300,A[3]=400 and A[4]=500.
Length of array OR Size of Array :-
The number „n‟ of the elements is called as length or size of an array. In general the size
or length of the array can be obtained from the index set by the following formula :
Length or Size of array = UB – LB + 1
Where 1) UB – the largest index called as Upper Bound.
2) LB- the smallest index called as Lower Bound.
Representation of Linear Array in memory : -
1) The elements of LA are stored in consecutive memory locations.
2) The computer does not need to keeps track of the address of every element of an array. It just
requires the address of first element of an array which is denoted by Base [LA] and called as the
base address of linear array LA.
3) Using base address the computer calculates the address of any element of an array using the
following formula :
LOC ( LA[K] = Base[LA] + W (K-LB) )
Where, 1) LOC( LA[K] ) is an address of kth element of LA.
2) „W‟ is number of words per memory location for LA.
3) LB is lower bound i.e. smallest index of LA.
Memory Address Array elements are stored sequentially
1000
1001
1002
NAME OR X
START
„X‟ Null Pointer
A 9 B 4 C 1 D X
A 1) Node : -
Each element of binary tree are called as node. In diagram
there are 11 nodes. The total number
C of binary is calculated by formula :
B Total number of nodes = 2n-1 Where „n‟ is depth or height
H
of binary tree.
e.g. If binary tree have depth 5 then total number
D E F G of nodes in binary tree is 31 nodes.
2) Root :-
A node which has no parent node is called as root which is a
K first node. In diagram A is called as root.
I 3) Leaf :-
J This is also called as terminal node. The node which has
no child or children is called as leaf or terminal node. This
have degree zero.In diagram D,I, F, J,K are leaf or terminal
nodes.
4) Child :-
Those node which are subnode or child of parent node is called as child. In diagram A is root or
parent node have childrens B and C. Similarly B is parent have childrens D and E. C is parent have
childrens F,G and H etc.
5) Sibling:-
Childrens of the same parent are said to be sibling.
e.g. In diagram B and C are called siblings because they are childrens of same parent A. Similarly D
and E are called siblings because they are childrens of same parent B. Similarly F,G and H are called
siblings because they are childrens of same parent C.
6) Left Successor :- In diagram B is called as left successor of node A.
7) Right Successor :- In diagram C is right successor of node A.
8) Left Subtree :-In diagram B,D,E,I are left subtree.
9) Right Subtree :-In diagram F,G,H, J and K are right subtree.
2) Sequential Representation :-
For sequential representation only one linear
array is used. This array is generally known as
TREE.
Example of record
Suppose a college keeps a record of each students which contains following data item.
ITEM SUBITEM
________________________________________________
_____________________________________________________
Step 6 : EXIT
Q16) Explain with flowcharts the following control structures :
1) Sequence Logic 2) Selection Logic 3) Iteration Logic
1) Sequence Logic OR Sequential flow :- MODULE A
In sequence logic modules i.e. functions are executed sequentially
one after another. The sequence may be present explicitly by means
of numbered step or by the order in which modules are written.
In short in sequential logic or sequential flow modules of an MODULE B
algorithm are executed one after another.
2) Selection Logic OR Conditional flow :-
Selection logic uses number of conditions which causes
Selection of one out of several alternative modules. The structure MODULE C
which implement this type of logic is known as selection logic
OR conditional flow structure. Fig flowchart of sequence logic
Different types of selection logic or conditional flow :
There are three types of conditional flow or selection logic
i) Single Alternative :-
This has following form or syntax If NO
if condition Condition?
then [module A ]
[ end of if structure ]
If condition is satisfied i.e TRUE Yes
then module A which consists of statements
MODULE A
is executed. Otherwise module A is skipped
and next module of algorithm is executed.
Fig Single
Alternative
ii) Double Alternative
This has following form or syntax
NO
if condition If
then [module A ] Condition?
Else :
[module B ]
[End of if structure ]
MODULE B
If condition is satisfied i.e TRUE Yes
then module A which consists of true statements
is executed. Otherwise module Bis executed which MODULE A
contains false statements.
Fig Double
Alternative
iii) Multiple Alternative :-
This structure has the following form
if condition (1) then [module A1]
else if condition(2) then [module A2]
15) For a=23 and b=3 the value of c after execution of the statement c=(a/b) * (a%b) will be ----------
a) 14 b) 49 c) 21 d) 69 ( Mar 2010)
Ans : a) 14
16) ------- is not a derived data type in C++. (Oct 2010)
a) Array b) Function c) Pointer d) class
Ans : d) Class
17) -------------- is not a visibility label. ( Oct 2011)
a) Public b) Private c) Protected d) Reserved
Ans : d) Reserved
48 | P a g e
18) Out of the following C++ operators ---------- operator can be overloaded. ( Mar 2012)
a) sizeof b) : : c) ? : d) *
Ans : d) *
19) A pointer is a variable that holds ----------- of another variable. (Oct 2012)
a) Value b) Memory Address c) Datatype d) none of a,b,c
Ans b) Memory Address
20) Object oriented programming follows --------- approach in program design. ( Mar 2013)
a) Top down b) non hierarchical c) random d) bottomup
Ans d) Bottom up
Oct 2003
1) State any six features of object oriented programming. ( Mar 2007, Oct 2011)
2) State any three important features of C-string in C++.
3) What is the function of each of the following file stream classes : (Mar 2008)
a) Ifstream b) ofstream c) filebuf
4) Write any three characteristics of friend function?
Mar 2004
5) Explain use of scope resolution operator and memory management operators in C++ with examples.
6) Explain how memory address of a variable can be accessed in C++. (Oct 2004, Mar 2007, Oct 2012)
7) Explain following OOPS concepts with an example of each :
a) Inheritance b) Polymorphism c) Data Abstraction
8) What are pointers in C++? Explain the use of pointer variables for function definitions using call by
value and call by reference.(Mar 2007, Mar 2008)
9) What is classes in C++? How are member functions defined inside and outside the class. Explain with
example.
Oct 2004
10) Describe briefly the features of I/O system supported by C++ with a suitable example.
11) Explain following OOPS concept with an example of each :
a) Polymorphism b) Data abstraction c) Object
12) What is a class in C++? How are member functions defined inside and outside the class. Explain with
examples of each type. ( Mar 2008)
13) What are constructors? What are the syntax rules for writing constructors?
Mar 2005
14) State any six important features of object oriented programming.(Oct 2009)
15) Explain in short the three special characteristics of a static data member in a class.
(Oct 2007, Mar 2011)
16) What is constructor in C++? With suitable example explain how a constructor is declared and defined.
(Oct 2010)
17) Explain three types of data conversion in C++ with a suitable example.( Mar 2010)
Oct 2005
18) Explain the difference in between procedural programming approach and object oriented programming.
19) What is constructor and destructor? Give one example of each. (Mar 2006, Mar 2007, Mar 2012)
20) What is class? Give the syntax (form) of class declaration in C++.
(Mar 2008, Mar 2010, Marr 2011, Oct 2011, Mar 2013)
Mar 2006
21) Enlist the basic datatypes used in C++ with size of data in terms of bytes for each.(Oct 2009)
22) Explain with a diagram the file input and file output streams in C++. ( Mar 2009)
23) Explain following terms related to object oriented programming with example: ( Mar 2008)
a) Object b) Classes c) Polymorphism
Oct 2006
24) Write a short note on basic data types with their byte sizes.
25) Explain call by value and call by reference with one example of each.
26) Explain the concept of function overloading with one example. (Mar 2008)
27) Explain the following concepts related to object oriented programming :
a) Objects b) Classes c) Encapsulation
Oct 2007
28) Explain the general concepts of the following in C++ :
a) Objects b) Classes c) Inheritance
29) Write declaration for each of the following in C++ :
a) An array of 8 floats b) A pointer to an array of 8 doubles
c) Function that return a pointer to float
30) What is constructor and destructor? State the difference between them.( Mar 2011)
49 | P a g e
Oct 2008
31) What do you mean by object based programming languages and object oriented programming
languages? State the relationship between these languages.( Mar 2010)
32) Write a declaration for each of the following:
a) A pointer to an array of 8 floats b) A function that returns a float
c) An array of 8 pointers to float
33) List any six characteristics of constructor in C++.
34) Sate any three special characteristics of friend function.
Mar 2009
35) Define the term „object oriented programming‟. Enlist any four features of object oriented programming.
36) What is destructor? What are rules for writing the destructor fucntions.
37) Explain call by value and call by reference with one example of each. (Oct 2011)
Oct 2009.
38) What is a constructor? Explain copy constructor with example.
Oct 2003
39) Explain operator overloading with illustration. Write the advantages of operator overloading.
40) What is polymorphism? How is the same achieved at : i) Compile time ii) Run time
( Mar 2006, Mar 2010, Mar 2013)
Mar 2004
41) What are classes in C++ for file stream operation? How do you open and close files in C++. Explain
any four file modes. (Mar 2012)
42) What is operator overloading? Explain with suitable example. Why is it necessary to overload an
operator. ( Oct 2004)
Oct 2004
43) What is inheritance? Explain any three types (forms) of inheritance with suitable diagrams.
(Oct 2008, Oct 2010)
Mar 2005
44) Explain in brief with suitable diagrams the following terms used in C++ : (Mar 2009)
a) Multiple inheritance b) Hierarchical inheritance c) Multilevel inheritance d) Hybrid inheritance
45) State the details of the following file stream classes:
a) Ifstream b) ofstream
Oct 2005
46) State any eight basic rules for virtual functions that satisfy the compiler requirements.
(Mar 2007, Oct 2007)
47) Write down characteristics of virtual functions.
Mar 2006
48) What is operator function? Describe the syntax of an operator function. Explain the difference
between operator function as a member function and as a friend function.( Mar 2007, Mar2011)
Oct 2006
49) What is inheritance? Write different forms of inheritance with figure.
50) What is polymorphism? Explain compile time and runtime polymorphism.(Mar 2009)
Mar 2007
51) State any eight rules for overloading the operators in C++. ( Oct 2010, Mar 2013)
Mar 2008
52) Explain the concept of function overloading with example.
Oct 2008
53) What is an operator overloading? Explain three steps involved in the process of overloading an
operator.( Mar 2010, Oct 2011)
Oct 2009
54) Explain runtime and compile time polymorphism. Give any one type of example of each.
55) What is class? Explain inside and outside class definition with example.
50 | P a g e
H.S.C. BOARD EXAM C++ PGRAMMING QUESTION BANK
-----------------------------------------------------------------------------------------------------------------------------
Oct 2003
1) Write a C++ program that right justifies text. It should read and echo sequence of left justified lines and
print then in right justified format. ( Oct 2006, Mar 2007)
2) Implement a circle class. Each of object of this class will represents a circle, accepting its radius value as
float. Include an area( ) function which will calculate the area of circle.( Oct 2005, Mar 2008)
3) Write a function that uses pointer to search for the address of a given integer of a given array. If the
given integer is found then function returns its aaddress otherwise it returns NULL.
4) Write a C++ program to accept a number and test whether it is prime or not.
(Mar 2007, Oct 2008, Mar 2011, Mar 2012)
Mar 2004
1) Write a c++ to replace every space in an inputed string is less than 80 characters with a hyphen i.e -.
(Mar 2007, Oct 2010, Oct 2012)
2) Write a C++ program to find factorial of a natural number inputed during program execution.
(Mar 2008, Oct 2009, Oct 2012)
3) Write a C++ program to display a series of 15 terms of the Fibonacci series.
(Mar 2007, Mar 2009, Oct 2011)
4) Write the output of the following C++ program ( Oct 2007)
#include<iostream.h>
long comb(int n, int k) ;
int main( )
{
const int m = 5;
for(int i=0; i<m; i++)
{
for(int j=1; j<m;j++)
cout<<setw(2)<<” “ ;
for(int j==0; j<=I; j++)
cout<<setw(4)<<comb(i,j);
cout<<endl;
}}
long comb(int n, int k)
{
If(n<0 || k<0 || k>n)
return 0 ;
long c=1;
for(int i=1; i<=k; i++, n – –)
c=c*n / i ;
return c ;
Oct 2004
1) Write a C++ program to exchange the contents of two variables using call by reference.
2) Write a C++ program to find factorial of a natural number is inputted during program execution.
3) Write a program in C++ to read a set of numbers from keyboard and findout the largest number in the
given array.
4) Write a C++ program to find greatest common divisor (GCD) of two natural numbers. ( Mar 2006, Mar
2011)
March 2005
1) Write a C++ program that inputs and stores 10 numbers in an array and prints the sum and average of
the array elements.
2) Write a function that uses pointer to search for the address of a given integer of a given array. If the
given integer is found then function returns its address otherwise it returns NULL.
3) Write a program that right justifies the text. It should read and echo a sequence of left justified lines and
print them in right justified format. ( Mar 2006)
4) Write a C++ program to find the smallest of four given integers using min( ) function that returns the
smallest of four given integers int min (int, int, int, int ) ;
Oct 2005
1) Write a C++ program to display content of an array using pointer.
2) Write a C++ program to accept the string form the user and reverse a string.
3) Write a C++ program to find the greatest common divisor (GCD) of two numbers. Define a method find to
accept the values and calculate greatest common divisor (GCD) of two numbers and print the GCD value.
(Mar 2008)
51 | P a g e
Mar 2006
1) Implement a class temperature to covert degree Fahrenheit value to degree Celsius value.
[ hint : C/5=F-32/9] where C is temperature in degree Celsius and F is temperature in Fahrenheit
degree.
2)Write the following power ( ) function in C++ that returns x raised to the power n where n can be any
integer
double power ( double x, int p ) ;
Use the algorithm that would compute x20 by multiplying x by 20 times.
Oct 2006
1) Write a C++ to read a set of numbers form the keyboard and to find out largest number in the given
array. The number are stored in a random order.
2) Write a function that uses pointer to copy an array of double..
3) Write a function that has passed an array of n pointers to floats and returns a pointer to the maximum of
a floats.
Oct 2007
1) Write a C++ program with computetriangle( ) that returns the area a and perimeter p of a triangle with
given side lengths x, y and z. Use following function prototype in program:
Void computetriangle ( float &a, float & p, float x, float y, float z) ;
2) Write a C++ program with computecircle( ) function that returns the area a and circumference of circle c
with given radius r.
3) Write a C++ program to print the input string in a reverse order using function which first locates the end
of string then it swaps the first character with the last character then second character with second last
character and so on.
Mar 2008
1) Write a C++ program that will read a line of text and count the number of words in a text.
( Mar 2009,Mar 2012)
Oct 2008
1) Write a C++ program with computesphere( ) function that returns the volume v and the surface area s of
a sphere with a given radius r.
2) Write a C++ program to read five elements of int array in reverse order and print the array i.e. read a[5]
first and while printing print a[0] first.
3) Write a C++ program with average ( ) function that returns the average of four input numbers. Use the
following function prototype :
double ave ( double x1, double x2, double x3, double x4 ) ;
Mar 2009
1) Write an object oriented program to implement a class convert to convert degree centigrade value to
Fahrenheit degree value. [ Hint C=5/9 (F-32) ] where C is temperature in degree Celsius and F is
temperature in Fahrenheit degree.
2) Write a program in C++ that inputs 10 numbers. Stores it in a one dimensional array and print the sum
and average of all the elements of the array.
Oct 2009
1) Write a program in C++ to find sum of first 100 natural numbers.
2) Write a C++ program to input a word maximum length upto 15 characters from user and print each of its
characters on a new line in a reverse order.
3) Write a program in C++ using OOP technique to find AREA of circle.
52 | P a g e
Mar-20 Explain friend function in C++ with example.
Mar-20 What is constructor and destructor? Explain each with the help of suitable example.
Mar –17 What is Operator Function? Describe the syntax of an Operator Function.Explain the difference between
Operator Function as the Member Function and Friend Function.
Mar –17 Explain different types of inheritance with suitable diagram.
Mar –17 Explain the concept of function overloading with example.
Mar –17 Explain the use of Scope resolution Operator and Memory Management
Operators in C++ with example.
July–16 What do you mean by object based programming languages and object oriented programming languages?
State the relationship between theselanguages.
July–16 What does inheritance mean in C++? Explain in brief with example any two forms of inheritance.
What do you mean by destructor in C++? What is the importance of destructor? State the order in which it
July–16
destroys the objects.
July–16 What is friend function? State any four special characteristics of friend function.
July–16 What is operator overloading? What is an operator function? Describe the syntax of an operator function.
July–16 Explain with example the following functions used in C++ for file handling
i) open ( ) ii) close ( ) iii) get ( ) iv) put ( )
Mar– 16 State any six characteristics of constructor.
53 | P a g e
Mar– 16 What is polymorphism? Explain Compile Time and Run Time polymorphism
What is Operator Function? Explain difference between Operator Function as Member Function and as a
Mar– 16
Friend Function.
Mar– 16 Explain Local Data and Global Data or variable in C++ using example.
Mar– 16 State characteristics of Friend Function.
Mar– 16 Using examples explain how files are opened and closed in C++. State any four file modes.
Mar– 16 State three characteristics of Static Data.
Mar– 16 Explain use of Memory Management Operators in C++.
Oct–15 List the different types of data types used in C++ with example.
Oct–15 What is constructor? Give an example.
54 | P a g e
Oct–12 What is operator overloading? State any six rules for overloading the operator in C++.
Oct–12 Explain how the memory address of a variable can be accessed in C++.
Oct–12 What is constructor? What are the rules for writing the constructor.
Describe how the member function of a class can be defined outside the class definition and inside the class
Oct–12
definition.
Oct–12 What is the function of each of the following file stream classes?
i) ifstream ii) ofstream iii) filebuf iv) fstream
Mar–12 Explain Insertion and Extraction operators in C++.
Describe with an example, how member functions of a class can be defined outside the class definition and inside the
Mar–12
class definition.
Mar–12 State any six principal advantages of Object Oriented Programming.
Mar–12 Explain difference between operator function as a member function and as a friend function.
Mar–12 What is a constructor and destructor? Give one example for each.
What are classes in C++ for tile stream operation? How do you open and close file in C++? Mention any four
Mar–12
file modes.
Oct–11 Explain call by value and call by reference by giving an example for each.
Oct–11 What is operator overloading? State the three steps involved in the process of overloading an operator.
Oct–11 What is class? Give a general form of a class declaration.
Oct–11 What is inheritance? Mention the different types of inheritance with suitable Diagram.
Oct–11 What are different file mode parameters in C++?
Oct–11 Write any six features of Object Oriented Programming.
Oct–11 What are object? Describe how members of a class can be accessed using objects of that class.
Differentiate between Traditional Procedural Programming Approach and Object Oriented Programming
Mar-11
Approach.
Mar-11 What is class? Explain general form of class declaration.
Mar-11 What is Pointer? What are advantages of pointer in C++?
Mar-11 What is constructor and destructor? State difference between them.
Mar-11 Explain in brief the three special characteristics of static data member in a class.
Mar-11 What is operator function? Describe syntax of an operator function. Explain difference between operator
function as a member function and as a friend function.
Oct-10 Explain any six advantages of OOPs.
Oct-10 State any eight rules for operator overloading in C++.
Oct-10 What is constructor? With suitable example, state how a constructor is declared and defined.
Oct-10 What is friend function? State any four special characteristics of friend function.
Oct-10 What is operator overloading in C++? What is an operator function? Describe syntax of an operator function.
Oct-10 What is inheritance in C++? Explain in brief three different types of Inheritances with suitable diagrams.
What do you mean by Object Based Programming and Object Oriented Programming Languages. State
Mar-10
relationship between them.
Mar-10 Explain in short the steps involved in the process of operator overloading in C++.
Mar-10
What is a destructor? What is the importance of a destructor? State order in which it destroys the object.
Mar-10 What is class in C++? Write general form of a class declaration.
Mar-10 Explain three types of data conversions in C++ with a suitable example:
55 | P a g e
Mar-10 What is Polymorphism? How is the same achieved at :
i) Compile Time ii) Run Time
56 | P a g e
Q) What different data types in C++? Explain it detail?
The data type is requires in every variable, function, array, string, pointer declarations. The data
type name suggest that it decides the type of variable, function, array, string, pointer etc. It also decides
how much space it reserves in memory. It holds decides which data that variable, function, array, string,
pointer etc holds during the program execution.
The data type in C++ is classified into three groups
such as follows : SrNo Data type Bytes
1) Built in type OR basic data type OR primary data type. OR
i) Integral type : -It includes integer and character data. Size
They are two types such as follows : 1 signed char 1
a) int : - An int type occupies 2 bytes in memory and holds 2 unsigned char 1
integer constants i.e. whole numbers only. 3 short int 2
b) char : The char type occupies 1 byte in memory and OR
holds character data. signed int
i) Floating type :- 4 unsigned int 2
It holds floating constants or real numbers. The 5 Float 4
constants are contains decimal point numbers. They 6 Double 8
are two types such as follows: 7 long double 10
a) float : - The float type occupies 4 byte in memory and holds real constant i.e. constant have decimal
point.
b) double :- The double type occupies 8 byte in memory and holds real constants or fractional numbers.
ii) void type :- void data type is used in following ways :
a) To specify the return type of a function when it is not returning any value.
b) To indicate an empty argument list to a function.
c) To declare generic pointer.
2) Secondary data type OR Derived data type: These are derived from primary data type.
i) Array ii) Function iii) Pointer iv) String
3) User Defined data type OR Abstract type
C++ allows user to creates a new abstract data types which can behaves like any built in data type.
These are called as user defined data types. These includes structure, union, class and enumeration etc.
i) Class ii) Structure and Union and Enumeration
57 | P a g e
Q) Explain memory management operators used in C++ ?
There are two types of memory management operators is used in C++ is called as new and delete
operators.
1) new : - It is a memory management operator used to allocates a memory in memory location. It
is also used for dynamic storage allocation. This operator can be used to creates object of any
type.
Syntax : pointer variable = new data type ;
2) delete : - This operator is used for deallocation. This operator releases or free memory space in
memory.
Syntax : delete variable ;
Example :
void main ( )
{
int *a = new int ;
*a = 100 ;
cout<<”\nUsing new operator”<<*a ;
delete a ;
}
Q) What is function in C++ write a suitable example.
A self contained block of statement or collection statements in its block is called as function. The
function block is written separately i.e. defined separately from main () but before definition they are
declared at outside the main function.
Terms related to functions :
1) Function prototype : -
This a statement declared outside the main function i.e. above main ( ) from this statement function are
identified. This is also known as function declaration.
Syntax : return type functionname (type argument1, type argument2,…., type argument n) ;
In above syntax return type of function is either char/int/float/double/void etc each arguments or parameters
in function have its own data type either char/int/float/double etc.
2) Function definition :
This is a collection of statement of function. It tells that how function is implemented i.e what function is do
is defined in this block. The function definition block is defined outside main ( ).
3) Function call :
This a statement is used in main ( ) . The main ( ) function calls subfunction is given in function call
statement.
Example :
void add ( int a, int b ); // function prototype of declaration
void main ( )
{
int a=10;
int b = 20 ;
cout<<”\nEnters two numbers”;
cin>>a>>b;
add(a,b); // function call
getch() ;
}
void add ( int a, int b ) // function definition
{
int c ;
c=a+b;
cout<<”\n”<<c;
}
58 | P a g e
Q) Explain the concept of function overloading with suitable example.
More than one function name having the same name but different task is called as function
overloading. Overloading refers to the use of same thing for different purposes. It is also called as function
polymorphism or compile time polymorphism.
In this C++ compiler finds more than one function have same name thus appropriate function is
selected for execution in function call is dependent on number of arguments is given with function call, type
of argument used in functions.
Thus in functions use different data types for arguments and number of arguments are different i.e
same data type and same arguments are used in two functions then ambiguity is occurred thus no any
functions are executed.
Example
int area ( int x ) ;
int area ( int a, int b );
void main ( )
{
cout<<area ( 10 );
cout<<area ( 2 ,4 );
}
int area ( int x )
{
return (x * x ) ;
}
int area ( int a , int b )
{
return ( a+b) ;
}
In above example the function area ( ) is overloaded. When a function s called then C++ compiler
first matches the arguments given in call and its type. If match is found then appropriate function is select
for execution.
In above example both area ( ) have different argument numbers one has one argument other has
two arguments. This area ( ) have same type argument as integer but number of arguments are different so
overloading function are not ambiguity in execution. If two function have same argument type and same
number of argument then overloading function can not executes function.
59 | P a g e
Q) Explain in detail inline function? What are different situations in which compiler may ignore
inline request?
An inline function is a function that is expanded inline when it is invoked or initiated. The C++
compiler replaces function call with the corresponding function code.In inline function inline keyword is used
with function name.
Example
inline int area ( int a, int b )
{
return ( a*b ) ;
}
In above example inline keyword is used before function return type and function name.
Following are some situations in which compiler may ignore inline request :
1) For functions returning value then inline request is ignored.
2) The program contains loop statements, switch case statement or goto statements then inline
request is ignored.
3) For function not returning value i.e. if a return statement is exists then inline request is ignored.
4) If function contains static variables then inline request is ignored.
5) If function contains recursion then inline request is ignored.
60 | P a g e
Q) Explain use of pointer variables for function definitions using call by value and call by
reference.
OR Explain call by value and call by reference with one example of each.
The use of pointers in a function definition may be classified into two groups :
1) Call by value 2) Call by reference
1) Call by value :-When function is called in main ( ) then program control is transferred from the main
function to the calling function the main ( ) transfers actual values that are copied to calling function. Within
calling function i.e. sub function the actual values are changed or altered. Then when function is return from
that function to main ( ) back then the altered values or changed values in sub function can not transfers to
main ( ). This mechanism is called call by value because main ( ) calls calling function i.e. sub function by
passing its actual values.
void add ( int a, int b ) ;
void main ( )
{
int a=10 , b = 20;
add ( a,b) ; // function call with call by value i.e. it passes actual value of a and b
getch () ;
}
void add ( int a, int b )
{ a =a + 10 ; // change values of in this function as a=20
b= b + 20 ; // change value of b in this function as b= 40
cout <<”a=”<<a<<”b=”<<b;
}
Thus in above example when program control is transferred from main ( ) to calling function add ( )
then main function passes values of a and b that are copied to calling function i.e. sub function. In calling
function i.e. sub function the values are changed or altered but when it transferred back to main ( ) function
the change in sub function can not passed by sub function to main ( ).
2) Call by reference :-When function is called in main ( ) then program control is transferred from the main
function to the calling function the main ( ) transfers address of the actual arguments that are copied to
calling function. Within calling function i.e. sub function the actual values are changed or altered. Then
when function is return from that function to main ( ) back then the altered values or changed values in sub
function can transfers to main ( ). This mechanism is called call by reference because main ( ) calls calling
function i.e. sub function by passing addresses or references of actual values.
void add ( int *a, int *b ) ;
void main ( )
{
int a=10 ;
int b = 20;
add ( &a,&b) ; // function call with call by reference i.e. it passes address or reference
// of actual value of a and b
getch () ;
}
void add ( int *a, int *b )
{
61 | P a g e
Q)What is array in C++?
An array is a collection of similar type data elements which are stored in consecutive or contiguous
memory locations under common variable name. Array may be one dimensional or multidimensional.
Example : int a [ 10 ] // a is array of integer type holds 10 integer elements under common name
Generally C++ arrays are zero based. In above example the first array element has index 0 and it is
referred as a [ 0 ]. Similarly second array element is a [ 1 ] and last i.e. 10th element is a [ 9 ]. Thus first
element of array is index 0 and last element is size – 1.The subscript tells that variable is array and it have
contain size of array.
Q) What is string in c++ ? Explain various string functions in C++ with example.
The one dimensional character array is called as string in C++. The string are used to manipulates
text as such as words and sentences.
A string constant is 1D array of character terminated by null or \0.
Example : char a [ ] = { “india” } ; // where a is 1D character array is called string which holds string india.
Different string functions
The string functions in C++ are included or predefined into string.h header file. The string functions
such as strlen ( ), strcpy ( ), strcat ( ), strcmp ( ) and strrev ( ) etc. Thus to use this string functions string.h
header file is included in program.
1) strlen ( ) This a string function counts the number of characters are present in string.
2) strcpy ( ) :- This a string function copies the contents of one string i.e. source string into other string i.e.
target string.
3) strcat ( ) :- This a string function concatenates or combines the one string i.e. source string at the end of
another string i.e. target string.
4) strrev ( ) :- This a string function that reverses contents of entered string.
Example:
#include <iostream.h>
#include<conio.h>
#include<string.h>
void main ( )
{
clrscr ( ) ;
char a [80] , b[80] ;
cout<<”\nEnter string”;
cin.getline(a,80);
cout<<strlen(a) ;
cout<<strcpy(b,a) ;
cout<<strcat(a,b) ;
cout<<strrev(a) ;
cout<<strcmp(a,b) ;
getch( ) ;
}
Q) What are different features provided by c-string in C++?
The string provides following features when it is used in program.
1) A string is a sequence of characters array with null terminated character or \0 is used to stores
and
manipulates the string.
2) For each character string in C++ inserts the null character or \0 automatically.
3) Each character in an array is occupied 1 byte of memory.
4) Elements of c-strings are stored in contiguous memory or consecutive memory locations.
62 | P a g e
Q) Explain the structure of a general C++ program.
OR Explain structure of object oriented C++ programming model.
Include Files
Class Declaration
Class Function Definition
Main Function Program
Fig Structure of C++ program
A typical C++ program contains four sections such as Include files, Class declaration, Class function
definition and Main function program. These sections may be placed in different code files and then
compiled independently or jointly.
1) Include Files: Any Input/Output functions are predefined into library subroutine files in header file. The all
input/output fuctions such as cin and cout are predefined into iostream.h file. In this way console functions
such as result get without screening and clear screen etc are defined in conio.h file. In this way some real
life functions are predefined into respective header files. So to use this functions without rewriting its
definition again include header files in program.
2) Class Declaration: The class is a abstract datatype. It is begins with class keyword and same like as
basic datatype class are created abstract datatype. The class declaration contains name of class and they
have two members called as data member and member functions. The variables of class are called as data
members while functions of class are called as member function.
3) Class Function Definition: The member functions in a class are called functions of class they performed
given specific task is defined in its class function definition.
4) Main function Program : The actual execution of program is executed from here. It also executes class
and its members.
Q) What is object oriented programming? Enlist the features of object oriented programming.
Definition of OOP:
An object oriented programming is defined as
“ Object oriented programming is an approach that provides a way of modularizing programs by crating
partitioned memory area for both data and functions that can be used as templates for creating copies of
such modules on demand”.
Characteristics or Features of Object Oriented Programming:
1) Emphasis is on data rather than procedure. 2) Programs are divided into number of entities called as
objects. 3) Data structures are designed such that they characterized the objects.
4) Functions that operates on the data of an object are tied together in the data structure.
5) Data is hidden and can not be accessed by external functions. 6) Objects may communicate with each
other through functions. 7) New data and functions can be easily added wherever required.
63 | P a g e
Q) Explain the OOPS concept with an example of each.
The followings are some object oriented concepts these are used to develops object oriented programming
:
1) Class : -
i) A class is a way to binds data and its associated functions together. ii) A class is a collection of an objects
of similar type.iii) A class is an abstract data type (ADT) or user defined data type in object oriented
programming. Whose variable is object.
2) Object :-
i) An object are runtime entities which are used at run time or dynamically. ii) To combines data and
procedure a unit is formed which operates on that data. This unit is called as object. iii) When program is
executed then object passes messages between them. iv) The object is declared and defined in main ( )
function.
Example : void main ( )
{
xyz d ; // xyz is a class and d is object class is data type and object is variable
d.print ( ) ;
In above example object have dot operator which separates object name and
member function. It is called as object identity operator or membership operator. The
member functions of class only accessible by object.
3) Data Abstraction :-
i) The collection of data and functions in a class is called as data abstraction. ii) The class binds data and
associated functions together is called abstraction. iii) Abstraction refers to the act of representing essential
features without including the background details of explanations. The class are concept of abstraction.
4) Dynamic binding:-
i) The member functions are called at runtime only by an object in main function. This mechanism is called
as dynamic binding. Class binds data and functions together while object are accessed member functions
of class. ii)This technique is associated with polymorphism and inheritance.
5) Data Encapsulation :-
i) The wrapping of data and code i.e. functions into a single unit i.e. class is called as data encapsulation.
ii) Those functions are accessible which is wrapped in a class. An external function can not accesses
outside class is called data hiding.
6) Polymorphism :-
i) An ability to take more than one form is called as polymorphism. ii) They are two types compile time and
runtime. iii) The compile time polymorphism is achieved by function overloading and operator overloading.
iv) The runtime polymorphism is achieved by virtual function.
7) Inheritance :-
i) The mechanism of deriving a new class from base class is called as inheritance.
ii) They are five types single, multiple, multilevel, hierarchical and hybrid.
8) Message Passing :-
i) This is technique by which an object sends and receives messages one to another.
ii) Messages is a request for execution of procedure. iii) Object passes messages from one to another.
Q) What do you mean by object based programming and object oriented programming languages.
State relationship between them.
Object based programming language :-
It supports encapsulation and object identity without supporting important features of object oriented
programming language such as polymorphism, inheritance and message based communication.
Example : Ada is object based programming language.
Object oriented programming language :-
It incorporates all the features of object based programming along with inheritance and
polymorphism.
Example : C++ and Smalltalk are object oriented programming language.
Relationship between object based and object oriented programming language :-
The following expression tells the relationship between object based and object oriented
programming language.
1) Object based programming language = encapsulation + object identity.
2) Object oriented programming language=object based features + Inheritance +
Polymorphism
64 | P a g e
Q) What is class? Explain general form of class declaration.
Class is a way to bind data and its associated functions together. It allows the data and functions to
be hidden if necessary from external use. When defining a class a new abstract data type that can be
created that treated like any other built in data type.
Class specification or syntax of class :
Generally a class specification has two parts such as class declaration and class function definition.
1) Class Declaration: The class declaration describes the type and scope of its members.
Syntax or Form of Class Declaration:
class classname
{
visibility label: Declaration of variables
visibility label: Declaration of member functions
};
In above syntax
i) The keyword class specifies that what follows is an abstract data type class-name.
ii) The body of a class is enclosed within pair of braces (open and close) and is terminated by a semicolon.
The body of class contains declaration of class members such as:
a) Data Member of class :
The all variables declaration in class body are called as data members of class. They have its own
visibility labels either public or private or protected. The members declared as private can be accessed only
from within the class. It hides data from external use. The public data members can be accessed from
outside the class also. If visibility label are missed or not given then by default its visibility is private.
b) Member function of class :
The all functions in body of class are called as member functions of class. They have its own
visibility labels either public or private or protected. The members declared as private can be accessed only
from within the class. It hides data from external use. The public data members can be accessed from
outside the class also. If visibility label are missed or not given then by default its visibility is private.
2) Class function definition:
The class function definition describes how class functions are implemented. Class member
functions are defined outside the class definition and inside the class definition.
65 | P a g e
Q) Describe how member functions of class can be defined outside the class definition and inside
the
class definition.
Member functions of class can be defined as two ways:
1) Inside the class definition :When a function is defined inside a class is called as inside class definition. It
is treated same like inline function.
Syntax : class class name
{
visibility label : return type function name ( )
{
// body of function
}};
Example :
class addition
{
public: int a, b, c;
public : void add ( )
{
c= a + b ;
cout<<”\n Sum=”<<c ;
}
};
}
Example :
class addition
{
public: int a, b, c;
public : void add ( ) ;
};
void addition : : add ( )
{
c= a + b ;
cout<<”\n Sum=”<<c ;
}
66 | P a g e
Q) What is an object? Describe how members of a class be accessed using object of that class.
An object is a variable whose data type is class. In one class more than one object are possible to
declares. The declaration of an object is similar to that of a variable of any basic type. The necessary
memory space is allocated to an object at this stage. Each object of class are declared and defined only in
main function.
Syntax : class-name object1-name, object2-name, -------- , object-n-name ;
Accessing members of a class using objects :
Each of member functions and data members are accessed by object. For this object uses dot
operator between object name and function name. The dot operator or period connects the object name
and the member function. The dot operator is also called as class member access operator.
Example
class addition
{
public: int a, b, c;
public : void add ( ) ;
};
void addition : : add ( )
{
c= a + b ;
cout<<”\n Sum=”<<c ;
}
void main ( )
{
addition x;
x.add( ) ;
getch();
}
Where addition x statement in main function is called as addition as class name is data type
and x is object of class. The statement x.add( ) i.e. object x and dot operator separates object and
member function. Thus object accesses member function of class and object must be declared and
defined only in main function and accessed by data type class and variable object and dot operator
with object and member function accesses it s function. Thus member functions of class are
accessed by object.
The public variables of class can be accessed within main ( ). But private variables can not
accessed inside main program they can be accessed by public functions of the same class.
67 | P a g e
Q) Explain three special characteristics of a static data member and static member function in a
class.
Characteristic/properties of Static data member;-
The three special characteristics of a static data member in a class are as follows:
1) It is initialized to zero when the first object of its class is created. No other initialization is permitted.
2) Only one copy of that member is created for the entire class and is shared by all the objects of that
class, no matter how many objects are created.
3) It is visible only within the class but its life time is the entire program.
68 | P a g e
Q) What is constructor? Why it is so called?
A constructor is a special member function of a class. Its task is to initialize the objects of its class. It
is called special member because its name is same as that of the class to which it belongs. The constructor
is initiated or invoked whenever an object of its associated class is created. It is called constructor because
it constructs the values of data members of the class. A constructor can never return any value. Hence, it is
written with no return type even void is not written.
Example:
class addition
{
public : int a,b ;
public : addition ( ) ; // constructor is declared name of class = name of constructor
};
addition : : addition ( )
{
m=0 ;
n = 1;
}
void main ( )
{
addition x ; // object is created and it constructs data members
}
In above when object is created then constructor automatically initializes class data member.
Thus in above object x not only creates the object x of tyoe integer but also it initializes its data
members as m=0 and n=1.
Q) What are the syntax rules for writing constructors?
OR Write/Enlist characteristics of a constructor function.
The following are syntax rules to writing constructor these are also called as features or characteristics
of constructor function.
1) The constructor name is same as the class name.
2) They do not have return types not even void and therefore they can not return values.
3) They can not be static or virtual. 4) They should be declared only in public section.
5) They can not be inherited though a derived class can call base class constrictor.
6) Like other C++ functions they can have default arguments.n7) Constructor can not refer to its address.
8) An object with a constructor can not be used as a member of union.
9) They make implicit calls to the operator new and delete when memory allocation is required.
10) When a constructor is declared for a class then initialization of class objects become mandatory. Since
constructor is invoked automatically when the objects are created.
69 | P a g e
Q) What are different forms of constructors in C++? OR Explain different types of constructors.
C++ have various ways to defines constructor such like as follows :
1) Parameterized Constructor : Those constructors can take one or more arguments or parameters
are called as parameterized constructor.
Example : class fib
{
int f0, f1 ; // data members
public: fib( int x , int y ) // parameterized constructor with two arguments
};
2) Non Parameterized Constructor : Those constructors can not take any arguments or parameters are
called as non parameterized constructor.
Example : class fib
{
int f0, f1 ; // data members
public: fib( ) // non parameterized constructor with no arguments
};
3) Default Constructor : Those constructors can take one or more arguments or parameters with
default or constant value from right to left are called as default constructor or dynamic constructor.
Example : class fib
{
int f0, f1 ; // data members
public: fib( int x , int y=2 ) // default constructor y argument contain default value 2.
};
4) Copy constructor :-Copy constructor are always used when the compiler has to creates a temporary
object of a class object.
General form or syntax : class-name : : class-name (class-name &object-name)
Example:
fib : : fib (fib &x ) // copy constructor
{
f0 = x.fo ;
f1 = x.f1 ;
}
70 | P a g e
Q) What is destructor? Write the syntax rules of destructor?
A destructor as name implies is used to destroy or delete the objects that have been created by a
constructor. The destructor is invoked or initialized implicitly by the compiler upon exit from the program to
clean up storage that is no longer accessible.
In other word destructor is defined as “a destructor function gets executed whenever an instance of
the class i..e object of the class to which it belongs goes out of existence.
The destructor is started or begins with tilde sign ( ~) class name. e.g ~fib ( ).
Syntax rules for writing a destructor function:
1) A destructor function name is same as that of its class name. But it is preceded by a tilde sign(~) class
name e.g. ~fib ( ).
2) It is declared with no return type since it can never return any value i.e. do not use even void.
3) It takes no arguments i.e. it does not contains any arguments or parameter.
4) It is public declared and defined.
71 | P a g e
Q) What is operator function? Describe the syntax of an operator function. Explain the
difference between operator function as member function and friend function.
To define an additional task to an operator it specify what it mean in relation to the class to
which the operator is applied. This is done with the help of a special function called as operator
function which describes the task.
In other words “ A function which defines additional task to an operator or which gives a
special meaning to an operator is called as operator function.
Syntax of operator function OR general form of operator function:
return-type class-name : : operator op ( argument list )
{
// operator function body
}
Where return-type is type of value returned by the specified operation is
int/char/float/double/void etc and op is the operator such as ++/- - /+/- etc is being overloaded.
Operator functions must be either member functions i.e. non-static or friend function.
Basic difference between operator function as a friend function and as a member function
72 | P a g e
Q) Write syntax rules for overloading operators.
There are certain restrictions and limitations for overloading operators. Some of them are
listed below:
1) Only existing operators can be overloaded. New operators can not be created.
2) The overloaded operator must have atleast one operand that is user-defined data type.
3) The basic meaning of an operator can not be changed i.e. we can not redefine the plus(+)
operator to subtract one value from the another.
4) The overloaded operators follow the syntax rules of original operators.
5) Following are some operators that can not be overloaded :
Operators Operator Name
Sizeof Size of operator.
. Membership operator.
.* Pointer to member operator.
:: Scope resolution operator.
?: Conditional operator.
6) Following certain operators can not overloaded using friend functions but member functions can be
used to overload them.
Operators Operator Name
= Assignment operator.
() Function call operator.
[] Subscripting operator
Q) Enlist the operators which can not be overloaded and the operators where friend functions
can not be used.
Operators which can not be overloaded as like follows :
Operators Operator Name
Sizeof Size of operator.
. Membership operator.
.* Pointer to member operator.
:: Scope resolution operator.
?: Conditional operator.
73 | P a g e
Q) Write a short note on type conversions.
When constants and variables of different datatypes are mixed in an expression then C++ compiler
applies automatic datatype conversions to the operands as per certain rules. The type of data to the right of
an assignment operator is automatically converted to the type of variable on the left.
An assignment operator also causes the automatic type conversions.
Example:
int x; float y; y=29.13; x = y ;
In above example x=y is type conversion statement it converts y to an integer before its
value is applied to x. Thus the fractional part is truncated or removed because y is converted into
integer value. So its value is 29.
Different types of data conversion in C++ :
The C++ provides three types of data conversions called as :
1) Conversion from built in type to class type. 2) Conversion from class type to built in type.
3) Conversion from one class type to another class type.
1) Conversion from built in type to class type :
In this data conversion constructor can be used for default type conversion from argument‟s
type to the constructor‟s data type.
Example: class time
{
int hr, min;
public : time (int t) // constructor
{
hr=t / 60 ; min = t % 60 ;
}};
void main ( )
{
time z ; // z is object
int duration = 90;
z= duration ; // data conversion int to class type i.e built in type to class type.
2) Conversion from class type to built in type:
In this data conversion overloaded casting operator is used to covert a class type data to basic data type.
Syntax : operator datatypename ( )
{
// function body
}
The conversion function must satisfy the following conditions :
a) It must be a class member. b) It must not specify a return value. c) It must not have any arguments.
Example: time : : operator int ( ) // where time is class operator int ( ) operator function
{
int min ; int min1 = hr * 60 ; min1 = min1 +min; return min1;
}
void main ( )
{
time t ; // t is object class time
int m = t ; // data conversion class to basic data type.
3) Conversion from one class type to another class type :
In this data conversion uses one argument constructor or conversion function depends upon the
defining conversion routine in source class or destination class.
Example:
object a = object b
Where object a is a destination class object and object b is source class object. The
constructor is placed in the destination class and conversion function is placed in source class.
74 | P a g e
Q) What is polymorphism? Explain runtime and compile time polymorphism.
OR What does polymorphism in C++ ? How is the same achieved at :
a) Compile time b) Runtime ?
Polymorphism means one name and multiple forms i.e an ability take multiple forms is called as
Polymorphism.
Types of polymorphism :
There are two types of polymorphism such as
1) Compile time polymorphism :
In this information is known to the c++ compiler at the compile time and therefore the c++ compiler
is able to select the appropriate function for a particular call at the compiler time itself This is known as
compile time polymorphism.
Compile time polymorphism is also known as early binding or static binding. Because an object is
bound to its function at compile time.
Example: Function overloading and operator overloading are called as compile time polymorphism.
In function overloading more than one functions having same name but different task. Thus appropriate
function is selected by its type of argument, number of argument given etc. Thus in operator overloading
one operator overloads other operator.
2) Runtime polymorphism :
In this the member function is to be selected or invoked while the program is running. So this is
called as runtime polymorphism.
In this the appropriate member function can be selected at runtime and it is known as runtime
polymorphism. To achieve this C++ supports mechanism of virtual function is used.
Example : Virtual function.
In this same function name in both base and derived class the function in base class is declared as
virtual using keyword virtual. The c++ compiler determines which function to use at runtime based on the
type of object pointed to by the base pointer.
Q) Write the difference in between static binding and dynamic binding with example.
Static Binding Dynamic Binding
1) An object is bound to its function call at compile 1) Selection of the appropriate function is done
time. dynamically at runtime.
2) The compiler knows the function information i.e. 2) The function is linked with a particular class much
argument type, number of argument etc at the later after the compilation also known as late
compile time itself. So it able to select appropriate binding.
function for a particular call also called as early
binding.
3) Example : 3) Example:
Function overloading, Operator overloading Virtual function
4) class A 4) class A
{ {
int x ; int x ;
public: void show ( ) public: virtual void show ( )
{ {
cout<<”\nBase Class” ; cout<<”\nBase Class” ;
}}; }};
class B : public A class B : public A
{ {
int y ; int y ;
public : void show ( ) public : void show ( )
{ {
cout<<”\nDerived class”; cout<<”\nDerived class”;
} }; } };
75 | P a g e
Q) Explain the concept of virtual function.
When user use the same function name in both the base and derived classes then the function in
base class is declared as virtual using the keyword virtual.
When a function is made virtual then C++ compiler determines which function to use at runtime
based on the type of object pointed to by the base pointer. Thus by making the base pointer to point two
different objects it can execute different versions of the virtual function.
The virtual function can be accessed through the use of a pointer declared as a pointer to the base
class. Since the prototypes of the base class version of a virtual function and all the derived class versions
must be identical.
If two functions with the same name having different prototype then C++ compiler considers them as
overloaded functions and the virtual function mechanism is ignored.
Q) Write basic rules for virtual function that satisfy the compiler requirements.
When virtual functions are created for implementing late binding then following basic rules are
provided by C++ that satisfy compiler requirements:
1) The virtual functions must be members of base class. 2) They can not be static members.
3) They are accessed by using object pointers. 4) A virtual function can be a friend of another class.
5) A virtual in a base class must be defined even though it is not used.
6) The prototype of the base class version of virtual function and all derived class version must be identical.
If two functions have different prototype then C++ compiler considers them as overloaded functions and not
as virtual functions. 7) We can not have virtual constructors but we can have virtual destructors.
8) A base pointer can point to any type of derived object i.e. we can not use a pointer to derived class to
access an object of the base type.
9) When base pointer points to derived class then incrementation and decrementation is only relative to its
base type.
10) Virtual functions are defined in base class they need not be redefined in derived class.
76 | P a g e
Q) Explain different types of inheritances with suitable diagram.
There are five (5) type of inheritances in C++ such as follows :
1) Single Inheritance :
A derived class with only one base class is called as single inheritance.
Base class A
B
Derived Class
2) Multilevel Inheritance :
The mechanism of deriving one class from another derived class is multilevel inheritance.
Base Class A
Derived Class C
3) Multiple Inheritance :
When a class is derived from several base classes then it is called as multiple inheritance.
B1 B2 B3
D
4) Hierarchical Inheritance :
When several derived class are derived from only one base class is known as hierarchical
inheritance.
B Base Class
D1 D2 D3
Derived Classes
5) Hybrid Inheritance :
The inheritance which involves more than one inheritances is called as hybrid inheritance.
Grand Parent B
Parents A C
Child
D
77 | P a g e
Q) What is virtual base class? Why is it necessary to define virtual base classes in some cases
of hybrid inheritance?
Sometimes when hybrid inheritance is used then there are at least three levels as shown in
following figure. In figure.
Grand Parent
B
Parent A C
Child D
In figure class A and C are derived from class B and class D is derived from two parent class
i.e. class A and class C. This means that class D may contains duplicate sets of members of class B
i.e. the members of class B are inherited in class D twice via class A and via class C. This produces
ambiguity. To avoid this ambiguity concept of virtual base class is used.
Thus duplication of inherited members due to multiple paths can be avoided by making the
common base class as virtual base class while declaring the direct or intermediate base classes as
follows:
class B
{
} ; // Grand Parent Class
class A: virtual public B
{
} ; // parent1 class
class C : virtual public B
{
} ; //parent 2 class
Class D : public A, public C //child class
{
} ; // only one copy of B will be inherited.
When a class is made a virtual base class then C++ takes necessary care to see that
only one copy of that class is inherited regardless of how many inheritance path exist between the
virtual base class and the derived class.
Q) What are input and output streams?
The I/O system of C++ handles file operations which are very much similar to console input and
output operations. It uses file streams as an interface between the programs and the files. The streams that
supply data to program is known as input stream while the stream that receives data from the program is
known as output stream.
In other words input stream extract or reads data from the file and the output stream inserts or
writes data to the file. The input operation involves the creation of an input stream and linking it with the
program and the input file. Similarly the output operation involves establishing an output stream and linking
it to the program and the output file.
Input Stream
Data
Input
Read Data
78 | P a g e
Q) Describe the various classes are available for file operations.
The I/O system of C++ contains a set of classes that defines the file handling methods.
These includes ifstream, ofstream and fstream. These classes are derived from fstreambase class
the corresponding iostream.h (header fiile) as shown in following figure. These classes are designed
to manage the disk files are declared in fstream.h (header file) and therefore we must include this
file in any program that uses files.
1) filebuf( ) : - Its purpose is to set the file buffers to read and write. It contains „openport‟ constant
and used in the „open( )‟ of file stream classes. Also it contains close( ) and open () as members.
2) fstreambase ( ) : - It provides operations common to the file streams. It serves as a base for
fstream, ofstream and ifstream classes. It contains open ( ) and close ( ) functions.
3) Ifstream:- It provides input operations and contains open ( ) with default input mode. It contains
functions such as get ( ), getline ( ), read ( ), seekg ( ) and tellg ( ) et c from ifstream class.
4) ofstream : - It provides output operations and contains open ( ) with default output mode. It
inherits functions such as put ( ), seekp ( ), tellp ( ) and write ( ) functions from ostream.
5) fstream :- It provides support for simultaneous input and output operations. It contains open ( )
with default input mode. It inherits all the functions from istream and ostream classes through
istream.
Q) What are classes in C++ for file stream operations? How do you open a file using open ( )
function and close file using close ( )?
79 | P a g e
Q) What are different file modes for open a file ?
The following table lists the file mode parameters and their meanings is used with open ( ).
Parameter Meaning
1) ios : : app Appends to end-of-file.
2) ios : : ate Goto end-of-file on opening.
3) ios : : binary Binary file.
4) ios: :in Open a file for reading only.
5) ios : : nocreate Open fails if the file does not exist.
6) ios : : noreplace Open fails if the file already exist.
7) ios : : out Open file for writing only.
8) ios : :trunk Delete contents of file if it exist.
80 | P a g e
----------------------------------------------------------------------------------------------------------------------
Topic Scope in H.S.C. Board Exam : 14 Marks
1 Mark Objective=1nos.=1X1=01
3 Mark Questions=1nos=3X1=03
5 Marks HTML programming questions=2nos=5X2=10
-------------------------------------------------------------------------------------------------------------------------
What is HTML :
HTML stands for Hypertext Markup Language. HTML has its own syntax rules for communication.HTML
is not really a programming language, but it is a markup language. Generally HTML is used for creating the
web-pages. So it is a Internet Programming Language.
Using this language, programmer can creates web-page which can be viewed in any web browsers,
such as Netscape navigator or Internet Explorer. Hyper text is a ordinary text & adding extra features such
as formatting, images, multimedia & links to other documents etc. The Mark-Up is the process of taking
ordinary text & adding the extra symbols, such as editor‟s proof reading symbols are type of mark-up. Each
of the symbol used for mark-up in HTML is command that tells the browser how to display the text or page.
Thus a Mark-Up Language are special type of computer languages. They are concerned with only parts of
documents according to their functions.
HTML is invented by Tim Berners-Lee at CERN in Europe LAB. It have extension for file is .htm or
.html file.
Advantages of HTML :
There are several advantages of HTML are enlisted below :
1) For creating HTML document, only text editor is needed. No special S/W is needed.
2) HTML document can be created on any H/W platform using any text editor.
3) HTML is easy to learn, use of implement.
4) Contains powerful formatting facilities.
5) Required HTML pages can be updated easily, without changing whole document.
6) Any HTML document can be traversed due to hyper linking facility is available.
7) Independent work can be done & needed not to worry about editing program.
8) If something is not working then finding error is easy in HTML.
9) HTML will not cost anything for its use. There are no expensive licenses to buy or no upgrades
to purchase.
10) Learning HTML is very simple than any programming language.
Disadvantages of HTML :
Apart from several advantages. HTML has certain limitations as listed below:
1) HTML is not programming language in true sense.
2) Any simple calculation cannot be done in HTML.
3) It can not be used to display even date.
4) The interactive web-pages can not build by HTML.
5) The web-pages developed in HTML can not behave like an application.
6) The web-pages developed in HTML do not have their own interface.
7) Hyperlink is provided in HTML, but for that we need a trip to server at each step.
Features of HTML
The followings are some features provided by HTML
1) Hypertext Markup Language or HTML is a set of codes that is used to creates documents and then it
can be published on the world wide web.
2) HTML lets user to jump from topic rather than finding and reading information linearly.
3) Documents prepared in HTML includes reference graphic and formatting tags.
4) HTML is a hyperlink specification language.
5) HTML supports to frames including target windows and borderless frames.
6) It contains powerful formatting facilities for text, page, images etc.
81 | P a g e
Features of HTML
7) If defines the syntax and placement of special embedded directions which are not displayed by the
browser but it tells the browser how to display the contents of the documents.
8) It supports for .BMP (paint files) and .GIF(graphical image file).
9) HTML supports forms which makes it possible to creates documents that collects and process uses
input.
10) HTML tells how to makes a document interactive through special hypertext links.
Structure of HTML web page or How HTML web page is developed or Syntax of HTML
Every HTML document has the same general structure and it consists of few tags that defines the
page as a whole. The primary part of HTML document are denoted by <html>, <head> and <body> tags.
Each of these tags are known as Document Structure Tags.
HTML files are always starts with <html> tag. Similarly ended with </html> tag. It declares text
within web page viewed in a web browser.
Sections of HTML code syntax
HTML document can be divided into two sections as stated follows.
1) The head section:
It is like an introduction to the page. It generally consists of title of the page. To defines head add
<head> tag at the beginning and </head> tag at end of headings.
2) The body section :
In this user enters the text images and other tags that will actually appears on the web page.
To defines the body pace <body> tag is used at the beginning and </body> tag at the end after the
head section.
The basic structure is like below
<html>
<head>
<title> title of the document </title>
</head>
<body>
Actual code of HTML is write here.
</body>
</html>
82 | P a g e
What are Tags :
A tag is a single unit of mark-up. It is a set of symbols, defined in HTML to have a special meaning. Every
tag in HTML has a meaning and it is usually straight forward. Every tag is starts with a less than sign (
< ) followed by a keyword & conclude with greater than ( > ) sign. These symbols together known as angle
brackets. The attributes are inserted within tag that are used to affect tag‟s behaviors.
There are two types of tags in HTML :
I) Start tag : Start tag are used to begin an effect.
II) End tag : End tag are use to end that effect. Name of end tag is same as that of start tag but it is
preceded by forward slash ( / )
83 | P a g e
FORMATTING TAGS :
1) < B > tag : This tag is used for to bold text. The text appeared in the start < B > tag & end </B>
tag will displayed bold letters.
< HTML >
< BODY>
< B > This is a example of bold tag. < / B >
< / BODY >
< /HTML >
2) < I > tag : This tag is used for to italics text. The text appeared in the start < I > tag & end </ I>
tag will displayed italic letters.
Example
< HTML >
< BODY>
< I > This is a example of italic tag. < / I >
< / BODY > < /HTML >
3) < U > tag : This tag is used for to underline text. The text appeared in the start
< U > tag & end </U> tag will displayed underlined below letters.
< HTML >
< BODY>
< U > This is a example of italic tag. < / U >
< / BODY >
< /HTML >
4) < STRONG > tag : This is a strong tag. The text appeared in the start < STRONG > tag & end
< / STRONG > will displayed in bolded letters. But the main difference between < STRONG > & <
B > is that the < STRONG > tag gives grammatical supports, it also supports pronunciation‟s to the text.
e.g < HTML >
< BODY>
< P > This is a best performance grammar < STRONG > using strong tag
< / STRONG >
< /P >
< / BODY >
< /HTML >
5) < EM > tag : This is a Emphasis tag. The text appearing in start < EM > & end
< / EM > is displayed in the italic form. But the main difference between < EM > & < I > tags is that < I >
only italics the word, whereas < EM > italics the word as full supports of grammars.
e.g < HTML >
< BODY>
< P > This is a best performance grammar < EM > using EM tag
< / EM >
< /P >
< / BODY >
< /HTML >
6) < P > tag : This is a paragraph tag. A paragraph can be created by enclosing text within
paragraphs codes in start < P > tag & end < / P > tag.
Attributes used with < P > tag :
i) < P align = “left ” > aligns to the left.
ii) < P align = “right ” > aligns to the right.
iii) < P align = “center ” > aligns to the center.
e.g. < HTML >
< BODY>
< P align = “center” > This is a paragraph tag.
Using this tag the text enclosed between this is paragraphed.
< /P >
< / BODY >
< /HTML >
84 | P a g e
7) < PRE > tag : This is a pre-format tag. The text appearing in the start < PRE > & end < / PRE > is
displayed in the monospace form. Using this tag we can position the character. Generally this tag is used in
the columnar lists.
e.g <HTML>
< BODY >
< PRE > SrNO NameOfStudents RollNo Total < / PRE >
< / BODY>
< / HTML>
FONT TAGS :
1) < FONT > This is a font tag. It is used for to sets the font name, font size & font colour.
Attributes used with < FONT > tag :
i) < FONT FACE > : This used for to gives the name of font.
e.g. < FONT FACE = “ ARIAL ” >
ii) < FONT SIZE > : This is used for to gives the size of the font ranging size upto
1 to 7.
e.g. < FONT SIZE = “4” >
< FONT SIZE = “ + 4 ” > Size makes larger 4 step to current font position.
< FONT SIZE = “ – 4 ” > Size makes smaller 4 step to current font position.
iii) < FONT COLOR > This is used for to gives the color to the font.
e.g. < FONT COLOR = “ PURPLE ” >
2) < SUB > tag : This is a subscript tag. The text appeared in the start < SUB > & end < / SUB > is
displayed in the subscript form i.e. bit lower than text. It is generally used for to showing chemical formulae.
e.g. H < SUB > 2 < / SUB > O it shows H2O
3) < SUP > tag : This is a superscript tag. The text appeared in the start < SUP > & end < / SUP > is
displayed in the superscript manner i.e. bit upper than the text. It is generally used to showing the
mathematical formulae raised to the power.
e.g. 3 < SUP > 2 < / SUP > It shows 32
4) < STRIKE > tag : This is a strike tag. The text appeared in the start < STRIKE > & end
< / STRIKE > is displayed a line drawn through the middle of the text. The tag < S > is also used instead of
< STRIKE > & < / S > is used instead of < / STRIKE >.
e.g < STRIKE > This is a strike tag. < / STRIKE > is shown This is a strike tag.
5) < BIG > tag : This is a big tag. The text appeared in the start < BIG > tag & end < / BIG >
tag is displayed in the larger font. The < BIG > tag has also the same effect as < FONT SIZE = “ + 2 ” >.If
already the size is largest then this tag is ignored.
e.g < BIG > This is a effect of BIG tag < / BIG >
85 | P a g e
6) < SMALL > tag : This is a small tag. The text appeared in the start
< SMALL > tag & end < / SMALL > tag is displayed in the smaller font. The
< SMALL > tag has also the same effect as < FONT SIZE = “ - 2 ” >.If already the size is smallest then this
tag is ignored.
e.g < SMALL > This is a effect of small tag < / SMALL >
7) < MARQUEE > tag : This is a marquee tag. The text enclosed in would rolled over horizontal line
on the web-page. It is continuously rolling words till you close the application.
e.g. < MARQUEE > My marquee tag < / MARQUEE >
8) < A > tag : This is a anchor tag. It is used to creates link or hyper links. The text or images
enclosed between starting tag < A > & ending tag < / A > is a link. This link is clickable in a graphical
browser. The object to which the link has to be made is defined by the HREF attribute which refers to
hypertext reference.
e.g. < A HREF = “ c:\abc.html ” > < /A >
9) < ADDRESS > tag: This tag displays web page‟s information such as page URL ( uniform
resource locator ). The text enclosed in the < ADDRESS > < / ADDRESS > is recognized by search engines
as your address information. URL is address for a web-page. It is unique for each page.
e.g. http : //www.education.com/
In above example http is a hyper text transfer protocol & www.education.com is domain name i.e
internet name of computer that is serving the information.
e.g. < ADDRESS > HTML NOTES email : htmlnotes@hotmail.com</ADDRESS >
86 | P a g e
List tag :
1) < LI > tag : This is a list tag. Generally used for collection group of items.
e.g. <li> Sachin : It shows Sachin
<li value= “10” > Sachion : It shows 10.Sachin
Types of list tags :
There are two types of list tags used in HTML called as ordered list tag and unordered list tag.
i)unordered list tag ( < UL > ) :
This is a unordered tag. The list are displayed in bulleted form. Unordered lists can be preceded by
one of the several bullet styles like a closed circle ( ), an open circle ( ) , a square ( ). It contains the
start < UL > & </UL>.
Attributes with < UL > tag :
1) < UL TYPE = “ CIRCLE ” : it used for a hollow bullet ( ).
2) < UL TYPE = “ DISC ” : it used for a solid bullet ( )
3) < UL TYPE = “ SQUARE ” : it used for a square bullet ( )
e.g. < html>
< body >
< ul type = “ square ” >
< li > Square bullet of unordered list.
< ul type= “ disc ” >
< li > Solid circle bullet of unordered list.
< ul type = “ circle >
< li > Open circle bullet of unordered list.
</ul>
</body>
</html>
The above example shows as :
Square bullet of unordered list.
Solid circle bullet of unordered list.
o Open circle bullet of unordered list.
ii) Ordered List tag ( < OL > ) :
Ordered List are numbered in some fashion. Ordered list can be preceded by Arabic Numerals,
Uppercase or Lower Case Roman Numerals or Uppercase or Lowercase Alphanumeric characters. It
contains start < OL > & end < / OL > tag.
Attributes used with ordered list tag:
1) < OL TYPE = “ 1 ” > : It shows Arabic numbers.
Eg. < OL TYPE = “ 1” >
<LI> This is a first lie
< LI> This is a second line.
< LI > This is a third line.
</OL>
87 | P a g e
2) < OL TYPE = “ a ” > : It shows lowercase alphanumeric.
Eg. < OL TYPE = “ a” >
<LI> This is a first lie
< LI> This is a second line.
< LI > This is a third line.
</OL>
It Shows as such like follows :
a) This is a first lie
b) This is a second line.
c) This is a third line.
3) < OL TYPE = “ A ” > : It shows uppercase alphanumeric.
Eg. < OL TYPE = “ A” >
<LI> This is a first lie
< LI> This is a second line.
< LI > This is a third line.
</OL>
It Shows as such like follows :
A. This is a first lie
B. This is a second line.
C. This is a third line.
4) < OL TYPE = “ i ” > : It shows lowercase roman numbers.
Eg. < OL TYPE = “ i” >
<LI> This is a first lie
< LI> This is a second line.
< LI > This is a third line.
</OL>
It Shows as such like follows :
i. This is a first lie
ii. This is a second line.
iii. This is a third line.
5) < OL TYPE = “ I ” > : It shows uppercase roman numbers.
Eg. < OL TYPE = “ I ” >
<LI> This is a first lie
< LI> This is a second line.
< LI > This is a third line.
</OL>
It Shows as such like follows :
I. This is a first lie
II. This is a second line.
III. This is a third line.
6) < OL START = “ X ” > : X contains any starting number.
e.g < OL START = “10” > then list is ordered from 10.
88 | P a g e
iii) Definition List tag ( < DL > ) :
The definition list elements uses < DL > start tag & </DL> end tag to creates a definition list. This list is
rendered without bullets.
< DT > tag is used for definition terms i.e. name or title of the item you are defining.
The < DD > tag is used for the definition themselves.
e.g. < DL >
< DT > Term A
< DD > Definition of term A
< DT > Term B
< DD > Definition of term B
< /DL >
In above example the screen displayed
Term A
Definition of term A
Term B
Definition of term B
Heading Tag :
A web-page can have a maximum of six levels of headings.
1) < H1 > : It shows in very larger font than any other H2,H3,H4,H5 & H6.
2) < H2 > It shows in larger font than any other H3,H4,H5 & H6.
3) < H3 > It shows in larger font than any other H4,H5 & H6.
4) < H4 > It shows in larger font than any other H5 & H6.
5) < H5 > It shows in larger font than any other H6.
6) < H6 > It shows in very smaller font than any other H2,H3,H4,H5.
e.g. < H1 > This is a H1 heading tag </H2>
89 | P a g e
Adding Images in HTML :
You also inserts pictures, images, photographs in HTML documents. These can be inserted by tag <
IMG > & its many attributes.
< IMG > tag : This is a image tag. Its purpose is to include a graphic images in the body of the web page.
There are two types of images as listed below :
1) Inline Images : The inline images are aligned in top, middle and bottom. But by default it is
middle of a line of text.
2) Floating images : These are two typed aligned images as left and right. It causes text wrap
around the image.To make an image as a separate paragraphs, it is enclosed within paragraph
elements as stated below :
< P > < IMG SRC = “ C:\pic.bmp”> < / P >
90 | P a g e
Creating Hyper links in HTML documents :
The hyper link name suggested that to links one document to another documents or to one image to
another image or one address to another address etc. In HTML these links are also created by using a special
tag called anchor tag < A>.
The links are created to jumps from one document to other or image or any local or web page by
using tag <a>.
91 | P a g e
Creating tables in HTML page : Tables are created in HTML page by a < TABLE > tag.
1)< TABLE > This is a table tag. It organizes given data in a table format such as row & column
format. Table tag is created by start < TABLE > & end < / TABLE> tag.
Attributes of < TABLE > tags :
Following are attributes which uses within < TABLE > tag.
a) < TABLE WIDTH > It specifies the width of the table.
e.g. < TABLE WIDTH = “ 50 % ” > It specifies table width size is 50%.
b) < TABLE HEIGHT > It specifies the height of the table.
e.g. < TABLE WIDTH = “ 50 % ” TABLE HEIGHT= “ 12” > It specifies table width size is 50% & height
of table is 12.
c) < TABLE ALIGN = “ LEFT” > It horizontally aligns left to the specified table. It is default.
d) < TABLE ALIGN = “ RIGHT” > It horizontally aligns right to the specified table.
e) < TABLE ALIGN = “ CENTER” > It horizontally aligns center to the specified table.
f) < TABLE BORDER = “ 5” > It sets table border size is 5.
g) < TABLE BORDER = “ 1” > It sets table border size is 1.
h) < TABLE BORDER = “ 0” > It sets no border for table.
Note : By default table border is zero when not specified it considers zero.
i) < TABLE CELLSPACING = “ 12” > It creates 12 spaces between each cell.
The cell spacing is not default you specifies any space size.
j) < TABLE CELLPADDING = “ 5 ” > It increases the amount of spaces between a cell boarder & the
cell data. In example amount space is 5. It is not default size you specifies any amount of size. When
not specifies any cell space by default 1.
k) < TABLE BGCOLOR > It sets the background color to table.
2) < CAPTION > tag : This tag is used to crates a caption on the top of or below the table. It requires
start < CAPTION > tag & end < / CAPTION > tag. It is aligned with align attributes. It aligns caption left,
right, top & bottom as stated following example.
e.g < TABLE >
< CAPTION ALIGN = “ TOP ” >
It was table caption aligned top tag < /CAPTION>
< /TABLE >
3) < TR > It is a table row tag. It contains the start < TR> & end </TR> tag. It creates a horizontal row
of cells & contains table headings or table data. Each use of a table row i.e. < TR > begins a new table row.
A row must contains atleast one table data element or table heading elements. Table data is determined by <
TD > tag & table heading elements is determined by < TH > tag.
It includes attributes like ALIGN, BGCOLOR & VALIGN.
HORIZONTAL ALIGN attribute with < TR > : With < TR > tag we also uses horizontal align attributes
such as left, right, center etc. Which aligns table row left, right, center respectively.
e.g. < TR ALIGN = “ LEFT ” > It displays table row horizontally aligns to left.
< TR ALIGN = “ RIGHT” > It displays table row horizontally aligns to right.
< TR ALIGN = “ CENTER” > It displays table row horizontally aligns to center.
VERTICAL ALIGN attribute with < TR > : With < TR > tag we also uses vertical align attributes such
as top, middle, bottom, baseline, etc.
eg. < TR VALIGN = “ TOP ” > It displays table row vertically aligns to top side.
< TR VALIGN = “ MIDDLE ” > It displays table row vertically aligns to middle side.
< TR VALIGN = “ BOTTOM ” > It displays table row vertically aligns to bottom side.
< TR VALIGN = “BASELINE ” > It displays table row vertically aligns to baseline side.
92 | P a g e
COLOR attribute with < TR > : We also specifies the background color to the table row. The attribute
BGCOLOR is used with < TR > tag.
e.g. < TR BGCOLOR = “ PURPLE”> It displays purple as background color for table row.
4) < TH > tag : This is a table heading tag. It contains start tag < TH > & an end tag
< /TH >.It creates headings. By default, text enclosed in start & end tag is bolded & centered form.
Attributes used with < TH > tag:
1) Width attribute : This specifies the width of table heading.
e.g < TH WIDTH = “ 50 ” > It determines the width of table heading is 50.
2) HEIGHT attribute :This specifies the height of the table heading.
e.g < TH HEIGHT = “ 30 ” > It determines the height of table heading is 30.
3) HORIZONTAL ALIGN attribute with < TH > : With < TH > tag we also uses horizontal align
attributes such as left, right, center etc. Which aligns table row left, right, center respectively.
e.g. < TH ALIGN = “ LEFT ” > It displays table heading horizontally aligns to left.
< TH ALIGN = “ RIGHT” > It displays table heading horizontally aligns to right.
< TH ALIGN = “ CENTER” > It displays table heading horizontally aligns to center.
4) VERTICAL ALIGN attribute with < TH > : With < TH > tag we also uses vertical align
attributes such as top, middle, bottom, baseline, etc.
eg. < TH VALIGN = “ TOP ” > It displays table heading vertically aligns to top side.
< TH VALIGN = “ MIDDLE ” > It displays table heading vertically aligns to middle side.
< TH VALIGN = “ BOTTOM ” > It displays table heading vertically aligns to bottom side. < TH
VALIGN = “BASELINE ” >It displays table heading vertically aligns to baseline side.
COLOR attribute with < TH > : We also specifies the background color to the table heading. The
attribute BGCOLOR is used with < TH > tag.
e.g. < TH BGCOLOR = “ PURPLE”> It displays purple as background color for table heading.
5) < TD > tag : This is a table data tag. It contains start tag < TD > & an end tag
< /TD >.It creates individual cells. The number of cells in the row determines the number of columns. By
default, text enclosed in start & end tag is left & centered vertically.
Attributes used with < TD > tag:
1) Width attribute : This specifies the width of table data.
e.g < TD WIDTH = “ 50 ” > It determines the width of table data is 50.
2) HEIGHT attribute :This specifies the height of the table data.
e.g < TD HEIGHT = “ 30 ” > It determines the height of table data is 30.
3) HORIZONTAL ALIGN attribute with < TD > : With < TD > tag we also uses horizontal align
attributes such as left, right, center etc. Which aligns table row left, right, center respectively.
e.g. < TD ALIGN = “ LEFT ” > It displays table data horizontally aligns to left.
< TD ALIGN = “ RIGHT” > It displays table data horizontally aligns to right.
< TD ALIGN = “ CENTER” > It displays table data horizontally aligns to center.
4) VERTICAL ALIGN attribute with < TD > : With < TD > tag we also uses vertical align
attributes such as top, middle, bottom, baseline, etc.
eg. < TD VALIGN = “ TOP ” > It displays table data vertically aligns to top side.
< TD VALIGN = “ MIDDLE ” > It displays table data vertically aligns to middle side.
< TD VALIGN = “ BOTTOM ” > It displays table data vertically aligns to bottom side. < TD VALIGN
= “BASELINE ” >It displays table data vertically aligns to baseline side.
COLOR attribute with < TD > : We also specifies the background color to the table data. The attribute
BGCOLOR is used with < TD > tag.
e.g. < TD BGCOLOR = “ PURPLE”> It displays purple as background color for table data.
93 | P a g e
6) COLSPAN & ROWSPAN attributes used with < TD> & < TH :
COLSPAN & ROWSPAN are the special attributes that can be used with < TD> & <TH> tags. There may
be some situation, in which one cell of table to span more than one row or more than one column. For this
merging situations, COLSPAN & ROWSPAN attributes are used with the < TD> & < TH > tags.
COLSPAN attribute : This spans the relevant columns i.e it makes the cell contents merge to the
another cells.
e.g < TD COLSPAN = “ 2 ” > This merges the two columns in table‟s data elements.
< TH COLSPAN = “ 3 ” > This merges three columns for table heading.
ROWSPAN attribute : This spans the relevant rows i.e it makes the cell contents merge to the another
cells. It also specifies how many rows a cell should takes up.
e.g < TD ROWSPAN = “ 2 ” > This merges the two rows in table‟s data elements.
< TH ROWSPAN = “ 3 ” > This merges three rows for table heading.
94 | P a g e
Study of VB Script :
A script name suggested that it contains series of commands in its own script language tag. This
script commands are executed under the host environment or server. Scripting languages are special
programming languages. These are used on web-page to controls different elements of the page including
controls frames & browser interface. Using scripts in web-page it runs dynamically 0r actively this HTML
page is then known as DHTML i.e. dynamic hyper text markup language.
In market most scripting languages are available but most popular scripting languages are used in
creating web-page are VB Script & Java Script. VB script are writtens under the tag < SRIPT > tag.
< SCRIPT> tag : The VB Script can be placed in < SCRIPT > start tag & </SCRIPT> end tag. It
contains attributes LANGUAGE= “ VB Script “ as stated follows :
< SCRIPT LANGUAGE = “ VB Script ” >
// Scripting code
< /SCRIPT>
When browser finds the < SCRIPT> tag then it calls the VB Script interpreter to compile & executes the
given code under < SCRIPT > tag.
e.g. // VB Script displaying local time & day.
< HTML >
< HEAD >
< TITLE > Local time & day < /TITLE >
< /HEAD >
< BODY >
< SCRIPT LANGUAGE = “ VB SCRIPT ” >
DOCUMENT.WRITE Time( ) & “ on” Month Name ( Month( Now ), False)
& Day ( Now) And Year ( Now )
< /SCRIPT >
< /BODY >
< /HTML >
In above program when browser finds the < SCRIPT LANGUAGE = “ VB SCRIPT>
Tag then it calls interpreter to compile & execute code. The code of VB script is then placed to Time ( ) then
it reads the local time, month name, day & year etc. After completion of procedure Time ( ) function then
DOCUMENT.WRITE which writes the desired result.
95 | P a g e
RGB codes or Color codes in HTML with RGB color coding system
Colors in HTML can be specified by color name or by color code known as RGB code. In RGB code
R stands for red, G stands for green and B stands for Blue.
There are 16 color names in HTML such as black, silver, gray, white, maroon, red, purple, fuchsia,
green, lime, olive, yellow, navy blue, teal and aqua.
RGB codes are always 6 numbers. First two numbers specify amount of red color. Next two numbers
are specifies amount of green and last two numbers are specifies amount of blue color. By mixing these
three primary colors in different amount it is possible to derives any color. RGB code uses hexadecimal
numbering system.
Examples RGB codes
1) #FF0000 This is a RGB code for red color.
2) #0000FF This is a RGB code for blue color.
3) #00FF00 This is a RGB code for green color.
96 | P a g e
H.S.C. Board Question Bank Objectives of HTML
1) To place the image into an HTML file ------ attribute is used in IMG tag.
a) <url> b) <alt> c) <src> d) <href> (Oct 2003,Mar2006,Mar2007,Mar2011)
Ans c) <src>
2) VBScript can be executed in ---- web browser. (Mar2004)
a) Netscape navigator b) Internet Explorer c) Both d) none of these
Ans c) both
3) HTML stands for ----- (Oct2004, Oct 2005,Mar2013)
a) Hypertext Markup Language b) Hightext Manipulation Language
c) Hypertext Manipulating Language d) Hightext Markup Language
Ans a) Hypertext Markup Language
4) The long form of SGML is ---------- (Mar2005)
a) Standard Global Machine Language b) Special Global Markup Language
c) Symbolic Generalized Machine Language d) Standard Generalized Markup Language
Ans d) Standard Generalized Markup Language
5) ------ is name of the web browser. (Oct2006)
a) Embedded system b) Netscape navigator c) Oracle d) C++
Ans b) Netscape navigator
6) COLSPAN attribute is used with ----- tag. (Oct2007)
a) <body> b) <html> c) <title> d) <table>
Ans d) <table>
7) <A> tag has attribute ------ which defines URL of the document to be linked. (Mar 2008)
a) SRC b) HREF c) VREF d) REF
Ans b) HREF
8) In HTML ------ attribute defines the name of the file in which the image is to be found. (Oct2008)
a) ALIGN b) SIZE c) SRC d) BGCOLOR
Ans c) SRC
9) ------- tag is used to scroll the text. (Mar2009)
a) <STRIKE> b) <MARQUEE> c) <HR> d) none of these
Ans b) <MARQUEE>
10) In HTML -------- tag is used for super script. (Oct 2002,Oct 2009)
a) <S> b) <Super> c) <sup> d) <script>
Ans c) <sup>
11) ALIGN is not an attribute used with ---------- <tag> (Mar 2010)
a) <body> b) <hr> c) <tr> d) <table>
Ans a) <body>
12) -------- is a tag in HTML. (Oct2010)
a) ALT b) SRC c) IMG d) ALIGN
Ans c) IMG
13) ---------- tag is used for subscript in HTML code. (Oct2011)
a) <sup> b) <subscript> c) <sub> d) <super>
Ans c) <sub>
14) --------- tag is used to put a horizontal ruler in HTML code. (Mar2012)
a) <HR> b) <BR> c) <P> d) <TD>
Ans. a) <HR>
15) For green color RGB code is ----------- (Oct2012)
a) #FF0000 b) #0000FF c) #00FF00 d) #00FFFF
Ans. c) #00FF00
16) The longform of HREF is ----------- (Mar2002)
a) Horizontal reference b) Hypertext reference c) Hyperlink reference d) Hypermedia reference
Ans. b) Hypertext reference
17) ---------- tag is used to put a line break in HTML code. (Mar2003)
a) <HR> b) <BR> c) <P> d) <TT>
Ans b) <BR>
97 | P a g e
H.S.C. Board Question Bank of HTML
3 Marks Questions in H.S.C. BOARD Exam of HTML
---------------------------------------------------------------------------------------------------------------------------------
1) What is HTML? State the advantages and disadvantages of HTML.
(Oct2003,Mar2006,Mar2009,Oct2009)
2) Explain the following HTML tags with one example of each :
a) <PRE> b) <MARQUEE> c) <SUB> (Mar2004)
3) Explain the following HTML tags with one example of each :
a) <BR> b) <HREF> c) <SUB> (Oct2004)
4) Explain the following HTML tags with one example of each :
a) <OL> b) <TR> c) <B> (Mar2005)
5) Explain the following HTML tags with one example of each :
a) <SUB> b) <P> c) <BODY> (Oct2005)
6) Explain the following HTML tags with one example of each :
a) <HR> b) <UL> c) <PRE> (Oct2006)
7) Explain the following HTML tags with one example of each :
a) <P> b) <LI> c) <PRE> (Mar2007)
8) Explain the following HTML tags with one example of each :
a) <SUB> b) <U> c) <LI> (Oct2007)
9) Explain the following HTML tags with one example of each :
a) <MARQUEE> b) <SUB> c) <BODY> (Mar2008)
10) Explain the attributes BGCOLOR and BACKGROUND of <BODY> tag. (Oct2008)
11) Explain use of the following attributes of <IMG> tag with suitable examples:
a) ALT b) HEIGHT c) SRC (Mar2010)
12) Explain the following HTML tags with one example of each :
a) <SMALL> b) <BIG> c) <SUP> (Oct2010)
13) Explain the following HTML tags with one example of each :
a) <P> b) <BR> c) <HR> (Mar2011)
14) Give structure of HTML web page. (Oct2011)
15) Explain the following HTML tags with one example of each :
a) <PRE> b) <BR> c) <SUB> (Mar2012)
16) Explain the following HTML tags with one example of each :
a) <HEAD> b) <TITLE> c) <BODY> (Oct2012)
17) Explain the following HTML tags with one example of each :
a) <I> b) <LI> c) <TH> (Mar2013)
98 | P a g e
H.S.C. Board Question Bank of HTML programming
5 Marks Questions in H.S.C. BOARD Exam of HTML
---------------------------------------------------------------------------------------------------------------------------------
1) Write the exact output of the following HTML code
with font specifications in brackets. (Oct2003) 6) 6) Write HTML code for displaying a web page
<html> containing a six celled table as shown below
<title> Introduction</title> (Oct2004)
<body> Sachin Sachin Sachin
<h1><b>COMPUTER SCIENCE </b> </h1>
<hr>
First Second Third
<u> SCHAUM‟S SERIES </u>
<hr> 7) 7) Write the exact output of the following HTML
<u> SCHAUM‟S OUTLINE SERIES </u> code with font specifications in brackets :
<hr> (Mar2005)
<h5>SEYMOUR LIPSCHUTZ</h5> <html>
</body> <body>
</html> <h1 align=”center”>LIST OF TOPICS </h1>
2) Write the HTML code for the following <hr>
(Oct2003) <ol>
<li> <p align = “left” > Operating System </p>
SCIENCE
<li> <p align = “left” >Data Structure </p>
F..Y.B.Sc. S.Y.B.Sc. T.Y.B.Sc.
<li> <p align = “left” >C++ Programming </p>
300 100 25 <li> <p align = “left” > HTML </p>
ARTS </ol>
F..Y.B.A. S.Y.B.A. T.Y.B.A. <hr noshade>
200 150 40 <ol>
COMMERCE <li> <p align =”center”> COMPUTER SCIENCE
F..Y.Bcom S.Y.B.Com T.Y.B.Com. </p>
300 70 50 </ol>
3) Write the HTML code for the following table : <hr>
(Mar2004) </body>
Year </html>
1999 2000 2001 8) 8) Write HTML code for the following (Mar 2005)
Sales Units 300 750 1200 COMPUTER PAPER -I PAPER-II TOTAL
Income Rs. 3000 Rs. 7500 Rs. 12000 SCIENCE
100 100 200
4) Write a HTML code using VB Script for designing a
Web-Page which greets “Good Morning” if time is 9)
from 12:00 am upto 12:00pm else it greets “Good 9) Write an exact output of the following HTML
Afternoon”. (Mar 2004) code with font specifications in brackets (Oct2005)
5) Write the exact output for the following codes <html>
specifying RGB colours and output specifications in <h1> <center> HSC SYLLABUS </center> </h1>
brackets. (Oct2004) <h3> PAPER I </h3>
<html> To know more about
<had> <p> Just clock on here
<title> computer shop </title> <address>
</head> <b> Data Structure </b>
<body> <b> GUI </b>
<h3> <b> Title : XYZ Computers Ltd. </b> </h3> <b> HTML </b>
<p> Address : Shakti Complex, Aurangabad </p> <b> C++ </b>
<h1> <i> Dealers in: all types of peripherals </i> <b> VB </b>
</h1> </address>
</body> </html> </body>
</html>
99 | P a g e
10) Write HTML code for web page displaying the 15) Write the exact output of the following HTML
following table : (Oct2005) code with font specifications in brackets : (Mar2007)
Weather Forecast <html> (Mar2002)
Wind From To <body>
City speed <h1> LIST OF BOOKS </h1> <hr>
Mumbai 39 South West <ul type=”circle”>
Raigad 47 South West <li>C++ Programming
Panaji 42 East South <li>HTML in Easy Steps
<li>How to solve it By computer
Speed in Km/hr. </ul>
11) Write the HTML code for the following: <ol type=”A”>
(Mar2006) <li> Microprocessor Programming
Faculty <li> Networking Essentials
Arts Science Commerce <li> Microcontrollers
</ol>
Students Boys 100 400 500
</body> </html>
Girls 300 300 400
16) Write the HTML code for the following table
12) Write the exact output of the following HTML (Mar 2007)
code with font specification in brackets: (Mar 2006)
<html> SCIENCE
<title>Introduction</title> F..Y.B.Sc. S.Y.B.Sc. T.Y.B.Sc.
<body> 800 600 200
<h1> <b> Computer Science</b> </h1> ARTS
<hr> <u> E Balguru Samy </u> F..Y.B.A. S.Y.B.A. T.Y.B.A.
<hr> <h4> Achyut S Godbole </h4> 500 400 200
</body> COMMERCE
</html> F..Y.Bcom S.Y.B.Com T.Y.B.Com.
13) Write a HTML code for the following: 200 150 100
Government of Maharashtra <–Text size in h2 17) Write HTML code for the following (Oct2007)
Subjects
Education
1. English (compulsory)
2. Second Languages
PWD ADMN
o Physics
for details Chemistry
feel free to approach us Maths
PWD is a link available where checking on PWD a Biology
webpage file „Mahapwd.html‟ should be invoked. On 18) Write the exact output of following HTML code
clicking ADMN a webpage file „admn.html‟ should <html>
be invoked. On clicking for details the user can write <head>
e-mail to mail-address „free_free@hscboard.com‟. <title> </title>
On clicking feel free to approach us, user can invoke </head>
to website „www.maharashtra.gov.in‟.(Oct2006) <body>
14) Write the exact output of the following HTML <table border=”2” width=”50%”>
code with font specification in brackets <tr>
<html> <td width=”100%” colspan=”2”>
<title> Examination </title> <h1 align=”center”> HSC Board Exams</h1>
<body> </td>
<h1> <b> First Semester Exam </b> </h1> </tr>
<hr> <tr>
<u>MATHEMATICS</u> <td width=”50%” align=”center”>
<hr> <u>Paper I </u> </td>
<u>STATISTICS</u> <td width=”50%” align=”center”>
<hr> <u> Paper II </u> </td> </tr>
<u>BIOLOGY</u> <tr>
<hr> <td width=”50%”>
<h5>MSEC BOARD </h5> <p align=”center”>
</body> </html> <i>50 Marks </i> </td>
100 | P a g e
<td width=”50%” align=”center”> 23) Write HTML code for displaying following table
<i>50 Marks </i> </td> on the web page : ( Mar 2009 )
</tr> S.N. Student Marks Obtained Total
</table> Name Test-1 Test-2 Test-3
</body> 1 ABC 150 150 125 425
</html> (Oct2007) 2 LMN 129 130 131 390
19) Write the exact output of the following HTML 3 XYZ 115 125 120 360
code with font specifications in brackets:
<html> 24) Write HTML code for the following output
<title> INTRODUCTION</title> (Mar2009)
>body> ART
<h1> <b> PCMBEC </b> </h1> o MARATHI
<hr> o HINDI
<u> NOBAL‟S SERIES </u> o ENGLISH
<h5>WELLKNOWN </h5> COMMERCE
</body> o ACCOUNT
</html> (Mar 2008 ) o COSTING
20) Write HTML code for the following: (Mar2008) o AUDITING
Year SCIENCE
2000 2001 2002 o PHYSICS
Sales Units 500 1000 1500 o CHEMISTRY
Income Rs. 5000 Rs. 10000 Rs. 15000 o MATHS
o COMPUTER SC.
21) Write the exact output of the following HTML 25) Write the HTML code for the following table
code ( Oct 2008 ) (Oct 2009)
<html> Yuvraj 138*
<head> Ind 387 Sehwag 83
<title> </title> Peterson 58
</head> Eng 238 Bopara 49
<body> IND wins Ist ODI by 149
<h1> Languages </h1>
<ol> 26) Write the HTML code for the following table
<li> English (Oct2009)
<li> Second Languages Students
</ol> Year Boys Girls Total
<ul> 2006 55 75 130
<li> Marathi 2007 75 95 170
<ul> Record
<li> Hindi
<ul> 27) Write the exact output of the following HTML
<li> French code with font specifications in brackets (Mar2010)
</ul> <html>
<li> Sanskrit</li> <body>
</ul> <h1> <u> Network Connectivity Devices </u> </h1>
</body> <ul>
</html> <li> Modem
22) Write HTML code for the following (Oct2008) <li> Hub
<ul>
<li> Repeater
HSC Board Exams
<li> Router
</ul>
Computer 1. Paper I </ul>
2. Paper II </body>
Science </html>
200 Marks
101 | P a g e
28) Write HTML code for the following: (Mar 2010) 33) Write the HTML code for the following
No. Books Purchased (Oct2011)
F.Y.J.C. S.Y.J.C. V.I.P. SALES
2004 1200 1300 ERASER 5
Year
2005 1250 1400 PENCIL 7
29) Write exact output of the following HTML code STATIONARY
PEN 10
with font specifications in brackets (Oct2010) BOOK 22
<html>
TOTAL 44
<body>
<h1>Terms used in Networking </h1> 34) Write HTML code to display the following
<hr> nested list : (Oct 2011)
<ul type=”circle”> College
<li> Bandwidth I. Arts
<li> Attenuation a. History
<li> Electromagnetic Interference b. Politics
</ul> c. Languages
<ol type=”a”> i. English
<li> Topology ii. Marathi
<li> Ethernet II. Science
<li> Protocol a. Physics
</ol> b. Chemistry
</body> c. Biology
</html> III. Commerce
30) Write HTML code for the following : Accounts
XII RESULT <––Text size h1 35) Write exact output of the following HTML code
with font specifications in bracket ((Mar2012)
STREAM <html>
<head>
<title> Computer Step </title>
SCIENCE COMMERCE ART
</head>
SCIENCE is a link available where clicking on <body>
SCIENCE a web page file “SCIENCE.html” should <h2> <u> Title : Megastar Company Ltd. </u> </h2>
be invoked, on clicking COMMERCE a web page <p> Address : Surya Complex, Delhi </p>
file “COMMERCE.html” should be invoked and on <h4> <b> Deals In : </b> </h4>
clicking ART a web page file “ART.html” should be <ul>
invoked. (Oct 2010) <li> Software
31) Write a HTML code for the following output : <li> Hardware
(Mar2011) <li> Peripherals
COMPUTER DEVICES <–– Text size h2 </ul>
align center </body>
INPUT DEVICES </html>
1. Keyboard 36) Write a HTML code for the following (Mar2012)
2. Mouse
Roll No Name Marks Total
STORAGE DEVICES
CS1 CS2
1. Hard Disk
1 RINA 75 70 145
2. Floppy Disk
3. Compact Disk 2 RONAK 80 90 170
3 TINA 70 85 155
OUTPUT DEVICES
1. Screen 37) Write HTML code for a web page displaying of
2. Printer the following table : (Oct2012)
Year
32) Write a HTML code for following (Mar2011)
2007 2008 2009
COMPUTER PAPER -I PAPER-II TOTAL Sales Units 1500 400 1200
SCIENCE Income 1000 900 3000
100 100 200
102 | P a g e
38) Write a HTML code to display the following 40) Write HTML code for following: (Mar2013)
output (Oct 2012)
List of Books <–– Text size h1, default font is used HTML COLOUR CODE
o How to solve it By computer IN HEXA-DECIMAL
o HTML in Easy steps
o C++ Programming BLACK WHITE
A. Microprocessor Programming
B. Networking Essentials
C. Microcontrollers #000000 #FFFFFF
39) Write exact output of the following HTML code
with font specifications in brackets (Mar2013)
<html>
<body>
H1 align=”center”> H.S.C. BOARD EXAM </h1>
<p align=center”>
<i> SUBJECT : COMPUTER SCIENCE <i> </P>
<p align=center”>
<b> THEORY AND PRACTICAL EXAMS
</b> </p>
<p align=center”>
<u> TOTAL </u> ____200 MARKS </P>
</body>
</html>
Q) Which are different tags in HTML they do not have contains ending tags?
The HTML tag do not have contains ending tags as like follows:
1) < li >
2) < br >
3) < small >
4) < big >
5) < h1 > , < h2 > , ------- , < h6 >
103 | P a g e