Screenshot 2024-03-09 at 8.28.06 PM

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 78

SUBJECT : C.

S 1

CHAPTER 1 : Operating System

Q 1)What is o.s? Explain services of o.s.?

Ans.->

An operating system is an interface between user of computer and computer hardware.


The primary goal of an o.s. is to make the computer system convenient to use.

Services:

1) Information management : It refers to a set of services for storing ,retrieving ,modifying or


removing the information on various devices.
It includes- Crete a file, create a directory, open a file, close a file etc.

2) Process Management : O.S. has to keep track of all running programs called as process. O.s
has to schedule all processes and will have to dispatch them.

It includes-Ready a process, Block a process, Resume a process, Suspend a process etc.

3) Memory Management : It keeps track of memory and allocating/deallocating it to various


processes .It keeps a list of free memory locations.

It includes-Allocate a chunk of memory and deallocate a chunk a memory.

Q 2) What are the features of Windows 98

Ans->

 Single user multitasking system.

 Installation of new hardware is very easy.

 We can open a file by single click.

 Windows and programs open faster.

 Using www is easier

 The conferences on internet can be arranged.


 It supports DVD and digital audio.

 We can play high quality digital movies.

 Television broadcast is also possible.

 To use of multiple monitors with a single computer.

Q 3) Explain features of windows NT

Ans -> 1) Multiuser , Multitasking, Multithreading O.S.

2) 32 bit O.S

3)It has virtual memory management.

4) Portable O.S.

5) support modular design

6)support all the features of modern o.s.

Q4) Explain features of Linux

Ans -> 1) multiuser, multitasking o.s.

2) Full set of UNIX compatible tools.

3)runs on wide variety of platforms.

4)Provides standard interface to both the programmer and user.

5)Support wide base of application.

6)Free software

7)Obeys all UNIX semantics.

8) Pages are loaded on demand whey they are referenced.

Q 4) Explain Program manager, File Manager , Control Panel

Ans-> Program Manager :

1) To start and stop application

2) Organize various applications into different groups.


3) To end MS-Windows section

File Manager :

1) Help to organize user files and directories.

2) Used to traverse through the file system and to change directories.

3) Search, copy, move, create, delete files and directories.

4) Application can be started directly from the file manager by clicking on an application
icon.

Control Panel :

1) Used to select and display the background of the screen

2) Add or remove a fonts.

3) Used to configure a printers .

Q 5) What is GUI ? Explain with advantages.

Ans- >The interfaces which replaces cryptic commands by their graphical representation are called
as ‘ Graphical User Interface’.

Advantages/ features :

1) Easy to use

2) User can communicate and exchange data between programs without transferring or copying
files.

3) User can run several programs simultaneously.

4) Commands are replaced by graphics.

Q 6) What are the components of GUI ?

Ans->

1. Menu bar

2. Scroll bar

3. Dialogue boxes

4. Option buttons, check box, list box. combo box


5. Feedback pointer

Q7) What is file system? Explain difference between Taped based n File based System?

Ans-> The collection of inter related information called as file. There are two types of file system.

Taped based Disk Based

1) Simple inefficient

2) Files are stored on reels of physical tapes files are stored on track and sectors

3) Finding any file is difficult and

time consuming

4) Less info can b stored

5) Rewriting is not possible.

6) Modification can not b done without

copying entire disk

Q8) Explain the operation related to Information management with file ?

Ans->

 Create a file – First whether to check sufficient memory is available or not .If available then
create a file.

 Write to a file- Search for a particular file. If available then only open n write.

 Reading a file- Search for a particular file if available then only open for reading

 Delete a file-Search for a particular file if found then delete n release memory space

 Rewind a file- Search for a particular file if found then file is reset to beginning of file.

Q9) What is VDU? Explain the following terms: Dumb Terminal and Intelligent Terminal

Ans-> answer is in definition paper


Q10) What is process scheduling? Explain scheduling objectives?

Ans-> O.s has to keep track of all processes and will have to dispatch them one after the
another.This is known as process scheduling.

Some of the objectives :

1) Fairness

2) Good throughput

3) CPU utilization

4) Turn around time

5) Waiting time

6) Response time.

Q 11) What is Priority? Explain Types of Priority?

Ans->The concept of arranging ready processes in a queue so that they can dispatched one after the
another on some policy or criteria a known as priority.

A priority may be external , internal or purchased.

External Priority : 1) It is specified by the user externally generally at the time of initiating the
process.

2) The o.s allows user to change its priority externally .

3) If the user does not specify any external priority at all, the o.s work with default priority.

4) but when an urgent job needs to be done, the system admin permits the process to be created
with a higher priority.

Internal priority : 1) The o.s can set their own internal priority which is highest for shortest job.

2)It is done by scheduling algorithms.

3)they base their calculation on the current state of the process.

4)because of this, the number of processes competing for cpu will be decreased. and number of
satisfied users will increase.

Purchase priority: 1) It used in some data centre. Where each user pays for the time used.

2) Higher priority processes are changed at a higher rate to prevent each user from firing his job at
the highest priority.
Q12)What is Process? Explain states of Process ?

Ans ->Process is a program under execution , which competes for the CPU time .

Process States :

1) Running : CPU can execute only one process at any time .

2) Ready : A process which is not waiting for any external event such as an I/O operation and
which is not running is said to be in ready state.

3) Blocked : When process is waiting for an external event such as an I/O operation the process
is said to be in blocked state.

Q 13 ) Explain Context Switching with example?

Ans -> answer is in definition paper

Q14) State functions of MM also write any four memory management system?

Ans-> functions:

1) To keep track of memory locations free or allocated.

2) To decide memory management policy

3) To use various algorithms to allocate n deallocate memory.

MM systems :

 Contiguous, real MM system:

 Single

 Fixed partition

 Variable partition

 Non-contiguous , Real MM system:

 Paging

 Segmentation

 Combined
 Non-Contiguous ,virtual MM system

 Virtual Memory

Q15) What is Paging? Explain in detail?

Ans ->1) Partitions suffer from External fragmentation caz of available memory is not contiguous.

2) Paging allows a programs memory to be non-contiguous allowing a program to be allocated


physical memory whenever it is available.

3)Physical memory divided into fixed size blocks called Page Frames.

4) Logical memory divided into fixed size blocks called Pages.

5) Now, When a program is to be executed its pages are loaded into any available frames and
according to that Page map table defined.

6)The page size is defined by hardware. And it is typically power of 2.

7) every address generated by CPU is divided into 2 parts : Page number and Page offset.

8) page number is used as an index into a PMT.

Q 16) what is segmentation?Explain.

Ans-> 1) Segments are logical division of programs and hence are normally of variable size.

2) each segment has number and length.

3) Each program is executed form can be considered to be consisting of different segments such as
code, data and stack.

4)Each of these can be further divided into new segments.


5)An application programmer does not necessarily have to declare different segments in the
program.

6) if various segments in his programs does not define explicitly, then the does it by its own.

7)the segment table has a separate entry for each segment, giving beginning address of segment in
physical memory and length of that segment.

Q 17) What is security ? Explain elements of Security?

Ans-> answer is in definition paper( Confidentiality, Integrity, availability)

Q 18 ) What are the different ways in which system can be attack ?

Ans ->The security system can be attacked in number of ways –

 Authentication : Guessing or stealing somebody else’s password, Finding password by trial


and error method , Wring dummy log in program to fool user, if user already log in and goes
somewhere access confidential info.

 Trap door : Software developer leave some entry point to modify the programs.

 Browsing : One can browse through system file to get t info, after which ,unprotected files
could b easily accessed.

 Invalid parameters: passing invalid parameters may cause a serious security problem
 Line trapping :A special terminal is used to tap into a communication line.

 Electrical Data Capture : Use of active wire taps to pick up the screen radiation.

 Waste recovery : By using some technique, deleted files can be recovered. Password may be
recollected.

 Rough software : virus can attack on system.

Q 19) What is the difference between computer virus and Worms.

Ans-> Virus worms

 Defination

 Not a complete program complete program

 Can not act independently can act independently

 It direct harm to computer system do not direct harm to computer system

 Corrupt the code and data goes on spreading on network

Q 20) What are the different methods by which virus can infect other program?

Ans->

1) Append – The virus code appends itself to unaffected program.

2) Replace- The viral code replaces the original executable program completely.

3) Insert- Viral code is inserted in body of an executable code.

4) Delete – Viral code deletes some code from executable code.

5) Redirect – Normal control low of program is changed to execute some other code.

Q 21) What is virus detection, removal and prevention .

Ans->

Virus Detection-

 Program maintain checksum of each file.

 A mismatch in it indicate virus.

 Checks the integrity of binary files


Virus removal-

 It scans the disk for the patterns of known viruses

 But if virus has already damaged data, then recovery of data is not possible.

 Virus removal program is very difficult to imagine due to the multiplicity of


viruses.

Virus prevention-

 User can not recover data after viral affection so the best way to prevent viruses.

 User must buy official, legal copies of software

 Careful about when using free, unreliable or illegal software

 Frequently take back up of programs or data.


Subject : C.S-1
Chapter 1:Data Structure

Q1 ) What is Data Structure? Explain with its type?


Ans. 1) Defination : The way in which different data elements are organize in computer
memory.It should be simple.
2)There are basically two types of data structure : Linear and Non Linear
3)Linear data structure : The data elements are stored in consecutive/ Sequential
memory Location.
Eg. Array , Linked List
4)Non Linear data structure : The data elements are stored in random memory location.
Linear order cannot be maintained.
Eg. Tree , Graph

Q2) Define the following terms


Ans. 1 ) Data : Single value / set of values
Eg . abc, I am a girl.
2)Group item :The data items which are divided into subitems called as Group item.
Eg. Date –DD MM YY
Name- First name , Middle name, Last name
3)Elementary item : The data items which are not divided into subitems called as
Elementary Items.
Eg. Pincode
4)Entity : An entity is something which has certain attributes and associated values.
5) Field : It is a single elementary unit of information
6)Record : It is a collection of inter-related field.
7)File : It is a collection of inter-related record.

Sr.no Name Marks address


Field
1 Sonu 50 Virar
2 Raju 70 Vasai
3 Meena 65 Malad Record

Q3)Explain any 6 Data Structure Operation


Ans. There are basically 6 data structure operations
1)Traversing – Accessing each record at only once
2)Inserting – Insert new record to the existing structure
3)Deleting/removing – Delete a record from the existing structure
4)Searching – Search the record either by giving memory location or by giving actual
data
5)Sorting – Arrange the data alphabetically or numerically
6)Merging- Combining two or more different sorted files into single sorted file.

Q4 ) Explain in brief control structure.


Ans. We have basic 3 control Structures
Sequetial Logic : In this, modules are executed one after the another.( modules i.e. single
statement or set of statements in a block)

Selection Logic: Here we uses number of conditions which, cause selection of one out of
several alternatives.
There are three types of selection control structure.
a) Single alternative : here we will check the condition , if condition is true execute module
A ,otherwise skip that part and go ahead
b)Double Alternative: here we will check the condition , if condition is true execute module
A otherwise execute module B.

c)Multiple Alternative :it allows only one module to be executed. The module following the
condition ,which is satisfied the condition will be executed . if no condition is satisfied then
the module which follows last else statement will be executed.

Iteration Logic: Here certain module is executed repeatedly until condition satisfies.
i.e. whenever we want to perform same action/ logic repeatedly.it uses either repeat for,while
or do while.

Repeat for Repeat while Repeat do while


Q5 ) Explain Linear Array in detail
Ans. 1) Defination – It is a set of finite number of homogeneous data stored in a sequential
memory location with a starting same name for all elements.
2) Syntax : data type array_name[size];
3)Eg. int a[100];
Here, we declared array ‘a’ of type integer which can stored maximum 100 elements into it.
3)Array elements are always called using index number.
4)The base index of an array is always a zero.
5)Memory Representation : Array elements are always stored in a sequential /consecutive
memory Location.

6)Advantages: a) data stored in sequential


b) Easy to remember the name/access of any element of an array

7)Disadvntages: a) we can stored only a same kind of data


b) once we declared then we can not change the size of an array

Q6) Explain Linked List with example


Ans . 1)Definition : Linked List is a linear collection of data elements where each element is
called as Node.
Node contains two parts INFO and LINK
2)Info contain actual data and Link contain address of next data.
3)Address of first data is always stored in a START node and LINK part of last node is
always a NULL
4)It is also called as One way List.
5) For above diagram, there are five nodes in a linked List Address of first node is
stored in Likewise A stored in
B stored in
c stored in
d stored in

6)Memory Representation: To represent the Linked List in Memory we uses two arrays
INFO and LINK. INFO[K] contains information of every element. LINK[K] contain
address Of next node.
And Pointer field of last node denoted by NULL.

Q7 ) What is record? Explain in detail


Ans : 1) definition : Collection of interrelated fields called as record.
2)Collection of data is organized into hierarchy of fields.
3)Eg.

Student
1.Name
2. First name
2. Middle name
2. Last name
1.Age
1.Address
2. village
2. city
2. state
It may contain homogeneous or non homogeneous data.
4)Elements of records are referenced by level numbers.
5) Memory representation : The records are stored in memory using parallel linear arrays of an
elementary items.
for eg. If we want to access Kth record , First name[K],Middle name[K],……. Belong to the same
record in a file
Q8) Show the representation of records in memory considering suitableexample of three records
and three fields.

Q9 ) Difference between Linear array and Record ?


Linear Array Record
1 ) Definition Definition
2) Only Homogeneous data May contain homogeneous / on
homogeneous data
3) Referenced using index number Referenced using level numbers
4) Natural ordering of elements is possible Natural ordering of elements is not
possible
5) Memory representation: Sequential Memory Representation: parallel liner
arrays of an elementary items
6 )Eg.

Q10) Difference between Linear array and Linked List?

Linear Array Linked List


1 Definition Definition
2 Insertion of new element is quiet Insertion of new element is easier than
difficult array
3 Deletion of existing element is quiet Deletion of existing element is easier
difficult than array
4 Maintenance and modification is Maintenance and modification is easier
difficult than array
5 Memory Representation : Sequential Memory Representation: Using two
parallel arrays INFO and
LINK

Q 11) Explain pointer array with example


Ans : 1) Pointer is a variable which holds memory address of another variable.
2)Array is a set of finite number of homogeneous data which stored in sequential memory location
3)pointer Array : when each elements in an array is a pointer then it is called as pointer array
4)Consider an example which divides students in a 3 groups. Following figure shows , There are 10
students divides into 3 groups.

G1 G2 G3
Ram Priyanka Sonu
Pratik Ravi Prajakta
Shweta Vaibhav Bhavika
Vaishali

In these groups are to be represented in memory, the most efficient way is to use 2 arrays . The first
one is student array which contain list of all students stored in sequentially and Second array is
Group array , which is a pointer array which contains starting address of each group in the student
array resp.

1 Ram
2 Pratik
3 Shweta 1
4 Vaishali 5
5 Priyanka
6 Ravi
7 Vaibhav
8
8 Sonu
9 Prajakta
10 Bhavika

Each element of Group is a pointer , which holds the starting addresses of different groups.
Q12) Difference between STACK and QUEUE Ans:

Q 13) Define TREE? And Explain following terms?


Ans . It is a non linear hierarchical data structure where each element of a tree called as node. There
is one special designed node called as ROOT and other nodes are subdivided as t1,t2,t3…. Are
subtrees.
1) ROOT : A node which has no parent.
2) CHILD : The nodes which are reachable from a node. SIBLING : children of same parent.
3)Leaf/Terminal node: The node which has no child or children
4) LEVEL OF TREE: Each node in a tree is assigned a level number. Normally, level number
of Root ‘R’ is ZERO. and every other node is assigned to level number which is one more than the
level number of its parent.
5) DEPTH/HEIGHT :Maximum level of any node in a tree.
If Root has level 0 then depth of a tree is 1. DEGREE OF A NODE : The number of children of any
node.

Q 14) What is Binary Tree ?


Ans .
1) It is a non linear hierarchical data structure with finite set of elements called as nodes.
2) It may be empty or partitioned into thee disjoint subsets:
3) There is a single node without parent called as root. And other two are themselves binary tree
called as left subtree or right subtree.
4) A left and right subtree may be empty. BUT there is no node with degree greater than two.
Eg.
Q15) What is Binary Tree? Explain its terminology with suitable diagram?

Ans : 1) Definition : It is a non linear hierarchical data structure with finite set of elements called as
nodes.
2) It may be empty or partitioned into thee disjoint subsets:
There is a single node without parent called as root. And other two are themselves binary tree
called as left subtree or right subtree. A left and right subtree may be empty.BUT there is no
node with degree greater than two.

3) Terminology :

Root : Node with no parent .


Eg. 1
Left successor : Immediate left node from Root Eg . 2
Right successor : Immediate right node from root.
Eg. 3
Left Subtrees: All nodes from left hand side of Root.
Eg. 2,4,5
Right Sbtrees: All nodes from right hand side of Root.
Eg. 3,6
Terminal node: The nodes with no further child or children.
Eg. 4,5,6

Q16) What is binary tree? With suitable example show the relationship between total numbers of
nodes and depth of a tree
Ans :
Defination for binary tree
Depth of a binary tree means maximum level of any node in a tree .
Maximum number of nodes in a binary tree : Formula : 2n-1
example :

For above tree , depth is 3


So, the total number of nodes in a given tree -> 2n-1
->23-1
->8-1
->7

Q 17)Define the following :


Complete Binary tree : If all leaf nodes of a binary tree have same level number and every non
leaf node has non empty left and right subtrees then the tree is called as complete binary tree.

Extented binary tree or 2-tree :A binary tree T is said to be a 2-tree if every node N has either 0
or 2 children. The node with 2 children are called internal node and the nodes with 0 children are
called External nodes.
Binary Search Tree : It is a binary tree in which each node N of tree has the property that the value
at N is greater than every node value in the left subtree of N and is less than or equal to every node
value in the right subtree of N

Q 18) How binary trees are represented in memory?


Ans : A binary tree T can be represented in memory by two types of representation Linked and
Sequential
Linked Representation :
It uses three parallel arrays INFO ,LEFT and RIGHT.
A pointer variable ROOT uses such that for any index ‘k’
INFO[K] contains actual data,LEFT[k] contains address of left child and RIGHT[k]contains
address of right child.
The ROOT always stores address of first node of TREE . eg.
LEFT INFO RIGHT
0
1 3 A 5
2 X E X
3 4 B 2
4 6 D 8
5 7 C 9
6 X H X
7 X F X
8 X I X
9 X G X

Sequential Representation :
For this only one linear array is used. This array is generally known as TREE.
The ROOT ‘R’ of the tree is stored in TREE[0]
if a node N of a tree stored in TREE[k]then,

0 A
1 B
2 C
3 D
4 E
5 F
6 G
7 H
8 I
9 -
Q) Draw Binary Tree for following expressions.
1)

2)

3)
ALGORITHMS

1) TRAVERSING
Traversing means accessing each records at only once.
Traverse( LA,N,LB,UB)
Where,
LA-> Linear array
N-> total no.of elements
LB-> Lower bound
UB-> upper bound
Step 1: start
Step 2: Repeat for i=LB to UB Apply process on LA[i]
(end of loop)
Step 3: stop

2) INSERTING
Inserting means insert new record/element in existing array
Insert(LA,N,K,ITEM)
Where,
LA-> Linear array
N-> total no. of elements K-> Position of new item
ITEM-> new item to be added
Step 1: start
Step 2: j:=N
Step 3: Repeat step 4 and 5 while j>=k
Step 4: LA[j+1]:=LA[j]
Step 5: j:=j-1
(end of loop)

Step 6: LA[k]:=ITEM
Step 7: Reset N:=N+1
Step 8: stop

3) DELETING
Delete/remove any element from existing array
Delete(LA,N,K,ITEM)
Where,
LA-> Linear array
N-> total no. of elements
K-> Position of item
ITEM-> item to be deleted
Step 1: start
Step 2: ITEM:=LA[k]
Step 3: Repeat step 4 for i=k to N-1
Step 4:LA[j] :=LA[j+1]
(end of loop)
Step 5: Reset N:=N-1

Step 6: stop

4) SORTING
Sorting means arranging elements in ascending/descending order
Bubble Sort(LA,N)
Where,
LA-> Linear array
N-> total no.of elements
Step 1: Start
Step 2: Repeat step 3 and 4 for k=1 to N-1
Step 3: Set ptr :=1
Step 4: Repeat while ptr<=N-k
If LA[ptr]>=LA[ptr + 1]
Then interchange LA[ptr] and LA[ptr + 1]
Set ptr:= ptr + 1
(end of inner loop )
( end of outer loop)
Step 5 : Stop

Example 1 :

Example 2:
5)Linear Search
Searching means to find out a particular element from a given list of elements.
Linear Search means the given (finding ) element is compared with each element of list one by one.

Linear Search(LA,N,ITEM,K)
Where,
LA-> Linear array
N-> total no. of elements
ITEM -> element to be search
K->position of the item

Step 1: start
Step 2: set LA[N+1 ] :=ITEM
Step 3: K:=1
Step 4 : Repeat while LA[K] ≠ ITEM
Set K :=K +1
(end of loop )
Step 5 : if K = N+1
K: = NULL ( Search unsuccessful)
Step 6 : Stop

Example 1 :
6)Binary Search
Searching means to find out a particular element from a given list of elements.
Binary search means the given element is search from sorted array.
Binary(LA,LB,UB,ITEM,LOC)
Where,
LA-> Linear Array
LB-> Lower Bound
UB-> Upper Bound
ITEM-> element to be search
LOC-> Location of data

Step 1: start
Step 2: set BEG:=LB, END:=UB, MID:=INT(BEG+END)/2
Step 3: repeat step 4 and 5 while BEG<=END and LA[MID]≠ITEM
Step 4: if ITEM<LA[MID]
END:=MID-1
Else
BEG:=MID+1
( end of if )
Step 5: set MID :=INT (BEG+END)/2
Step 6: if LA[MID]=ITEM then
Set LOC:=MID
Else
LOC:=NULL
Step 7: stop

Example 1:
Example 2 :
Q ) difference between Linear Search and binary search
Ans :
Subject : c.s- 1
Introduction to c++
Q1) differentiate between procedure oriented and object oriented programming
Ans :
POP OOP
1 Top down approach Bottom up approach
2 Data hiding not possible Data hiding possible
3 Emphasis on things Emphasis on data
4 Data move openly from Data can not be accessed by external
function to function function
5 The problem is viewed as a The problem is decomposed into a
sequence of things to be done number of entities
6 Large program are divided into Large programs are divided into
smaller program known as smaller entities called as objects.
function

Q 2) explain data types in c++


Ans : datatype is nothing but to specify the particular type of data which we can store.
There are main 3 categories of datatypes in c++

1)user defined data types: a) user will create new abstract data type , which can
behave like any built in datatype
b) eg. Structure, class etc.
2) built in datatype: a) also called as “basic” or “ primary” datatype
b) already specified by c++ s/w

Data type Size(bytes)


1) int 2
2) char 1
3) float 4
4) double 8
5) void -

3)derived datatype : a) also called as “secondary datatype”


b) derived only with the help of primary datatype
c) eg. Array , function, pointer

Q 3)Explain insertion and extraction operators?


Ans :
Insertion operator Extraction opertaor
1) Symbol - << Symbol - >>
2) Also called as put to Also called as get from
3) Eg. cout<<a Eg . cin>>a
cout<<”a”
4) Above eg. cout<< a will display Above eg cin>>a will accept value
value of a and from keyboard and assign to variable
cout<<”a” will display a as it is a
5) It inserts the contents of the It assigns value to its right
variables on its right to the object
on its left
6) It is used in output statement in It is used in input statement in c++
c++

Q) short note on scope resolution operator?


Ans :
1) symbol - ::
2) scope resolution operator is used to access global value rather than local value.
3) c++ is a block structured language.
4) When a variable is declared in program , scope extends from the point of
declaration till the end of the block in which it is defined.
5) i.e it is used to uncover a hidden variable
6) syntax -> :: variable name
7) eg.
int a =5; // global value
{
int a=8; // local value
……..
……..
cout<< a;
cout<< ::a ;
}
8) output :
8 5
Q)Explain memory management operators in detail?
Ans :
1) c++ provides two memory management operators
new and delete
2) new operator is used to allocate the memory dynamically .
3) the new operator returns NULL , if memory allocation is unsuccessful.
4) Syntax : datatype * new datatype[ size ];
5) delete operator is used to deallocate the memory which is allocated with the help
of new operator. So this memory can be reused by other parts of program.
6) Syntax -> delete pointervariable;
7) Eg
{
int *p=new int[ 3 ];
…..
…..
delete p;
}
8) In above example , the new operator returns a pointer that point to a memory
section large enough to hold integer an extra byte for null.
Then after its use, delete operator released memory .

Q)list the syntax for looping structure?


Ans :
1) for loop
syntax :
for( initialization; test condition ; increment/decrement)
{
Body of loop
}
Entry controlled loop.
2) While loop
Syntax :
While(test condition )
{
Body of loop
}
Entry controlled loop
3) do…while loop
syntax :
do
{ body of loop
}
While(test condition);
Exit controlled loop

Q)short note on inline function ?


Ans :
1) when a function is called , a lot of time is spent in executing a series of
instruction , or such a task such as jumping to the function , saving registers,
pushing arguments into stack and returning to the calling function.
2) So, to minimize the execution time c++ provide the solution “inline function”
3) An inline function is a function that is expanded inline when it is invoked.
4) Compiler replaces function call with the corresponding function code.
5) Syntax :
inline function header()
{
Function body
}
6) Advantages: run faster
7) Disadvantages : only used by smaller function ,
Not be used with looping, static function, recursion
8) Eg ,. inline int add(inta, int b)
{
return(a+b);
}

Q)explain function overloading in detail


Ans :
1) the mechanism of giving same function name for more than one function in a single
program but they differ with their function signature called as function overloading
2) function signature means number of arguments or types of arguments.
3) the use of same function name to create functions that perform a variety of task is
called as function overloading
4) it is the example of compile time polymorphism
5) using this concept, create a family of functions with one function name but with
different argument lists.
6) select appropriate function depending upon the type of arguments or number of
arguments not on return type.
7)
Eg.
int area( int , int);
float area( float);
void main()
{
cout<<” area of circle”<< area(2.5);
cout<< “ area of rectangle “<< area(1, 6);
}
int area( ina l ,int b)
{
return ( l * b);
}
float area( float r)
{
return( 3.14* r *r);
}

Q)what is pointer ? give advantages of pointer ?


Ans :
1) Definition :Pointer is a variable which holds the memory address of another
variable.
2) Symbols : * and &
3) Syntax : datatype * variablename;
4) Advantages :
1)Pointers save the memory.
2)Pointers reduce the length and complexity of a program.
3)Pointers allow passing of arrays and strings to functions more efficiently.
4)Pointers make possible to return more than one value from the function.
5)Pointers increase the processing speed.

Q)Explain how the memory address of a variable can be accessed in c++?


Ans :
1) Memory location can be used to store the values of a variable and each memory
cell called as address.
2) In c++, when we declare a variable , then it gets associated with certain memory
location .
3) Eg int a = 5;
Where, a is variable name
5 is a value
1001 is memory location name.
4) To access value using memory location so we can used the concept of pointer.
5) Symbol * and & is used. * is called as value at operator( de-referencing
operator) and & is called as address of operator ( referencing operator)
6) So we can write, int a=5;
int *p;
p=&a;
7) & operator always returns the memory address of its operand.

Q) explain call by value and call by reference


An s:
Call by value :
1) When function invokes , control will be transferred from the main function to
the calling function .
2) The values of actual arguments are copied into the formal arguments.
3) Within a function that values may be altered or changed but altered values are
not transferred back.
4) void swap( int , int);
void main()
{
….
…..
swap( a,b);
…..
……
}
void swap( int x, int y)
{
int t;
t=x;
x=y;
y=t;
}
Call by reference:
1) When a function is called by a program the address of actal arguments are
copied into the formal arguments.
2) i.e both are referring to the same memory location
3) so, changed in formal arguments affects actual arguments.
4) Eg.

5) void swap( int * , int *);


void main()
{
….
…..
swap( &a,&b);
…..
……
}
void swap( int *x, int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}

Q)structure of c++ program?


Ans :

A normal c++ program contain 4 sections as shown in above diagram.


1)it is a common practice to organize a program into 3 separate files
2) the class declaration are placed in a header file and the definitions of the member go
in other files
3)this approach enables the programmer to separate the abstract of the interface from
the implementation details.
4)finally the main program that uses the class is placed in third file , which includes the
previous two files as well as any other files required .

Q) what is OOPs? Features of OOPs?


Ans :
1) Definition : it is an approach that provides a way of modularizing programs by
creating partitioned memory area for both data and functions
2) Features:
 Emphasis on data
 Programs are divided into objects
 Data is hidden
 It can not be accessed by external function
 New data and functions can easily added
 Bottom up approach
 Object may communicate with each other through functions.
Q) what is class ? explain general form of class?
Ans:1)definition : it is a way to bind data members and member functions together.
2)it allows data to be hidden from external use.
3)generally class specification has two parts :
 Class declaration : specifies the type and scope of variables(members)
 Class function definition : how the class functions are implemented
4 ) syntax :
class classname
{
private :
variable declaration
function declaration
public :
variable declaration
function declaration
};

5)visibility labels :
private : only accessed by the functions of same class
public: accessed by all
protected: accessed by same class and its next derived class
6 ) default visibility label/ access specifier is private
7) every class terminated with close curly brace with semicolon.
8) eg.
class A
{
int p;
public:
void add();
};
Q)How to declare member functions of class ?
Ans :
1) there are two ways to declare a member function of a class inside and outside
2) Inside member function declaration :
 When a function is defined inside a class , it is treated as inline function.
 Only used for small functions
 Eg . class A
{
int x;
public:
void put()
{
cout<<”hello”;
}
};
3) Outside member function declaration:
 the member function can be defined outside the class using :: operator
 this tells the compiler the class which the function belongs and restricts the
scope of that function.
 Eg. class A
{
int x;
public:
void put();
};
void A :: put()
{
cout <<”hello”;
}

Q) what is object ?
Ans :
1) Definition: it is variable whose data type is class
OR
It is a basic runtime entity in OOPS
2) Objects created in void main ()
3) Syntax :
void main()
{
A x; //object creation
x. add(); //functions access using object
}
4) User have more than one object for a class. But reverse is not true.
5) The private data of a class can b accessed only through the member functions of
that class.
6) To use a member function , the dot operator connects the object name and the
member function.
7) The dot operator called as class member access operator.

Q) what is friend function ? characteristics of friend functions?


Ans : definition:
The private data members of class can be accessed only using object of same class.
But if there is a situation any outsider function wants to access private data members
of a class then declare that function as friend of class.
Characteristics :
1)it is not in the scope of the class to which it has been declared as friend.
2)since it is not in the scope of the class , it can not be called by using object of that
class
3) it can be either declared in public and private part of class.
4) it has the object as arguments.
5) it can accessed member functions using object and dot operator.

Q) what is constructor ?explain with its characteristics ?


Ans :
Definition : It is a special member function of a class whose name is same as class
name.
Its task to initialise the object of a class.
It is used to construct the values for a data members.
Characteristics :
1)it is always same name as a class name
2)they should be always declared in public section of a class
3)they can not be static or virtual
4)they do not have a return type even void also.
5) we can not refer their address
6) they can have default arguments
7) they make implicit call to new and delete operator.
8)when a constructor is declared for a class , it is invoked automatically when the
objects are created.

Q) what is destructor? Characteristics ?


Ans :
Definition : A destructor is the same name as constructor but preceded with sign
tilde (~ ), which is used to destroy the object that have been created by a constructor.
 It is invoked implicitly by the compiler upon exit from the program .
 It is good practice to declare destructor in a program since it release memory
For future use.
Characteristics :

1) Same name as class name preceded with the sign tilde (~)
2) No return type even void also
3) It takes no arguments
4) Always declared in public section of class.

Q) what is constructor and destructor explain with example.


Ans :
Definition for constructor : It is a special member function of a class whose name is
same as class name.
Its task to initialise the object of a class.
Definition for destructor: A destructor is the same name as constructor but preceded
with sign tilde (~ ), which is used to destroy the object that have been created by a
constructor.
Eg.

class ratio
{
public:
ratio()
{
cout<<”constructor”;
}
void ratiox()
{
cout<<” member function”;
}
~ratio()
{
cout<<” object dies”;
}
};
void main()
{
ratio r; // object created…..constructor called
r.ratiox();
} // end of program…….destructor invoked.

Q)characteristics of static data members in a class?


Ans :
1) It is initialized to zero when first object of its class is created.
2) Only one copy of that member is created for the entire class and it is shared by all
the objects of the class.

3) It is visible only within the class , but its lifetime is the entire program.
4) Static data members are only accessible by static functions only.

Q)what is inheritance ? explain with its types?


Ans :
Definition :
The mechanism of deriving a new class from existing class called as Inheritance.
Where, old class called as base class/ super class / parent class.
New class called as derived class/ sub class / child class.
 Inheritance support the concept of reusability.
TYPES :
1) Single inheritance :
Derive a class from single base class

2) Multilevel Inheritance

The mechanism of deriving one class from another derived class .


3) Multiple inheritance

Deriving a class from several base classes.


4) Hierarchical inheritance:

Derived several classes from single base class.

5) Hybrid inheritance

Q) what is virtual base class?


Ans :

1) When hybrid inheritance is used , there are atleast 3 levels as shown in figure.
2) From above figure, class b and C is derived from class A and class D is derived
from class B and class C
3) i.e property of class A can be inherited to
A-> B -> D
A-> C-> D
4) this means class D may contain duplicate sets of members of class A. this
produces ambiguity( confusion)
5) to avoid this ambiguity , concept of virtual base class is used.
6) class A
{
……
};
class B:public virtual A
{
……
};
Class C: virtual public A
{
……
};
Class D : public B, public C
{
…..
};
7) When a class is made a virtual base class, C++ takes necessary care to see that
only one copy of that class is inherited
8) The keyword virtual and public may be used in either order.

Q) what is operator overloading ?give its advantages?


Ans :
1)definition : the mechanism of giving some special meaning to operator called as
operator overloading
2) when operator is overloaded , its original meaning is not lost.
3)to define an additional task to an operator , a special function called as operator
function.
4)there are two types of operator : unary and binary
5)advantages :
 It extends the capabilities of an operator
 applied in data conversion
 built in data types behaves similar to user defined data type

Q) what is operator overloading ? steps to perform operator overloading?


Ans :
definition : the mechanism of giving some special meaning to operator called as
operator overloading
steps :
1. implement a class that defines the data type that is to be used in overloading
operator.
2. Declare operator function operator op() in public part of class. it may be either a
member function or friend function
3. Define operator function operator op () with proper logic.

Q) state any 8 rules for overloading operators?


Ans :
 only existing operators can be overloaded
 it must have atleast one operator and one operand
 the basic meaning of an operator can not change
 basic syntax/ rules of an operator can not change
 :: (scope resolution) ,
. (membership)
.* ( membership to pointer )
?: (ternary ) operators can not be overloaded.
 = , ( ), [ ], -> these operators can be overloaded using member function but not be
used in friend function
 unary operator overloaded using member function takes zero ( 0) arguments.
 unary operator overloaded using friend function takes one ( 1) arguments.
 binary operator overloaded using friend function takes one ( 1) arguments.
 binary operator overloaded using friend function takes one ( 1) arguments.

Q) what is polymorphism? Explain with its type?


Ans :
1) Poly means many and morph means form. polymorphism simply means “one
name , multiple form”
2) Multiple functions with same name that have different behaviour .

Compile time polymorphism :


1) It select appropriate function depending upon function signature i.e type of
arguments or number of arguments.
2) It is also called as early binding or static binding because an object is bound to its
function at compile time
3) Function overloading and operator overloading are the example of compiletime
polymorphism.

Runtime Polymorphism :
1) In some situation , it is nice to select appropriate member function to be invoked
while the program is running.
2) When base class and derived class both classes having same function with same
signature then to avoid the confusion will use the concept of virtual function.
3) At runtime, it is known what class objects under consideration , the appropriate
version of function is called.
4) It is also called as dynamic binding or late binding because selection of function
is done at dynamically or much after the compilation.

Q) what is virtual function?


Ans :
1)when base class and its derived class both classes use the same function name with
same function signature then base class is declared as virtual using the keyword ‘virtual’
preceding its normal declaration.
2) when a function is made virtual , c++ determines which function to use at runtime
3) virtual function can be accessed through the use of pointer declared as pointer to base
class.
4) if two functions with same name have different signature , c++ considers as
overloading function not a virtual function
Eg.

#
#
class A
{
public:
virtual void show()
{
cout<<”tom”;
}
};
class B:public A
{
public:
void show()
{
cout<<”\n bob”;
}
};
void main()
{
A x,*p;
B y;
p=&x;
p->show();
p=&y;
p->show();
}
Output
Tom
bob

Q) what are the rules to declare a virtual function ?


Ans :
1) It must be a member of some class
2) They can not be static member
3) They are accessed by using object pointer
4) It can be a friend of another class
5) A virtual function is defined in base class , they need not be redefined.
6) A virtual function must be defined in base class eventhough it is not used.
7) We can not have virtual constructor but we can have virtual destructor
8) A base pointer can point to any type of derived object ,but the reverse is not true.
9) The prototype(signature) of the base class version of virtual function and all
derived class version must be identical.

Q)what are input output stream ?


Ans :
1) The i/o stream is an interface between program and files
2) C++ handles file operation which are very much similar to console input and
output operations.
3) There are two file handling streams : input and output
4) Diagram :
5) Input stream reads the data from file also used to enter data in program
6) Output stream receives the data from program and also writes data into file
7) The input operation involves the creation of input stream and linking it with
program and input file.
8) The output operation involves the creation of output stream and linking it with
program and output file.

Q) similarities and differences between ifstream and ofstream


Ans :

Q)what are the classes in c++ for file stream operation ? how do you open and close
file in c++? Explain file handling modes ?
Ans:
1) c++ contains set of classes which r used in file handling ifstream,
ofstream , fstream
2) ifstream : used for input purpose
ofstream : used for output purpose
fstream : used for both input and output
3 ) these 3 classes are derived from fstreambase class
4 ) to perform any file handling operation we need to include <fstream.h> header
file

Opening a file
1) Syntax : file handling class object;
Object.open(file name);
OR
file handling class object;
Object.open(file name, mode);

2) filestream class can be anything ifstream, ofstream, fstream. Need to create the
object for class.
3) Eg. 1) ifstream fin;
fin.open(“ country.txt”);
2 ) ofstream fout;
fout.open( “ capital.txt”, ios::in);

closing a file :
1) To close a file we don’t need to pass the file name , file which is opened for read ,
write that is used to be close
2) Syntax : object. close();
3) Eg. fin.close(); // closes country.txt file
fout.close(); // closes capital.txt file
file handling modes :

ios::app -> append to the end of file


ios::ate -> go to end of file on opening
ios::in-> open a file for reading purpose
ios:: out-> open a file for writing purpose
ios:: binary -> open binary file
ios::nocreate -> open fails if file does not exist
ios::noreplace -> open fails if file already exist
ios:: trunk -> delete the contents of file, if it is exist.

Q) what are file pointers?


Ans :
1) Each file associated with 2 pointers : input pointer and output pointer
2) Both the pointers are used to move through the files while reading and writing
3) The input pointer is used to read the contents of given file location
4) Output pointer is used for writing to a given file location
5) Input pointer is also called as get pointer and output pointer is also called as put
pointer
6) Each time whenever input or output operation takes place , the appropriate
pointer is automatically called.

Q) explain the purpose of following functions :


1) seekg():
It is used to move the file pointer forwards with given number of bytes .
Syntax: seekg(int);
Eg. ifstream fin(“abc.txt”);
fin.seekg(10);
seekg() moves file input pointer 10 bytes forward.

2)seekp()
It is used to move the output file pointer forwards with given number of bytes.
Syntax: seekp(int);
Eg. ifstream fin(“abc.txt”);
fin.seekp(10);
seekp() moves file output pointer 10 bytes forward.

3) tellg()
It is used to return current file pointer position . this function is associated with input
file stream .
Syntax : tellg()
Eg. ifstream fin;
fin.open(“abc.txt”);
int n=fin.tellg();

4)tellp()
It is used to return current file pointer position . this function is associated with output
file stream .
Syntax : tellg()
Eg. ofstream fin;
fin.open(“abc.txt”);
int n=fin.tellp();

4) get()
this function is used to read a character into file.it is related to ifstream object.
Syntax : ifstream f (“abc.txt”);
char c;
while(fin)
{
fin.getc(c);
cout<<c;
}
5 )put()
this function is used to store a character from file.it is related to ofstream object.
Syntax : ofstream f (“abc.txt”);
char c;
while(fin)
{
fin.getc(c);
cout<<c;
}
7)read()
This function is used to read data in binary mode from file.this function is
associated with ifstream object.
8)write()
This function is used to rwrite data in binary mode to file.this function is
associated with ofstream object.
Subject : c.s -1
HTML

Q1 ) what is html?
Ans : HTML stands for Hypertext Markup Language.it is used to create web pages.it is
most simple, text oriented programming languages.
Hypertext : original text+ extra features
Markup: process of taking ordinary text and adding extra symbols.

Q 2) what are the advantages of HTML


Ans :
1)it is used to create web pages.
2)no special s/w required.
3)h/w platform independent
4)powerful formatting facilities available
5)easy to learn
6)easy to implement
7)easy to update html pages
8) independent work can be done
9)hyperlink facility is available
10)simple than any other programming language
11)error finding easy

Q 3)what are the disadvantages of HTML


Ans :
1) It is not a programming language in true sense.
2) Can not done simple calculation
3) Can’t display current date
4) Interactive/attractive web page can not be done
5) Can not be used in real life application
6) Do not have their own interface
7) Hyperlink facility is available but we need to trip to server fo every visit

Q 4) give structure of HTML web page or


Explain basic and essential tags in HTML?
Ans: structure
<html>
<head>
<title>
…………..
</title>
</head>
<body>
………..
………..
………..

</body>
</html>

a) <HTML>
1)always start with <HTML> and ends with </HTML>
2)all other tags must enclosed within <html > and </HTML>
3)when document start with <HTML> , must told that to browser that
the file is HTML file.
4) it is a start of any web document.

b)<HEAD>
1)stats with<HEAD> and ends with </HEAD>
2)header area of web page
3)it is not displayed within the web page
4)<TITLE > tag always enclosed with <HEAD > tag

c)<TITLE>
1)starts with <TITLE> and ends with </TITLE>
2)it is used to give appropriate title for web page.
3)there should not be extra space between <TITLE > tag and actual title of
web page
4) <TITLE > tag always enclosed with <HEAD > tag

d) <BODY>
1)starts with <Body> and ends with </body>
2)other than basic tags all other tags must enclosed within
<BODY> tag
3)the actual contents of web page that will be displayed on browser
Will always put it into body section
4) it has number of attributes like bgcolor,font etc.

Q 5)explain t procedure of HTML page


Ans :
Step 1: open text editor
Step 2: write HTML code
Step 3: save HTML code with appropriate name with extension .HTML
Step 4: open the web browser
Step 5 : browser the appropriate file from address

Q 6 )explain following tags

1) <BR>
a) Break line
b) It tells the browser to put the text that follows onto next line
c) For multiple blank lines, that much <BR> tags we have to include
d) Eg. A<Br>B<br>c
Output:
A
B
C

2) <HR>
a)horizontal ruler
b)to divide the web page into different sections
c)mostly used for decorative purpose
d)attribute : size -> thickness of line and width-> how much percentage of line
display
e)eg. <HR size=”2” width= “50%”>
output:
______

3) <IMG>
a) Image tag
b) Used to display image on web page
c) Image of two types inline and floating image
d) Inline image, we can put either top,middle or bottom of a line
e) Floating image can wrap text either on left and or right and side of image.
f) Attributes: SRC->image file path searching
ALT->used to displayed text instead of image
g) Eg. <IMG src=”sunset.jpg” alt=”HELLO”>

*NOTE : above 3 tags are standalone tags. Those are not having any
closing tags *

4) <P>
a) paragraph tag
b)used to create a paragraph
c)browser ignores the paragraph created by user by making pressing enter key
d)attributes: align with values left,right,center,justify
e) eg.
Hie,I m a tom. How r u?

Output :
Hie, I m a tom.
How r u?

5) <PRE>
a)preformat the text
b)the text appearing between start tag <PRE> and end tag </pre> is displayed in
mono space form.
c)this tag is used to position the characters.
d)this tag displays the text in exactly same format as the character and line
spacing format defined in HTML code.
e)eg. <PRE>
1
2 2
3 3 3
</pre>
OUTPUT:
1
2 2
3 3 3

6 )Physical/formatting tags :
<B>
Bold tag.
Text appearing between start tag <B> and </B>will be displayed in
bold .
Eg. <b>pqr</b>
Output:
Pqr

<I>
italic tag.
Text appearing between start tag <I> and </I>will be displayed in
italic.
Eg. <i>pqr</i>
Output:
Pqr

<u>
underline tag.
Text appearing between start tag <u> and </u>will be displayed in
underlined.
Eg. <u>pqr</u>
Output:
Pqr

8) <marquee>
a) Used to scroll the text or image from right to left.
b) The text written between start tag <marquee> and </marquee> will
scroll horizontally by default.
c) Attributes: bgcolor,height
d) Eg :
<marquee> pqr </marquee>
Output:
<- <- <- pqr

9) <strike>
a)strike tag
b)the text enclosed within <strike > and </strike> would have line drawn
through the center/middle of the text.
c)eg. <strike> pqr </strike>

output :
pqr

10) < SUP>


a) Superscript
b) The text enclosed within <SUP> and </SUP> is displayed in super
script form.
c) Bit higher than normal text.
d) Used in mathematical formulas
e) Eg. x<sup>y</sup>
Output:
xy
11) <SUB>
a)Subscript
b)The text enclosed within <SUB> and </SUB> is displayed in sub script
form.
c)Bit lower than normal text.
d) Used in chemical formulas
Eg. H<sub>2</sub>O
Output:
H2O

12) <font>
a) Font tag
b) Used to change the size, colour, type(face) of the text.
c) Attributes: SIZE -.> 1 to 7 and by putting plus and minus sign before
the number will change the font size relative to the default size.
Color -> direct colour name or RGB colour format
RED : #ff0000
GREEN: #00FF00
BLUE : #0000FF
BLACK : #000000
WHITE : #FFFFFF
Face : style of the text eg.arial, times new roman
d)eg. <FONT face= “arial “ color=”red” size=7> computer
science</font>

output :
computer science

13) <BIG>
a) Big tag
b) The text enclosed within <BIG> and </BIG> is displayed in
larger font
c) It has same effect asc<font size=”+1” >
d) If already the size is largest , then tag is ignored.
e) Eg. Pqr<big>Pqr</big>
Output :
PqrPqr

14) <SMALL>
f) Small tag
g) The text enclosed within <small> and </small> is displayed in
smaller font
h) It has same effect asc<font size=”-1” >
i) If already the size is smallest , then tag is ignored.
j) Eg. Pqr<small>Pqr</small>
Output :
PqrPqr
15) <OL>
a)order list . numbered in fashion
b)it includes : numbers(1 to 9 and combinations)
small letter alphabets (a to z)
uppercase letter alphabet( A to Z)
roman lower number ( i to x)
roman higher number (I to X)
c ) default appearance for list is numbers.
d)attributes : type, face
e)<LI> tag is used to indicate actual list element

16) <UL>
a) Unordered list. Bulleted list.
b) It includes: closed circle/disc ( ● )
Open circle (○ )
Square(■ )
c)default appearance is disc
d)attributes: type
e) the end tag </UL> is always required at the end of
unordered list.
f)<LI> tag is used to indicate actual list element.

17) <LI>
a) List item
b) Used with OL and UL tag.
18) < A>
a) anchor tag
b)it is used to create links and hyperlink.
c)this link is clickable graphical link.
d)the text or image enclosed between <a> tag is a link.
e)attribute : HREF (hypertext reference )
f) eg. <A href=” www.google.com”>home</A>
output:
home

18) <TABLE >


a) Used to create table.
b) Table consist of rows and columns
c) The row is created using <TR> and cells can be inserted in <TD>
and <TH>
d) Attributes: border, cellpadding, cellspacing,
bgcolor,bordercolor,align
19) <CAPTION >
a)used to create a caption on top or bottom of table.
b)it can be used with align attribute TOP/ BOTTOM
c)caption is displayed outside the table’s border.
d)we have to provide caption inside the <caption > tag.
e) eg. <caption> cricket record </caption>

20) <TR>
a)table row
b)it creates horizontal row .
c)each use of <TR> begins a new row.
d)a row must contain atleast one table data.
e) attributes : ALIGN,BGCOLOR

21) <TH>
a) Table heading
b) Used to represent individual column .
c) By default text in this bold and center
d) Attribute: colspan, rowspan, align

22) <TD>
a)table data.
b)it creates individual column
c)number of TD tag in a single <TR> tag determines the number of
columns.
d)by default text in this normal and left
e) attributes: colspan, rowspan, align

Q )list and explain the types of hyperlinks?


Ans:hyperlink is basically used to create/jump from one web page to another . it can be
done with the help of<A> tag.
There are 3 types of hyperlink:
a) LINK to page on WWW
<A HREF=www.google.com >home </A>
Home is a hyperlink link to a website indicates once u click on home it will
transfer u to google page.

b) LINK to image by another image


< A HREF=”sunset.gif”><IMG SRC=”moon.gif”></A>
The image sunset.gif is a hyperlink. Once v click on image moon.gif , it will
open sunset.gif image
c) LINK to document /file in different drive.
< A HREF= “c://abc/page.txt”> login</A>
Here after clicking on text login will open file page.txt.

PROGRAMS:

1)
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>

<ol start="50">
<li>eggs</li>
<li>fish</li>
<li>meat</li>
</ol>

OUTPUT :
1.Coffie
2.Tea
3.Milk
50.eggs
51.fish
52.meat

2)
<ul>
<li>Chocolate Cake</li>
<li>Black Forest Cake</li>
<li>Pineapple Cake</li>
</ul>

OUTPUT:

 Chocolate Cake
 Black Forest Cake
 Pineapple Cake
3)
<html>
<body>

<h2>Unordered List with Square Bullets</h2>


<br>
<h2>Grocery list</h2>
<br>
<ul type =”square">
<li>Bread</li>
<li>Eggs</li>
<li>Milk</li>
<li>Coffee</li>
</ul>

</body>
</html>

OUTPUT :

4) <html>
<body>
<h1><b>subjects</b></h1>
<ol>
<li>english (compulsory)
<li>second language....
<ul type=”circle”>
<li > physics</li>
<ul type="disc">
<li>chemistry</li>
<ul type="square">
<li>maths</li>
<li>biology</li>
</ul>
</ul>
</ul>
</ol>
</body>
</html>

Output:

5)
<html>
<body>
<ol>
<li>Fruit
<ul type=circle>
<li>Apples</li>
<li>Oranges</li>
<li>Pears</li>
</ul>
</li>
<li>Vegetables
<ul type =circle>
<li>Broccoli</li>
<li>Peas</li>
<li>Corn</li>
</ul>
</li>
</ol>
PROGRAMS on TABLE tags:
1)
<html>
<head>
<title> simple program</title>
</head>
<body>
<table border="1">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
</body>
</html>

OUTPUT

2)
<html>

<head>
<title>HTML Table Cellpadding</title>
</head>

<body>
<table border = "1" cellpadding = "5" cellspacing = "5">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
</tr>
</table>
</body>

</html>
This will produce the following result –

3)
<HTML>
<HEAD>
<TITLE>EXAMPLE OF COLSPAN AND ROWSPAN</TITLE>
</HEAD>
<BODY>
<CAPTION>RESULT</CAPTION>
<TABLE BORDER="1" CELLSPACING="10">
<TR>
<TH ROWSPAN="2">COMPUTER SCIENCE</TH>
<TH>PAPER-I</TH>
<TH>PAPER-II</TH>
</TR>
<TR>
<TD>50</TD>
<TD>45</TD>
</TR>
</TABLE>
</BODY>
</HTML>

OUTPUT:

4)
year
2000 2001 2002
Units 500 1000 1500
Sales
Income Rs.1500 Rs.10000 Rs.15000

5)

STREAM

SCIENCE COMMERCE ART


6)

CRICKET ANALYSIS

COUNTRY PLAYED WON LOSE

INDIA 30 24 07

AUS 24 19 05

PAK 18 02 16

ZIM 10 07 03

7)

Pen Pencil Eraser scale


sales
25 34 33 10

Thank you

<html>
<body>
<table border=”1”>
<tr>
<td rowspan=2 align=”center”>sales</td>
<td>Pen</td>
<td>Pencil</td>
<td>Easer</td>
<td>scale</td>
</tr>

<tr>
<td>25</td>
<td>34</td>
<td>33</td>
<td>10</td>
</tr>
<tr>
<th colspan=”5”> Thank you </th>
</tr>
</table>
</body>
</html>

C++ Programs:

Programs of string
Q)Enter a string and count number of words in a string :

#include <iostream.h>
#include<conio.h>
#include<string.h>
void main( )
{
char a[100];
int n,l,i;
n=0;
cout<<“Enter a string”;
cin.getline(a,100 );
l=strlen(a);
for(i=0;i<l;i++)
{
if(a[i]==“ “)
n++;
}
cout<<“total no. of words” << n+1;
getch();
clrscr();
}

Q)
Enter a string and count occurance of ‘j’ in a string :

#include <iostream.h>
#include<conio.h>
#include<string.h>
void main( )
{
char a[100];
int n,l,i;
n=0;
cout<<“Enter a string”;
cin.getline(a,100 );
l=strlen(a);
for(i=0;i<l;i++)
{
if(a[i]==“ j “)
n++;
}
cout<<“total no. of j in string” << n;
getch();
clrscr();
}

Q)
Enter a string and replace every space with hyphen (-)

#include <iostream.h>
#include<conio.h>
#include<string.h>
void main( )
{
char a[100];
int l,i;
cout<<“Enter a string”;
cin.getline(a,100 );
l=strlen(a);
for(i=0;i<l;i++)
{
if(a[i]==“ “)
a[i]=‘-’;
}
cout<<“string with hyphen\n”<<a;
getch();
clrscr();
}
Q) Enter a string and print reverse of a string

#include <iostream.h>
#include<conio.h>
#include<string.h>
void main( )
{
char a[100];
int l,i;
cout<<“Enter a string”;
cin.getline(a,100 );
l=strlen(a);
for(i=l-1;i>=0;i--)
{
cout<< a[i];
}

getch();
clrscr();
}

Programs on Array
Q) write a program to enter 10 numbers in an array and calculate sum and average
#include <iostream.h>
#include<conio.h>
void main( )
{
int a[10];
int i , sum=0;
float avg=0.0;
cout<<“Enter 10 numbers”;
for(i=0 ; i<=9 ;i++ )
{
cin>>a[i];
}
for(i=0 ; i<=9 ;i++ )
{
sum=sum+a[i];

}
cout <<”Sum is”<< sum;
cout<<”Average is “<<avg;
getch();
clrscr();
}

Q) write a program to enter 10 numbers in an array and find largest number


#include <iostream.h>
#include<conio.h>
void main( )
{
int a[10];
int i , l;
cout<<“Enter 10 numbers”;
for(i=0 ; i<=9 ;i++ )
{
cin>>a[i];
}
i = a[0];
for(i=1 ; i<=9 ;i++ )
{
if (l < a[i])
l =a[i];
}
cout <<”largest number is “<<l;
getch();
clrscr();
}

Programs on concept of OOPs

Q ) write a program in oops to implement class circle and calculate area of a circle

#include< iostream .h>


#include <conio. h>
class circle
{
float r, area;
public:
void calculate();
};
void circle :: calculate()
{
cout<< “ enter radius “;
cin >> r;
a = 3.14*r*r ;
cout <<” Area is : “<<a;
}
void main()
{
circle c;
c. calculate();
getch();
clrscr();
}

Q ) write a program in oops to implement class rectangle and calculate area and
perimeter of a rectangle

#include< iostream .h>


#include <conio. h>
class rectangle
{
int l,b, area, perimeter;
public:
void calculate();
};
void rectangle :: calculate()
{
cout<< “ enter l and b “;
cin >> l>> b;
area = l*b ;
perimeter=2*(l+b);

cout <<” Area is : “<<area;


cout <<” Perimeter is : “<<perimeter;

}
void main()
{
rectangle x;
x. calculate();
getch();
clrscr();
}

Q ) write a program in oops to calculate square of a number

#include< iostream .h>


#include <conio. h>
class square
{
Int a,b
public:
void calculate();
};
void square :: calculate()
{
cout<< “ enter a “;
cin >>a;
b=a*a;
cout <<” Square of a number is :”<<b;
}
void main()
{
rectangle x;
x. calculate();
getch();
clrscr();
}

Q) write a program in oops to calculate the distance from origin to point p(x,y)
#include< iostream .h>
#include <conio. h>
#include <math.h>
class point
{
int x,y;
float d;
public:
void calculate();
};
void point :: calculate()
{
cout<< “ enter x and y coordinate “;
cin >>x>>y;
d=sqrt((x*x)+(y*y));
cout <<” Distance from origin is”<<d;
}
void main()
{
point x;
x. calculate();
getch();
clrscr();
}

Q) write a program in oops to convert temp from cel to fah


#include< iostream .h>
#include <conio. h>
class temperature
{

float c,f;
public:
void calculate();
};
void temperature :: calculate()
{
cout<< “ enter temp in c “;
cin >>c;
f=1.8*c+32;
cout <<” temp in fah is ”<<f;
}
void main()
{
temperature t;
t. calculate();
getch();
clrscr();
}

Q)write a program to calculate the factorial of a number in oops

#include <iostream.h>
#include <conio.h>
class factoial
{
int i , f, n;
public:
void fact();
};
void factorial :: fact()
{
cout<< “ enter a number :”;
cin >> n;
for (i=1 ;i <= n; i++)
{
f =f * i ;
}
cout<< “ factorial of a number is “<< f;
}

void main()
{
factorial x;
x.fact();
getch();
clrscr();
}

Q) to calculate GCD of two numbers


#include <iostream.h>
#include <conio.h>
class GCD
{
int x,y;
public:
void calculate();
};
void GCD :: calculate()
{
cout<< “ enter numbers :”;
cin >> x>>y;
while( x!= y)
{
if (x>y)
x=x-y;
else
y=y-x;
}
cout<< “ GCD is “<< x;
}

void main()
{
GCD g;
g.calculate();
getch();
clrscr();
}

C++ function programs :

Q) find minimum from 4 numbers


#include < iostream.h>
#include<conio.h>
int small(int , int ,int, int );
void main()
{
int a,b,c,d,e;
cout <<” Enter 4 numbers “;
cin > a>>b>>c>>d;
e=small (a,b,c,d);
cout<<” Smallest number is “<< e;
getch();
clrscr();
}
int small (int x,int y, int z, int w)
{
int p;
if( x>y)
p=y;
else
p=x;
if (p>z)
p=z;
if(p>w)
p=w;
return p;
}

Q) to check number is prime or not


# include<iostream .h>
#include <conio.h >
void main()
{
int n, i, f=1;
cout <<” enter a number “;
cin>> n;
for( i=2 ;i < n; i-- )
{
if ( n %i==0)
f=0;
}
if (f==1)
cout <<” the given number is a prime number “;
else
cout<<”the given number is not a prime number “;
getch();
clrscr();
}

Q)to display Fibonacci series


# include<iostream .h>
#include <conio.h >
void main()
{
int n, i,a,b,c;
a=0, b=1;
cout<< “ how many terms u want to display ?’;
cin>> n;
cout<<a<<”\t”<<b;
for ( i=1;i<= n-2 ;i++)
{
c=a+b;
cout<< c;
a=b;
b=c;
}
getch();
clrscr();
}

You might also like