Chapter-4-Data-structure (1) (9 Files Merged)
Chapter-4-Data-structure (1) (9 Files Merged)
CHARACTER Single Dimension Some commonly used linear data structures are Stack, Queue and Linked Lists.
Linear Non-Linear
ii. Non-Linear Data structures:
FLOAT Two Dimension
Stack Trees A Non-Linear Data structures is a data structure in which data item is connected to
POINTERS Multi Dimension several other data items.
Queue Graphs
Non-Linear data structure may exhibit either a hierarchical relationship or parent child
Linked List relationship.
Primitive Data structures:
The data elements are not arranged in a sequential structure.
• Data structures that are directly operated upon the machine-level instructions are known as
The different non-linear data structures are trees and graphs.
primitive data structures.
• The integers, float, character data, pointers are primitive data structures. Operations on Non-Primitive Data structures:
1. Traversing: The processing of accessing each element exactly once to perform some operation is
Operations on Primitive Data structures:
called traversing.
• Create: Create operation is used to create a new data structure. This operation reserves memory
2. Insertion: The process of adding a new element into the given collection of data elements is called
space for the program elements. It may be carried out at compile time and run time.
insertion.
1|Page 2|Page
Chapter 4- Data Structures II PUC, MDRPUC, Hassan Chapter 4- Data Structures II PUC, MDRPUC, Hassan
3. Deletion: The process of removing an existing data element from the given collection of data 1002 C A[2]
elements is called deletion. 1003 D A[3]
4. Searching: The process of finding the location of a data element in the given collection of data 1004 E A[4] Upper Bound(UB)
elements is called as searching.
5. Sorting: The process of arrangement of data elements in ascending or descending order is called • Calculating the length of the array:
sorting. o A[n], the number of n is called the size or length of the array.
6. Merging: The process of combining the elements of two structures to form a single structure is o The length of the array can be calculated by:
called merging. L = UB – LB + 1
o Here, UB is the largest Index and LB is the smallest index
Arrays:
o Example: If an array A has values 10, 20, 30, 40, 50, stored in location 0,1, 2, 3, 4 the UB
• An array is an ordered collection of elements of same data type that share common name.
= 4 and LB=0
• The elements are arranged one after the other in adjacent memory location.
o Size of the array L = 4 – 0 + 1 = 5
• These elements are accessed by numbers called subscripts or indices.
• The elements are accessed using subscripts; arrays are also called as subscripted variables. Basic operations on One-dimensional array: Important
• There are three types of arrays
1. Traversing : Processing each element in the array.
i. One-dimensional Array
2. Insertion : Inserting a new element into the array.
ii. Two-dimensional Array
3. Deletion : Removing an element from the array.
iii. Multi-dimensional Array
4. Searching : Finding the location of an element in the array.
One dimensional array: 5. Sorting : Arranging the elements of the array in some order.
• An array with only one row or column is called one-dimensional array. 6. Merging : Combining one or more array to form a single array.
1001 B A[1]
3|Page 4|Page
Chapter 4- Data Structures II PUC, MDRPUC, Hassan Chapter 4- Data Structures II PUC, MDRPUC, Hassan
Inserting an element into an array: • For example: Let A[4] be an array with items 10, 20, 30, 40, 50 stored at consecutive locations.
• Insertion refers to inserting an element into the array. Suppose item 30 has to be deleted at position 2. The following procedure is applied.
• Based on the requirement, new element can be added at the beginning, end or any given position o Copy 30 to ITEM, i.e. Item = 30.
• When an element is to be inserted into a particular position, all the elements from the asked o Move Number 50 to the position 3.
position to the last element should be shifted into higher order position. A[0] 10 A[0] 10 A[0] 10 A[0] 10
• For example: Let A[5] be an array with items 10, 20, 40, 50, 60 stored at consecutive locations. A[1] 20 A[1] 20 A[1] 20 A[1] 20
Suppose item 30 has to be inserted at position 2. The following procedure is applied. A[2] 30 A[2] A[2] 40 A[2] 40
o Move Number 60 to the position 5. A[3] 40 A[3] 40 A[3] A[3] 50
o Move Number 50 to the position 4. A[4] 50 A[4] 50 A[4] 50 A[4]
o Move Number 40 to the position 3.
o Position 2 is blank. Insert 30 into the position 2 i.e. A[2]=30. ALGORITHM: Delete (A, N, ITEM, Pos) A is an array with N elements. ITEM is the
element to be deleted in the position Pos and it is stored into variable Item.
A[0] 10 A[0] 10 A[0] 10 A[0] 10 A[0] 10
Step 1: ITEM = A [Pos]
A[1] 20 A[1] 20 A[1] 20 A[1] 20 A[1] 20
Step 2: for I = Pos down to N-1
A[2] 40 A[2] 40 A[2] 40 A[2] 40 A[2] 30
A[ I ] = A[I+1]
A[3] 50 A[3] 50 A[3] 50 A[3] A[3] 40
[End of for loop]
A[4] 60 A[4] 60 A[4] A[4] 50 A[4] 50
Step 3: N = N-1
A[5] A[5] A[5] 60 A[5] 60 A[5] 60
Step 4: Exit
ALGORITHM: Insert (A, N, ITEM, Pos) A is an array with N elements. ITEM is the
Searching an element in an array:
element to be inserted in the position Pos.
Step 1: for I = N-1 down to Pos • Searching refers to finding the location of the element in a linear array.
A[ I + 1] = A[I] • There are different algorithms, but the most common methods are linear search and binary search.
Deleting an element into an array: ALGORITHM: Linear_Search (A, N, Element) A is an array with N elements.
• Deletion refers to deleting an element from the array. Element is the being searched in the array.
• Based on the requirement, element can be deleted at the beginning, end or any given position of Step 1: LOC = -1 [Assume the element does not exist]
array. Step 2: for I = 0 to N-1 do
• When an element is to be deleted from a particular position, all the subsequent shifted into lower if ( Element = A [ I ] ) then
order position.
5|Page 6|Page
Chapter 4- Data Structures II PUC, MDRPUC, Hassan Chapter 4- Data Structures II PUC, MDRPUC, Hassan
• Example: Consider the following elements stored in an array and we are searching for the element Sorting the elements in an array:
67. The trace of the algorithm is given below. • Sorting is the arrangement of elements of the array in some order.
MID = • There are different sorting methods like Bubble Sort, Selection Sort, Shell Sort, Quick sort, Heap
BEG & END Compare Location
(BEG+END)/2
Sort, Insertion Sort etc.
A[0] A[1] A[2] A[3] A[4]
67>39
12 23 39 47 57 BEG = 0 MID = (0+4)/2 Insertion Sort:
(Does not LOC = -1
END = 4 MID = 2
BEG MID END match) • In Insertion sort, the first element of the array is assumed to be in the correct position next element
The search element i.e. 67 is greater than the element in the middle position i.e. 39 then is considered as the key element and compared with the elements before the key element and is
continues the search to the right portion of the middle element. inserted in its correct position.
A[0] A[1] A[2] A[3] A[4] • Example: Consider the following array contains 8 elements as follows:
67>47
12 23 39 47 57 BEG = 3 MID = (3+4)/2 A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7]
(Does not LOC = -1
END = 4 MID = 3
BEGMID END match) 45 26 23 56 29 36 12 4
The search element i.e. 67 is greater than the element in the middle position i.e. 47 then
continues the search to the right portion of the middle element.
A[0] A[1] A[2] A[3] A[4]
12 23 39 47 57 67>57
BEG = 4 MID = (4+4)/2
(Does not LOC = -1
BEGMID END = 4 MID = 4
match)
END
The search element i.e. 67 is greater than the element in the middle position i.e. 57 then
continues the search to the right portion of the middle element.
A[0] A[1] A[2] A[3] A[4] ALGORITHM: Insertion_Sort (A, N) A is an array with N unsorted elements.
12 23 39 47 57 BEG = 5 Since the condition (BEG <= END) is
Step 1: for I=1 to N-1
END = 4 false the comparison ends
ENDBEG Step 2: J=I
9|Page 10 | P a g e
Chapter 4- Data Structures II PUC, MDRPUC, Hassan Chapter 4- Data Structures II PUC,, M
MDRPUC, Hassan
• Column-Major Method: All the first column elements are stored in sequential memory locations • The condition TOP = MAXS
XSTX indicates that the
and then all the second-column elements are stored and so on. stack is full and TOP = NULL
LL indicates that stack is
empty.
11 | P a g e 12 | P a g e
Chapter 4- Data Structures II PUC, MDRPUC, Hassan Chapter 4- Data Structures II PUC, MDRPUC, Hassan
o If the top of the stack is opening parenthesis, push operator on stack. • Consider the following examples of converting from infix to prefix.
o If it has higher priority than the top of stack, push operator on stack.
Infix Prefix
Sl No
o Else pop the operator from the stack and output it, repeat step 4.
1 (A+B)*C = [+AB] * C *+ABC
5. If it is a closing parenthesis, pop operators from the stack and output them until an opening
2 A+B+C = [+AB]+C ++ABC
parenthesis is encountered. Pop and discard the opening parenthesis.
6. If there is more input go to step 1. 3 (A+B)/(X–Y) = [+AB]/[-XY] /+AB-XY
7. If there is no more input, pop the remaining operators to output. = [^AB] *C-D
4 A^B*C–D -*^ABCD
= [*^ABC]-D
• Example: Suppose we want to convert 2*3/(2-1)+5*3 into postfix form. = ([+AB]*C-[-DE])^[+XY]
Expression Stack Output 5 ((A + B)*C–(D–E))^(X+Y) =([*+ABC]-[-DE])^[+XY] ^-*+ABC-DE^+XY
2 Empty 2 = (-*+ABC-DE)^[+XY]
* * 2
3 * 23 QUEUES:
/ / 23* • A queue is an ordered collection of items where an item is inserted at one end called the “rear”
( /( 23* and an existing item is removed at the other end, called the “front”.
2 /( 23*2 • Queue is also called as FIFO list i.e. First-In First-Out.
- /(- 23*2 • In the queue only two operations are allowed enqueue and dequeue.
1 /(- 23*21 • Enqueue means to insert an item into back of the queue.
) / 23*21- • Dequeue means removing the front item.
+ + 23*21-/ REAR FRONT
5 + 23*21-/5
Dequeue
* +* 23*21-/5
Enqueue
3 +* 23*21-/53 Types of Queues:
Empty 23*21-/53*+ • Queue can be of four types:
• Consider the following examples of converting from infix to postfix o Simple Queue
Sl No Infix Postfix o Circular Queue
1 (A+B)*C = [AB+] * C AB+C* o Priority Queue
2 A+B+C = [AB+]+C AB+C+ o Dequeue ( Double Ended Queue)
3 (A+B)/(X–Y) = [AB+]/[XY-] AB+XY-/ • Simple Queue: In simple queue insertion occurs at the rear end of the list and deletion occurs at
= [AB^] *C-D the front end of the list.
4 A^B*C–D AB^C*D-
= AB^C*-D Front Rear
= ([AB+]*C-[DE-])^[XY+]
A B C D Front = 1
5 ((A + B)*C–(D–E))^(X+Y) =([AB+C*]-[DE-])^[XY+] AB+C*DE--XY+^
Rear = 4
= (AB+C*DE--)^[XY+] 0 1 2 3 4 5
15 | P a g e 16 | P a g e
Chapter 4- Data Structures II PUC,, M
MDRPUC, Hassan Chapter 4- Data Structures II PUC, MDRPUC, Hassan
• Ci
Circular Queue: A circular queue is a queue
ue in which all nodes are ITEM = QUEUE [FRONT], FRONT = FRONT + 1
treatedd as circular such that the last node follows the fi
first node. Front Rear
• Pr
Priority Queue: A priority queue is a
B C D E Front = 2
queue tha
that contains items that have some Rear = 5
0 1 2 3 4 5
present pr
priority. An element can be inserted
Queue Insertion Operation (ENQUEUE):
or removed from any position
on de
depending upon some priority.
• Consider a queue Q with 5 elements.
• Dequeue: It is a queue in which
hich iinsertion and deletion takes place
Q[0] Q[1] Q[2] Q[3] Q[4] Initially Queue is Empty FRONT = -1, REAR= -1
at the both ends.
• If we want to add one element i.e. 8 in the queue, then FRONT and REAR Indicator are set to 0
and the element 8 would be stored at the position pointed by the REAR.
REAR = 0, FRONT = 0, Q[REAR]=Q[0]=8 Q[0] Q[1] Q[2] Q[3] Q[4]
Operation on Queues: 8
• Queue( ): It creates a new queue that is empty.
• If we want to add one more element i.e. 12 in the queue, then REAR Indicator would be
• enqueue(item): It adds a new
w iitem to the rear of the queue.
incremented by 1 and the element 12 would be stored at the position pointed by the REAR.
• dequeue( ): It removes the front
ront item from the queue.
REAR = 1, FRONT = 0, Q[REAR]=Q[1]=12 Q[0] Q[1] Q[2] Q[3] Q[4]
• isEmpty( ): It tests to see whethe
hether the queue is empty.
8 12
• size( ): It returns the number of items in the queue.
• Repeat this procedure three more times to insert 4, 18 and 34 elements.
Memory Representation
n of a queue using array: REAR = 4, FRONT = 0, Queue is full. Q[0] Q[1] Q[2] Q[3] Q[4]
• Queue is represented in memor
ory using linear array. 8 12 4 18 34
• Let QUEUE is a array, twoo point
pointer variables called FRONT and REAR are re m
maintained.
Algorithm for Insertion:
• The pointer variable FRONT cont moved or deleted.
contains the location of the element to be remove
ALGORITHM: ENQUEUE (QUEUE, REAR, FRONT, ITEM) QUEUE is the array with N
• The pointer variable REAR cont
contains location of the last element inserted.
• The condition FRONT = NULL LL indicates that queue is empty. elements. FRONT is the pointer that contains the location of the element to be deleted and REAR
• The condition REAR = N-11 indi
indicates that queue is full. contains the location of the inserted element. ITEM is the element to be inserted.
Front Rear
Step 1: if REAR = N-1 then [Check Overflow]
PRINT “QUEUE is Full or Overflow”
A B C D Front = 1 Exit
Rear = 4
0 1 2 3 4 5 [End if]
REAR
EAR = R
REAR + 1, QUEUE [REAR] = ‚E€ Step 2: if FRONT = NULL then [Check Whether Queue is empty]
FRONT = 0
Front Rear REAR = 0
else
A B C D E Front = 1 REAR = REAR + 1 [Increment REAR Pointer]
Rear = 5 Step 3: QUEUE[REAR] = ITEM [Copy ITEM to REAR position]
0 1 2 3 4 5
Step 4: Return
17 | P a g e 18 | P a g e
Chapter 4- Data Structures II PUC, MDRPUC, Hassan Chapter 4- Data Structures II PUC, MDRPUC, Hassan
LINKED LIST:
• If we want to delete an element i.e. 12 from the queue, then the value of FRONT will be
incremented by 1 i.e. 2. • A linked list is a linear collection of data elements called nodes.
REAR = 2, FRONT = 2 Q[0] Q[1] Q[2] Q[3] Q[4] • Each nodes is divided into two parts:
ALGORITHM: DEQUEUE (QUEUE, REAR, FRONT, ITEM) QUEUE is the array with N
• In the above figure shows an representation if Linked List with three nodes, each node contains
elements. FRONT is the pointer that contains the location of the element to be deleted and REAR
two parts.
contains the location of the inserted element. ITEM is the element to be deleted.
• The left part of the node represents Information part of the node.
Step 1: if FRONT = NULL then [Check Whether Queue is empty] • The right part represents the next pointer field. That contains the address of the next node.
PRINT “QUEUE is Empty or Underflow” • A pointer START or HEAD gives the location of the first node.
Exit • The link field of the last node contains NULL.
[End if]
Types of Linked List: Important
Step 2: ITEM = QUEUE[FRONT]
Step 3: if FRONT = REAR then [if QUEUE has only one element] • There are three types of linked lists:
FRONT = NULL o Singly Linked List
REAR = NULL o Doubly Linked List
else o Circular Linked List
FRONT = FRONT + 1 [Increment FRONT pointer]
Singly Linked List:
Step 4: Return
• A singly linked list contains two fields in each node - an information field and the linked field.
19 | P a g e 20 | P a g e
Chapter 4- Data Structures II PUC,, M
MDRPUC, Hassan Chapter 4- Data Structures II PUC, MDRPUC, Hassan
o Inserting a node at the end of the linked list. Step 5: link(P1) NULL
Free(P2)
• Inserting a node at the beginning of the linked list
Step 6: STOP
1. Create a node.
2. Fill data into the data field of the new node. Non-Linear Data structures:
3. Mark its pointer field as NULL • A Non-Linear Data structures is a data structure in which data item is connected to several
4. Attach this newly created node to START other data items.
5. Make the new node as the STARTing node. • The data items in non-linear data structure represent hierarchical relationship.
• Each data item is called node.
ALGORITHM: INS_BEG (START, P) START contains the address of the first node.
• The different non-linear data structures are trees and graphs.
Step 1: P new Node;
Step 2: data(P) num; Trees:
Step 3: link(P) START
• A tree is a data structure consisting of nodes organized as a hierarchy.
Step 4: START P
Step 5: Return
Garbage Collection:
• The operating system of the computer periodically collects all the deleted space into the free-
storage list. This technique of collecting deleted space into free-storage list is called as garbage
collection.
• Path: A path is an ordered list of nodes that are connected by edges. In figure path A to O is A, D, CHAPTER – DATA STRUCTURES BLUE PRINT
I, M, O. VSA (1 Marks) LA (3 Marks) Essay (5 Marks) Total
• Height: the height or depth of a tree is defined to be the maximum number of nodes in a branch of 01 Question 01 Question 02 Question 04 Questions
tree. ( The height of tree is 5)
Question No 3 Question No 23 Question No 28 & 29 14 Marks
• Ancestor: A node reachable by repeated proceeding from child to parent. (Ancestor of M is I, D,
and A)
Important Questions
• Descendant: A node reachable by repeated proceedings from parent to child. (Descendent of I are
1 Mark Questions:
(M,O) and N)
• Subtree: A Subtree is a set of nodes and edges comprised of parent and all the descendants of that 1. Definition of Data Structure, Linear Data Structures, Array, Stack, Queue, Linked List,
parent. In figure T1, T2 and T3 are subtrees. Non Linear Data Structures.
2. Definition on Tree, Tree Terminologies, Binary Tree, Complete Binary Tree, Graph.
Binary tree:
3 Marks Questions:
• A binary tree is an ordered tree in which each internal node can have maximum of two child
nodes connected to it. 1. Types of Data Structure, Array, Queue, Linked list.
• A binary tree consists of: 2. Memory Representation of Array, Stack.
o A node ( called the root node) 3. Algorithms – Traverse, Insertion, Deletion, Linear Search, PUSH, POP
o Left and right sub trees. 4. Conversions: Infix to Postfix & Prefix.
5. Advantages/Applications of arrays, stacks, queues
5 Marks Questions:
GRAPH
25 | P a g e 26 | P a g e
Chapter 6- Basic Concept of OOP III P
PUC, MDRPUC, Hassan Chapter 6- Basic Concept of OOP III P
PUC, MDRPUC, Hassan
BAS
BASIC CONCEPT OF OOP • Class is the major concept tha
that plays important role in this approach.
h. C
Class is a template that
represents a group of objectss w
which share common properties and relationshi
onships.
Introduction:
Difference between P
Procedural Programming & Object Oriented
• Object oriented programming
ng is the principle of design and developme
ment of programs using
programming:
modular approach.
• Object oriented programming
ng approach provides advantages in creation
ion and development of Procedural Progra
ogramming Object Oriented Progr
rogramming
software for real life application.
tion.
Large programs are divided
ed iinto smaller
Programs are divided intoo obj
objects
• The basic element of object orie
oriented programming is the data. programs known as functions
tions
• The programs are built by combi
ombining data and functions that operate on the
he da
data. Data is not hidden and can
an be accessed by Data is hidden and cannott be accessed by
• Some of the OOP€s languages
guages aare C++, Java, C #, Smalltalk, Perl, and Python
thon. external functions external functions
Follow top down approach
ch iin the program Follows bottom-up approac
oach in the
Procedural programming
ing: design program design
Objects • Data hiding is a method used in object oriented programming to hide information within computer
Overloading:
• Overloading allows objects to have different meaning depending upon context.
• There are two types of overloading viz.
o Operator Overloading
o Function Overloading
• When an existing operator operates on new data type is called operator overloading.
Classes: • Function overloading means two or more function have same, but differ in the number of
• The objects can be made userr de
defined data types with the help of a class. arguments or data type of arguments.
• A class is a collection of object
objects that have identical properties, common
Polymorphism:
behavior and shared relationsh
onship.
• The ability of an operator and function to take
• Once class is defined, any num
number of objects of that class is created.
multiple forms is known as Polymorphism.
• Classes are user defined data types. A class can hold both data and
• The different types of polymorphism are operator
functions.
overloading and function overloading.
• For example: Planets, sun, moon
oon aare member of class solar system.
Dynamic binding:
Data Abstraction:
• Binding is the process of connecting one program to another.
• Data Abstraction refers too th
the process of representing essential featu
atures without including
• Dynamic binding is the process of linking the procedure call to a specific sequence of code or
background details or explanat
anations.
function at run time or during the execution of the program.
Data Encapsulation:
Message Passing:
• The wrapping of data and fun
functions into a single unit (class) is called
• In OOP€s, processing is done by sending message to objects.
data encapsulation.
• A message for an object is request for execution of procedure.
• Data encapsulation enabless data hiding and information hiding.
3|Page 4|Page
Chapter 6- Basic Concept of OOP II PUC, MDRPUC, Hassan Chapter 6- Basic Concept of OOP II PUC, MDRPUC, Hassan
• Message passing involves specifying the name of the object, the name of the function (message) CHAPTER 6 – Basic Concept of OOP€s BLUE PRINT
and the information to be sent. VSA (1 marks) SA (2 marks) LA (3 Marks) Essay (5 Marks) Total
Important - 01 Question - 01 Question 02 Question
Advantage of OOP€s
- Question No 13 Question No 30 07 Marks
• The programs are modularized based on the principles of classes and objects.
• Linking code & object allows related objects to share common code. This reduces code
Important Questions
duplication and code reusability.
• Creation and implementation of OOP code is easy and reduces software development time. 2 Marks Question:
• The concept of data abstraction separates object specification and object implementation.
• Data encapsulated along with functions. Therefore external non-member function cannot access or 1. Explain: Classes, Objects, Data Abstraction, Data Encapsulation, Inheritance, and
modify data, thus proving data security. Polymorphism.
• Easier to develop complex software, because complexity can be minimized through inheritance. 2. What is Base class and derived class?
• OOP can communicate through message passing which makes interface description with
outside system very simple.
5 Marks Question:
• Larger program size: OOP€s typically involves more lines of code than procedural programs. 2. Explain the characteristics of OOP€s.
• Slower Programs: OOP€s typically slower than procedure based programs, as they typically 3. Briefly explain the basic concepts of OOP€s.
require more instructions to be executed. 4. Explain the advantages of OOP€s.
• Not suitable for all types of programs. 5. Mention disadvantages of OOP€s.
• To convert a real world problem into an object oriented model is difficult.
6. Write the applications of OOP€s.
• OOP€s software development, debugging and testing tools are not standardized.
• Polymorphism and dynamic binding also requires processing time, due to overload of function
calls during run time.
Application of OOP€s
• Computer graphics applications.
• .CAD/CAM software
• Object-oriented database.
• User-Interface design such as windows
• Real-time systems.
• Simulation and Modeling
• Artificial intelligence and expert systems.
• Client-Server Systems.
5|Page 6|Page
Chapter 7- Classes and Objects II PUC, MDRPUC, Hassan Chapter 7- Classes and Objects II PUC, MDRPUC, Hassan
1|Page 2|Page
Chapter 7- Classes and Objects II PUC, MDRPUC, Hassan Chapter 7- Classes and Objects II PUC, MDRPUC, Hassan
3|Page 4|Page
Chapter 7- Classes and Objects II PUC, MDRPUC, Hassan Chapter 7- Classes and Objects II PUC, MDRPUC, Hassan
• An object is a real world element which is identifiable entity with some characteristics (attributes) Accessing member of the class:
and behavior (functions). • The member of the class can be data or functions.
• An object is an instance of a class. Objects are sometimes called as instance variables. • Private and protected members of the class can be accessed only through the member functions of
• An object is normally defined in the main ( ) function. the class.
• The syntax for defining objects of a class as follows: • No functions outside a class can include statements to access data directly.
class Class_Name • The public data members of objects of a class can be accessed using direct member access
{
operator (.).
private : //Members
public : //Members • The syntax of accessing member (data and functions) of a class is:
}; a) Syntax for accessing a data member of the class:
class Class_Name Object_name1, Object_name2,……;
Object_Name . data_member;
where class keyword is optional.
b) Syntax for accessing a member function of the class:
• Example 1: The following program segment shows how to declare and create objects.
Object_Name . member_function(arguments)
class Student
{
private:
int rollno;
char name[20];
char gender;
int age;
public:
void get_data( );
void display( );
};
Student S1, S2, S3; //creation of objects
• Here, creates object S1, S2, and S3 for the class Student.
• When an object is created space is set aside for it in memory.
5|Page 6|Page
Chapter 7- Classes and Objects II PUC, MDRPUC, Hassan Chapter 7- Classes and Objects II PUC, MDRPUC, Hassan
• An array can be used as private or public member of a class. • When a object is declared, memory is reserved for only data members and not for member
11 | P a g e 12 | P a g e
Chapter 7- Classes and Objects II PUC, MDRPUC, Hassan Chapter 7- Classes and Objects II PUC, MDRPUC, Hassan
cout<<”Hours = “<<hh; {
cout<<”Minutes = “<<mm; float dist;
} dist = ( (Ahh * 60 + Amm) – (Dhh * 60 + Dmm) ) * speed/60;
void convert( ) dist = (dist * 1000 / (60 * 60);
{ cout<<”Distance Travelled = “<<dist<<”Meter/Second”;
mm = hh * 60 + mm; }
cout<<”Total Minutes = “<<mm; };
} void main( )
}; {
void main( ) Distance d;
{ clrscr( );
int h, m; d.inputtime( ):
clock c; d.computedistance( );
clrscr( ); getch( );
cout<<”Enter the Hour and Minutes”<<endl; }
cin>>h>>m;
c.intialize( ); **************
c.display( );
c.convert( )
getch( );
}
4. Write a C++ program that receives arrival time and departure time and speed of an
automobile in kilometers/hours as input to a class. Compute the distance travelled in
meters/second and display the result using member functions.
#include<iostream.h>
#include<conio.h>
class Distance
{
private:
int Ahh, Amm, Dhh, Dmm;
float speed;
public:
void inputtime( )
{
cout<<”Enter the Arrival Time:”<<endl;
cout<<”Enter the Hour and Minutes”<<endl;
cin>>Ahh>>Amm;
cout<<”Enter the Departure Time:”<<endl;
cout<<”Enter the Hour and Minutes”<<endl;
cin>>Dhh>>Dmm;
cout<”Enter the speed in Kmph”<<endl;
cin>>speed;
}
void computedistance( )
15 | P a g e 16 | P a g e
Chapter 8- Function Overloading and Member Function II PUC, MDRPUC, Hassan Chapter 8- Function Overloading and Member Function II PUC, MDRPUC, Hassan
• An Inline function is a special type of function whose body is inserted at the place where it is • May increase the size of the executable file
called, instead of transferring the control to the function. • More memory is needed.
• The keyword inline is used to define inline function. • If used in header file, it will make your header file size large and may also make it unreadable.
Important
• Rules:
5 Marks Note: The inline function may not work some times for one of the following reasons:
o Inline function definition starts with keyword inline.
• The inline function definition is too long or too complicated.
o The inline function should be defined before all function that call it.
• The inline function is recursive.
o The compiler replaces the function call statement with the function code itself (expansion)
• The inline function has looping constructs.
and then compiles the entire code.
• The inline function has a switch or goto.
• The general format for the inline function declaration is given below:
inline Returntype Fun_Name ( [Argument] ) Friend Function:
{
• A friend function is a non-member function of a class has the access permission to the private
……….. ;
return expression ; member of the class.
} • The friend function is declared within a class with the prefix friend.
• Program to find the cube of a number using inline function:
• But it should be defined outside the class like a normal function without the prefix friend.
#include<iostream.h>
• The general format for the friend function is given below:
#include<conio.h>
inline int cube ( int a ) class class_name
{
Important
{
return a * a * a;
public:
5 Marks
}
void main( ) friend return_type function_name ( [arguments] );
{ }
int n ; The friend functions have the following properties:
clrscr( );
OUTPUT: • Friend function is not a member function of the class, has full access permission to private and
cout<<”Enter the input number”<<endl;
cin>>n; Enter the input number protected members of the class.
cout<<”Cube of “ <<n<<” = “<<cunbe(n); 4
• It can be declared either in public or private part of a class.
getch(); Cube of 4 = 64
} • A friend function cannot be called using the object of that class. It can be invoked like any normal
function.
Advantage of inline function:
• The function is declared with keyword friend. But while defining friend function it does not use
• The size of the object code is considerably reduced.
either keyword friend or : : operator.
• The speed of execution of a program increases.
• They are normal external functions that are given special access privileges.
• Very efficient code can be generated.
• It cannot access the data member variables directly and has to use an object name.membername.
• There is no burden on the system for function calling.
• Use of friend function is rare, since it violates the rule of encapsulation and data hiding.
• It also saves the overhead of return call from a function.
• The readability of the program increases.
3|Page 4|Page
Chapter 8- Function Overloading and Member Function II PUC, MDRPUC, Hassan Chapter 8- Function Overloading and Member Function II PUC, MDRPUC, Hassan
Program to check a number is even or odd using a friend function. CHAPTER 8 – Function Overloading and Member Function BLUE PRINT
#include<iostream.h> VSA (1 marks) SA (2 marks) LA (3 Marks) Essay (5 Marks) Total
#include<conio.h>
class number - - - 01 Question 01 Question
{ - - Question No 32 05 Marks
private:
int a;
public: Important Questions
void readdata( )
{ 5 Marks Question:
cout<<”Enter the Number”<<endl;
cin>>a; 1. What is function overloading? Explain the need for function overloading.
}
2. Discuss overloaded functions with syntax and example.
friend int even(number);
}; 3. What is inline function? Write a simple program for it.
int even(number n)
{
4. Mention the advantage and disadvantage of inline function.
if(n.a % 2 = = 0) //friend function can access the private data a of the object n 5. Explain friend function and their characteristics.
return 1;
else
OUTPUT: 6. Program to check whether a number is prime or not using inline function:
return 0; Enter the Number #include<iostream.h>
} 10 #include<conio.h>
void main( ) Number is Even inline int prime ( int n )
{ Enter the Number {
number num1; 11 for(int i=2; i<n/2; i++)
clrscr( ); Number is Odd if ( n % i = = 0)
num1.readadata( ); return 0;
if( even(num1) ) //friend function call return 1;
cout<<”Number is Even”; }
else void main( )
cout<<ƒNumber is Odd”; {
getch(); int num ;
} clrscr( );
cout<<”Enter the input number”<<endl;
cin>>num; OUTPUT:
if ( prime(num)) //inline function call Enter the input number
cout<<”Number is Prime “ ;
5
else
cout<<”Number is not a Prime “ ; Number is Prime
getch();
}
5|Page 6|Page
Chapter 11- Pointers II PUC, MDRPUC, Hassan Chapter 11- Pointers II PUC, MDRPUC, Hassan
var”. o Subtraction -
Example: Example:
int num = 25; int num, *iptr; iptr 1200 9
int *iptr; num = 9; 1201
iptr = # //The address of operator & iptr = # iptr++ 1202
iptr++; 1203
Pointer Operator or Indirection Operator (*):
cout<<iptr;
The second operator is indirection operator „*‟, and it is the complement of „&‟.
The following operation can be performed on pointers.
It is a unary operator that returns the value of the variable located at the address specified by its
o We can add integer value to a pointer.
operand.
o We can subtract an integer value from a pointer.
Example: o We can compare two pointers, if they point the elements of the same array.
int num = 25; o We can subtract one pointer from another pointer if both point to the same array.
int *iptr; //Pointer Operator (Indirection Operator *) o We can assign one pointer to another pointer provided both are of same type.
iptr = #
The following operations cannot be performed on pointers.
Example: A program executes the two operations. o Addition of two pointers.
#include<iostream.h> o Subtraction of one pointer from another pointer when they do not point to the same array.
#include<conio.h>
void main( ) o Multiplication of two pointers.
{ o Division of two pointers.
int num; A program to illustrate the pointer expression and pointer arithmetic.
int *iptr;
#include<iostream.h>
int val;
#include<conio.h>
void main( )
num = 300;
{ OUTPUT:
iptr = & num;
int a, b, x, y; Address of a = 65524
val = *iptr; OUTPUT: int *ptr1, *ptr2; Address of b = 65522
Value of num is : 300 a = 30;
cout<<” Value of num is :”<<num<<endl; a = 30 b=6
Value of pointer : 0xbff64494 b = 6;
cout<<” Value of pointer :”<<iptr<<endl; ptr1 = &a x = 30 y=6
cout<<” Value of val :”<<val<<endl; Value of val : 300 ptr2 = &b; a = 100 b = 12
} x = *ptr1 + *ptr2 – 6;
y = 6 - *ptr1 / *ptr2 + 30;
Pointer Arithmetic:
We can perform arithmetic operations on a pointer just as you can a numeric value. cout<<”Address of a = “<<ptr1<<endl;
cout<<”Address of b = “<<ptr2<<endl;
There are four arithmetic operators that can be used on pointers:
cout<<”a = “<<a<<”b = “<<b<<endl;
o Increment ++ cout<<”x = “<<x<<”y = “<<y<<endl;
o Decrement --
*ptr1 = *ptr1 + 70;
o Addition + *ptr2 = *ptr2 * 2;
When we declare an array, its name is treated as a constant pointer to the first element of the The general form of array of pointers declaration is:
This is also known as the base address of the array. The above statement declares an array of 5 pointers where each of the pointer to integer variable.
In other words base address is the address of the first element in the array of the address of a[0]. Example: Program to illustrate the array of pointers of isolated variables.
The difference between constant pointer and the pointer variable is that the constant pointer
Pointers and strings:
cannot be incremented or changed while the pointer to an array which carries the address of the
String is sequence of characters ends with null („\0‟) character.
first element of the array may be incremented.
C++ provides two methods of declaring and initializing a string.
The following example shows the relationship between pointer and one dimensional array.
Method 1:
#include<iostream.h>
char str1[ ] = “HELLO”;
void main( )
{ When a string is declared using an array, the compiler reserves one element longer than the
number of characters in the string to accommodate NULL character. For Example: int m = 23;
The string str1[ ] is 6 bytes long to initialize its first 5 characters HELLO\0. int &n = m;
Method 2: int *p;
char *str2 = “HELLO”; p = &m;
C++ treats string constants like other array and interrupts a string constant as a pointer to the first Then the value of m i.e. 23 is printed in the following ways :
character of the string. cout <<m; // using variable name
This means that we can assign a string constant to a pointer that point to a char. cout << n; // using reference name
Example: A program to illustrate the difference between strings as arrays and pointers. cout << *p; // using the pointer
#include<iostream.h>
Invoking Function by Passing the References :
#include<conio.h>
void main( ) When parameters are passed to the functions by reference, then the formal parameters become
{ references (or aliases) to the actual parameters to the calling function.
char str1[ ] = “HELLO”; OUTPUT: That means the called function does not create its own copy of original values, rather, it refers to
char *str2 = “HELLO”;
HELLO the original values by different names i.e. their references.
cout<<str1<<endl;
HELLO
cout<<str2<<endl; For example the program of swapping two variables with reference method:
str2++; ELLO
#include<iostream.h>
cout<<str2<<endl;
void main()
}
{
Pointers as Function Parameters: void swap(int &, int &);
A pointer can be a parameter. It works like a reference parameter to allow change to argument int a = 5, b = 6;
from within the function. cout << “\n Value of a :” << a << “ and b :” << b;
swap(a, b);
void swap(int *m, int *n) cout << “\n After swapping value of a :” << a << “and b :” << b;
{ }
int temp; void swap(int &m, int &n)
temp = *m;
{
*m = *n; int temp; OUTPUT:
*n = temp; temp = m; Value of a : 5 and b : 6
} m = n;
void swap(&num1, & num2); After swapping value of a : 6 and b : 5
n = temp;
Pointers and Functions: }
A function may be invoked in one of two ways : Invoking Function by Passing the Pointers:
o Call by value When the pointers are passed to the function, the addresses of actual arguments in the calling
Important
o Call by reference function are copied into formal arguments of the called function.
3 Marks
The second method call by reference can be used in two ways : That means using the formal arguments (the addresses of original values) in the called function;
o By passing the references we can make changing the actual arguments of the calling function.
o By passing the pointers For example the program of swapping two variables with Pointers :
Reference is an alias name for a variable. #include<iostream.h>
7|Page Keerthi Kumar H M 8|Page Keerthi Kumar H M
Chapter 11- Pointers II PUC, MDRPUC, Hassan Chapter 11- Pointers II PUC, MDRPUC, Hassan
void main() The following code demonstrates how to allocate memory for different variables.
{
To allocate memory type integer
void swap(int *m, int *n);
int a = 5, b = 6; int *pnumber;
cout << “\n Value of a :” << a << “ and b :” << b; pnumber = new int;
swap(&a, &b); The first line declares the pointer, pnumber. The second line then allocates memory for an integer
cout << “\n After swapping value of a :” << a << “and b :” << b;
} and then makes pnumber point to this new memory.
void swap(int *m, int *n) To allocate memory for array, double *dptr = new double[25];
{ To allocates dynamic structure variables or objects, student sp = new student;
int temp; OUTPUT:
temp = *m; Value of a : 5 and b : 6 delete Operator:
*m = *n;
After swapping value of a : 6 and b : 5 The delete operator is used to destroy the variables space which has been created by using the
*n = temp;
} new operator dynamically.
Memory Allocation of pointers: Use delete operator to free dynamic memory as : delete iptr;
Memory Allocation is done in two ways: To free dynamic array memory: delete [] dptr;
Important
o Static Allocation of memory To free dynamic structure, delete structure;
3 Marks
o Dynamic allocation of memory.
Difference between Static Memory Allocation and Dynamic Memory Allocation:
Static Allocation of Memory:
Sl no Static Memory Allocation Dynamic Memory Allocation
Static memory allocation refers to the process of allocating memory during the compilation of the
Memory space is allocated before the Memory space is allocated during the
program i.e. before the program is executed. 1
execution of program. execution of program.
Example:
2 Memory space allocated is fixed Memory space allocated is not fixed
int a; // Allocates 2 bytes of memory space during the compilation.
3 More memory space is required Less memory space is required.
Dynamic Allocation of Memory: 4 Memory allocation from stack area Memory space form heap area.
Dynamic memory allocation refers to the process of allocating memory during the execution of
Free store (Heap memory):
the program or at run time.
Free store is a pool of memory available to allocated and de-allocated storage for the objects
Memory space allocated with this method is not fixed.
during the execution of the memory.
C++ supports dynamic allocation and de-allocation of objects using new and delete operators.
These operators allocate memory for objects from a pool called the free store. Memory Leak:
The new operator calls the special function operator new and delete operators call the special If the objects, that are allocated memory dynamically, are not deleted using delete, the memory
function operator delete. block remains occupied even at the end of the program.
new operator: Such memory blocks are known as orphaned memory blocks.
We can allocate storage for a variable while program is running by using new operator. These orphaned memory blocks when increases in number, bring adverse effect on the system.
This situation is called memory leak.
It is used to allocate memory without having to define variables and then make pointers point to
them.
9|Page Keerthi Kumar H M 10 | P a g e Keerthi Kumar H M
Chapter 11- Pointers II PUC, MDRPUC, Hassan Chapter 11- Pointers II PUC, MDRPUC, Hassan
cout<<”Employee Number:”<<empno;
cout<<”Employee Name:”<<name;
cout<<”Employee Salary:”<<salary;
Pointers and Structures: }
We can create pointers to structures variable. };
void main( )
struct student
{
{ employee e, * ep;
int roll_no; ep = &e;
clrscr( );
float fee;
ep read( );
}; ep display ( );
student s; getch( );
student * sp = &s; }
Here, employee is an already defined class. When accessing members of the class an object
(*sp).roll_no = 14;
pointer, the arrow operator () is used instead of dot (.) operator.
The above statement can be written using the operator as
sproll_no = 14; this pointers:
Every object in C++ has access to its own address through an important pointer called this
Pointers and Objects:
Important pointer.
The Pointers pointing to objects are referred to as object pointers.
3 Marks The “this pointer” is an implicit parameter to all member functions.
Declaration of pointers to object
Therefore, inside a member function, this may be used to refer to the invoking object.
class_name * object-pointer;
Here class_name is the name of the class, object-pointer is the pointer to an object of this class
Program 12: Create a class containing the following data members Register_No, Name and
type.
Fees. Also create a member function to read and display the data using the concept of pointers to
Example: employee * eptr
objects.
#include<iostream.h>
#include<conio.h> #include<iostream.h>
class employee #include<conio.h>
class Student
{
{
private:
private:
int empno; long regno;
char name[20]; char name[20];
float salary; float fees;
public: public:
void read( ) void readdata( );
{ void display( );
cout<<”Enter the Employee Number, Name and Salaray”<<endl; };
cin>>empno>>name>>salary; void Student::readdata( )
} {
cout<<"Enter the Register Number:"<<endl;
void display( )
cin>>regno;
{
11 | P a g e Keerthi Kumar H M 12 | P a g e Keerthi Kumar H M
Chapter 11- Pointers II PUC, MDRPUC, Hassan Chapter 11- Pointers II PUC, MDRPUC, Hassan
****************
Important Questions
1 Marks Question:
1. Define pointer. [June 2016]
2. Write the declaration syntax for a pointer. [March 2015]
3. How do we initialize a pointer? [March 2016]
4. Write any one advantage of pointers. [June 2015, March 2017]
5. What is the purpose of new operator in C++? [June 2017]
6. What is a pointer variable?
Stream in C++:
A stream is sequence of bytes. In C++, a stream is a general name given to flow of data.
Different streams are used to represent different kinds of data flow.
The three streams in C++ are as follows.
Classes for file stream operation:
o Input Stream: The stream that supplies data to the program is known as input stream.
o Output Stream: The stream that receives data from the program is known as output Class Meanings
stream. filebuf It sets the file buffer to read and write
o Error Stream: Error streams basically an output stream used by the programs to the file or It supports operations common to the file streams. It serves as a base class for the
on the monitor to report error messages. fstreambase derived classes ifstream,ofstream and fstream and contains open( ) and close( )
as member functions
It supports input operations. It contains open( ) with default input mode and
ifstream
inherits get( ), getline( ), read( ), seekg( ) and tellg( ) functions from istream.
It supports output operations. It contains open( ) with default output mode and
ofstream
inherits put( ), seekp( ), tellp( ) and write( ) functions from ostream
It supports simultaneous input and output operations. It contains open( ) with
fstream default input mode and inherits all the functions from istream and ostream
classes through iostream
Text Files: The syntax of opening a file for output purpose only using an object ofstream class and open( )
o A text file is a file that stores the information in ASCII characters. member function is as follows:
o Each line of text is terminated by a special character, known as End of Line (EOL) or delimiter. oftream_object.open(“file name”);
Binary Files: Example: ofstream outfile;
o A binary file is a file that contains information in the same format as it is held in memory. outfile.open (“data”);
o In binary files, no delimiters are used for a line and no translations occur here. outfile.open (“text.dat”);
The syntax of opening a file for input purpose only using an object ifstream class and open( )
Opening and Closing of Files:
member function is as follows:
A file must first be opened before data can be read from it or written to it.
iftream_object.open(“file name”);
In C++ there are two ways to open a file with the file stream object.
Example: ifstream ifile;
o Opening file using constructor.
ifile.open (“data”);
o Opening file using open ( ) member function.
The first method is preferred when a single file is used with a stream. However for managing To open a file for both input and output, we declare objects of fstream class. We know that the
multiple files with the same stream, the second method is preferred. class fstream is derived from both ifstream and ofstream,
The syntax for opening a file an object of type fstream class and the constructor is as follows:
Opening files using Constructors:
fstream fstream-object(“file name’, mode);
In order to access a file, it has to be opened either in read, write or append mode.
The syntax for opening a file an object of type fstream class and the open( ) member function is as
In all the three file stream classes, a file can be opened by passing a filename as the first parameter follows:
in the constructor itself. fstream-object.open(“file name’, mode); Important
The syntax for opening a file using constructor is 3 Marks
streamclass_name file_objectname (“filename”) File Modes:
The syntax of opening a file for output purpose only using an object ofstream class and the While using constructors or open( ), the files were created or opened in the default mode.
constructor is as follows: There was only one argument passed, i.e. the filename.
ofstream ofstream_object(“file name”); C++ provides a mechanism of opening a file in different modes in which case the second
Example: ofstream fout (“results.dat”); parameter must be explicitly passed.
The syntax of opening a file for input purpose only using an object ifstream class and the Syntax: stream_object.open(“filename”, mode);
constructor is as follows: Example: fout.open(“data”, ios::app) // This opens the file data in the append mode.
ifstream ifstream_object(“file name”); The lists of file modes are:
Example: ifstream fin (“results.dat”);
Mode method Meaning Stream Type
Opening files using open( ): ios::app append to end of the file at opening time ofstream
open( ) can be used to open multiple files that use the same stream object. ios::in open file for reading ifstream
The syntax for opening a file using open ( ) member function is as follows: ios::out open file for writing ofstream
file_stream_class stream_object; Open file for updating and move the file
ios::ate ifstream
stream_object.open (“file_name”); pointer to the end of file
ios::trunc On opening, delete the contents of file ofstream Syntax: ifstream_object.get (ch); // where ch is the character variable.
ios::nocreate Turn down opening if the file does not exists ofstream Example: char ch;
ios::noreplace Turn down opening if the file already exists ofstream ifstream fin(“text.txt”);
ios::binary Opening a binary file. ifstream fin.get (ch);
fin is the object of ifstream. Text is the name of the file. Reads a character into the variable ch.
Example:
fstreamfout (“text”, ios::out); // open text in output mode getline( ):
fstream fin(“text”, ios::in); // open text in input mode It is used to read a whole line of text. It belongs to the class ifstream.
fout.open(“data”, ios::app) // This opens the file data in the append mode Syntax: fin.getline(buffer, SIZE)
fout.open(“data”, ios::app | ios::nocreate) It reads SIZE characters from the file represented by the object fin or till the new line character is
// This opens the file in the append mode but fails to open if it does not exist encountered, whichever comes first into the buffer.
Closing File: Example:
The member function close( ) on its execution removes the linkage between the file and the stream char book[SIZE];
object. ifstream fin;
Example: ofstream.close( );
Input and output operation in binary files:
ifstream.close( );
Binary files are very much use when we have to deal with database consisting of records.
Input and output operation in text file: The binary format is more accurate for storing the numbers as they are stored in the exact internal
The data in text files are organized into lines with new line character as terminator. representation.
Text file need following types of character input and output operations: There is no conversion while saving the data and hence it is faster.
o put( ) function Important Functions used to handle data in binary form are: Important
o get( ) function 3 Marks o write ( ) member function. 3 Marks
put ( ): o read ( ) member function
The put( ) member function belongs to the class ofstream and writes single character to the
write ( ):
associated stream.
The write ( ) member function belongs to the class ofstream and which is used to write binary data
Syntax: ofstream_object.put(ch); // where ch is the character variable.
to a file.
Example: char ch=’A’;
Syntax: ofstream_object.write((char *) & variable, sizeof(variable));
ofstream fout(“text.txt”);
These functions take 2 arguments. The first is the address of the variable and second the size of the
fout.put (ch);
variable in bytes. The address of the variable must be type casted to pointer to character.
fout is the object of ofstream. Text is the name of the file. Value at ch is written to text.
Example: student s;
get( ): ofstream fout(“std.dat”, ios::binary);
The get( ) member function belong to the class ifstream and reads a single character from the fout.write((char *) &s, sizeof(s));
associated stream.
} functions.
This is used to execute set statements on reaching the end of the file by the object fin. o seekg() - Moves get file pointer to a specific location
o seekp() - Moves put file pointer to a specific location
Important
File pointers and their manipulation: o tellg() - Returns the current position of the get pointer
3 Marks
In C++, the file I/O operations are associated with the two file pointers: o tellp() - Returns the current position of the put pointer
o Input pointer (get pointer) The seekp() and tellp() are member functions of ofstream
o Output pointer (put pointer) The seekg() and tellg() are member functions of ifstream.
We use these pointers to move through files while reading or writing. All four functions are available in the class fstream.
Each time an input or output operation takes place, appropriate pointer is automatically advanced.
seekg( ):
o ifstream, like istream, has a pointer known as get pointer that points to the element to be read
Move the get pointer to a specified location from the beginning of a file.
in the next input operation.
There are two types:
o ofstream, like ostream, has a pointer known as put pointer that points to the location where the
o seekg(long);
next element has to be written.
o seekg(offset, seekdir);
There are three modes under which we can open a file:
The seekg(long) moves the get pointer to a specified location from the beginning of a file.
o Read only mode
7|Page Keerthi Kumar H M 8|Page Keerthi Kumar H M
Chapter 12- Data File Handling II PUC, MDRPUC, Hassan Chapter 12- Data File Handling II PUC, MDRPUC, Hassan
Example: inf.seekg(20); object.seekp(m, ios::beg) Move forward by m bytes from the beginning for writing
object.seekp(-m, ios::end) Go backward by m bytes from the end for writing
The seekg(offset, seekdir) has two arguments: offset and seekdir.
The offset indicates the number of bytes the get pointer is to be moved from seekdir position. tellg ( ) and tellp( ):
seekdir takes one of the following three seek direction constants. tellg( ) returns the current position of the get pointer.
Syntax: position = ifstream_object.tellg( );
Constant Meaning
Example: int position
ios::beg seek from beginning of file position= fin.tellg();
ios::cur seek from current location
tellp( ) returns the current position of the put pointer.
ios::end seek from end of file
Syntax: position = ifstream_object.tellp( );
Syntax: stream_objectname.seekg(offset, origin_value); Example: int position
Example : Some of the pointer offset calls and their actions are shown in the following table position= fin.tellp();
seekg( ) function option Action performed
object.seekg(0, ios::beg) Take get pointer to the beginning of the file Basic operation on binary file in C++:
object.seekg(0, ios::end) Go to end of the file Basic operation on binary file is:
object.seekg(m, ios::beg) Move forward by (m+1) bytes in the file o Appending data
object.seekg(-m, ios::end) Go backward by m bytes from the file end. o Inserting data in sorted files
o Deleting a record
seekp ( ): o Modifying data
Move the put pointer to a specified location from the beginning of a file.
There are two types: CHAPTER 12 – DATA FILE HANDLING BLUE PRINT
o seekp(long); VSA (1 marks) SA (2 marks) LA (3 Marks) Essay (5 Marks) Total
o seekp(offset, seekdir); - 01 Question 01 Question - 02 Question
The seekp(long) moves the put pointer to a specified location from the beginning of a file. - Question no 15 Question no 23 - 05 Marks
Example: inf.seekp(20);
Important Questions
The seekp(offset, seekdir) has two arguments: offset and seekdir.
2 Marks Question:
The offset indicates the number of bytes the put pointer is to be moved from seekdir position.
1. Differentiate between ifstream and ofstream. [March 2015]
Syntax: stream_objectname.seekp(offset, origin_value);
2. What is a stream? Mention any one stream used in C++. [June 2015]
seekp( ) function option Action performed 3. Write any two member functions belonging to of stream class. [March 2016]
object.seekp(0, ios::beg) Go to beginning of the file for writing 4. Write any two member functions belonging to if stream class. [June 2016]
object.seekp(0, ios::end) Go to end of the file for writing 5. Differentiate between read( ) and write( ). [March 2017]
object.seekp(0, ios::cur) Stay at the current position for writing 6. Differentiate between put( ) and get( ) functions with reference to binary files. [June 2017]
Why SQL?
Allows users to create and drop databases and tables.
Allows users to describe the data.
Allows users to define the data in database and manipulate that data.
Allows users to access data in relational database management systems.
Allows embedding within other languages using SQL modules, libraries & pre-compilers.
Allows users to set permissions on tables, procedures, and views
SQL Architecture:
When you are executing an SQL command for any RDBMS, the system determines the best way
to carry out your request and SQL engine figures out how to interpret the task.
There are various components included in the process.
These components are:
o Query Dispatcher
o Optimization Engines
o Classic Query Engine
o SQL Query Engine, etc.
Classic query engine handles all non-SQL queries
but SQL query engine won't handle logical files.
Simple diagram showing SQL Architecture:
11 | P a g e Keerthi Kumar H M
1|Page Keerthi Kumar H M
Chapter 14- SQL Commands II PUC, MDRPUC, Hassan Chapter 14- SQL Commands II PUC, MDRPUC, Hassan
DML - Data Manipulation Language: 2 CHAR A variable length field up to 255 character in length
DML provides the data manipulation techniques like selection, insertion, deletion, updation, 3 VARCHAR/VARCHAR2 A variable length field up to 2000 character in length
modification, replacement, retrieval, sorting and display of data or records. A fixed length field. The time is stored as a part of the
4 DATE/TIME
DML facilitates use of relationship between the records. date. The default format is DD/MON/YY
DML provides for independence of programming languages by supporting several high-level 5 LONG A variable length filed up to 2 GB in length
programming languages like COBOL, PL/1 and C++. A variable length filed used for binary data up to 2000
6 RAW
Few of the basic commands for DML are: in length
A variable length filed used for binary data up to 2GB
Command Description 7 LONG RAW
in length
SELECT Retrieves certain records from one or more tables
1. NUMBER:
INSERT Creates a record
o Used to store a numeric value in a field column.
UPDATE Modifies records
o It may be decimal, integer or real value.
DELETE Deletes records
o General syntax: NUMBER(n, d)
o Where n specifies the number of digits and d specifies the number of digits to right of the SELECT, FROM and WHERE are keywords.
decimal point. The clauses are “FROM student” and “WHERE RegNo=109”.
o Example: marks NUMBER(3), average NUMBER(2, 3) Here SELECT and FROM are mandatory, but WHERE is optional.
2. CHAR: Name, Student, RegNo, are identifier that refers to objects in the database.
o Used to store a character type data in a column. Name and RegNo are column names, while Student is a table name.
o General syntax: CHAR(size) The equal sign is an operator and 109 is a numeric constant.
o Where size represents the maximum (255 Characters) number of characters in a column.
o Example: name CHAR(15) What is an Operator in SQL?
3. VARCHAR/VARCHAR2: An operator is a reserved word or a character used primarily in an SQL statement's WHERE
o It is used to store variable length alphanumeric data. clause to perform operation(s), such as comparisons and arithmetic operations.
o General syntax: VARCHAR(size) / VARCHAR2(size) Operators are used to specify conditions in an SQL statement and to serve as conjunctions for
o Where size represents the maximum (2000 Characters) number of characters in a column. multiple conditions in a statement.
o Example: address VARCHAR2(50) o Arithmetic operators (+, -, *, / %)
4. DATE: o Comparison operators (>, <, >=, <=, =, !=, <>, !<, !>)
o It is used to store date in columns. o Logical operators (AND, OR, NOT, IN, BETWEEN, EXISTS, ALL, ANY, LIKE, UNIQUE)
o SQL supports the various date formats other than the standard DD-MON-YY.
SQL Logical Operators:
o Example: dob DATE
5. TIME: Here is a list of all the logical operators available in SQL.
o SQL supports the various time formats other than the standard hh-mm-ss. ALL The ALL operator is used to compare a value to all values in another value set.
o Every DATE and TIME can be added, subtracted or compared as it can be done with other The AND operator allows the existence of multiple conditions in an SQL statement's
AND
WHERE clause.
data types.
The ANY operator is used to compare a value to any applicable value in the list according
6. LONG: ANY
to the condition.
1. It is used to store variable length strings of up to 2GB size.
The BETWEEN operator is used to search for values that are within a set of values, given
2. Example: description LONG BETWEEN
the minimum value and the maximum value.
Structure of SQL command: The EXISTS operator is used to search for the presence of a row in a specified table that
EXISTS
Any SQL command is a combination of keywords, identifiers and clauses. meets certain criteria.
Every SQL command begins with a keyword (CREATE, SELECT, DELETE and so on) which as The IN operator is used to compare a value to a list of literal values that have been
IN
specified.
a specific meaning to the language.
LIKE The LIKE operator is used to compare a value to similar values using wildcard operators.
The NOT operator reverses the meaning of the logical operator with which it is used. Eg:
NOT
NOT EXISTS, NOT BETWEEN, NOT IN, etc. This is a negate operator.
The OR operator is used to combine multiple conditions in an SQL statement's WHERE
OR
clause.
IS NULL The NULL operator is used to compare a value with a NULL value. It creates an empty STUDENT table which looks like this:
The UNIQUE operator searches every row of a specified table for uniqueness (no RegNo Name Combination DOB Fees
UNIQUE
duplicates). Viewing the table information:
o The DESCRIBE or DESC command displays name of the columns, their data type and size
Implementation of SQL Commands
along with the constraints.
CREATE TABLE
The SQL CREATE TABLE statement is used to create a new table.
Creating a basic table involves naming the table and defining its columns and each column's data
type.
Syntax: Basic syntax of CREATE TABLE statement is as follows:
ALTER Statement:
CREATE TABLE Table_name
( The table can be modified or changed by using the ALTER command.
column1 datatype,
column2 datatype, Syntax: Basic syntax of ALTER TABLE statement is as follows:
column3 datatype, 1. ALTER TABLE Table_name
.....
ADD (column_name1 DataType, Cloumn_name2 DataType……);
columnN datatype,
PRIMARY KEY( one or more columns ) 2. ALTER TABLE Table_name
); MODIFY (column_name1 DataType, Cloumn_name2 DataType……);
o Here CREATE TABLE is the keyword followed by the Table_name, followed by an open
3. ALTER TABLE Table_name
parenthesis, followed by the column names and data types for that column, and followed by a
DROP (column_name1 DataType, Cloumn_name2 DataType……);
closed parenthesis.
Example:
o For each column, a name and a data type must be specified and the column name must be a
unique within the table definition.
o Column definitions are separated by commas (,).
o Uppercase and lowercase letters makes no difference in column names.
o Each table must have at least one column.
o SQL commands should end with a semicolon (;).
Using the ALTER TABLE command the following tasks cannot be performed
Example: Create a table “STUDENT” that contains five columns: RegNo, Name, Combination,
o Changing a table name.
DOB and Fees.
o Changing the column name.
CREATE TABLE STUDENT
( o Decreasing the size of a column if table data exists.
RegNo NUMBER (6), o Changing a column‟s data type.
Name VARCHAR2 (15),
Combination CHAR (4), DROP TABLE:
DOB DATE,
Fees NUMBER (9, 2), The SQL DROP TABLE statement is used to remove a table definition and all data, indexes,
PRIMARY KEY ( RegNo ) triggers, constraints, and permission specifications for that table.
); Syntax: Basic syntax of DROP TABLE statement is as follows:
DROP TABLE Table_name; SQL> INSERT INTO STUDENT (REGNO, COMBINATION,FEES) VALUES(1412,
'PCMB',21000);
Example: 1 row created.
All the above statements would produce the following records in STUDENT table:
INSERT:
The SQL INSERT INTO Statement is used to add new rows of data to a table in the database.
Syntax:
There are two basic syntaxes of INSERT INTO statement as follows:
Example:
METHOD 2: The SQL INSERT INTO syntax would be as follows: SQL> DELETE STUDENT WHERE REGNO=1412;
SQL> INSERT INTO STUDENT (REGNO, NAME, FEES) VALUES (1411, 'SHREYA',24000); 1 row deleted.
1 row created.
8|Page Keerthi Kumar H M 9|Page Keerthi Kumar H M
Chapter 14- SQL Commands II PUC, MDRPUC, Hassan Chapter 14- SQL Commands II PUC, MDRPUC, Hassan
SELECT: There may be a situation when you have multiple duplicate records in a table. While fetching such
SQL SELECT statement is used to fetch the data from a database table which returns data in the records, it makes more sense to fetch only unique records instead of fetching duplicate records.
form of result table. These result tables are called result-sets. Syntax: The basic syntax of DISTINCT keyword to eliminate duplicate records is as follows:
Syntax: The basic syntax of SELECT statement is as follows: SELECT DISTINCT column1, column2,.....columnN
SELECT column1, column2, columnN Compulsory FROM Table_name
FROM Table_name; Part WHERE [condition]
[WHERE condition(s)]
Example: Consider the STUDENT table having the following records:
[GROUPBY column-list] Optional
[HAVING condition(s)] Part
[ORDER BY column-name(s)];
Here, column1, column2...are the fields of a table whose values you want to fetch. If you want to
fetch all the fields available in the field, then you can use the following syntax:
Now, let us use DISTINCT keyword with the above SELECT query and see the result:
The WHERE clause is not only used in SELECT statement, but it is also used in UPDATE, You can combine N number of conditions using AND operator. For an action to be taken by the
DELETE statement, etc., which we would examine in subsequent chapters. SQL statement, whether it be a transaction or query, all conditions separated by the AND must be
Syntax: The basic syntax of SELECT statement with WHERE clause is as follows: TRUE.
SELECT column1, column2, columnN Example: Consider the STUDENT table having the following records:
FROM Table_name
WHERE [condition]
You can specify a condition using comparison or logical operators like >, <, =, LIKE, NOT, etc.
Following is an example which would fetch REGNO, NAME and FEES fields from the
STUDENT table where FEES is greater than 15000:
Following is an example, which would fetch REGNO, NAME and DOB fields from the
STUDENT table where fees is less than 1500 AND combination is „PCMC:
Following is an example, which would fetch REGNO, NAME and COMBINATION fields from
the STUDENT table for a COMBINATION is „PCMC‟.
Here, it is important to note that all the strings should be given inside single quotes ('') where as
numeric values should be given without any quote as in above example: The OR Operator:
The OR operator is used to combine multiple conditions in an SQL statement's WHERE clause.
The AND Operator: Following is an example, which would fetch REGNO, NAME and DOB fields from the
STUDENT table where fees is less than 1500 OR combination is „PCMC:
The AND operator allows the existence of multiple conditions in an SQL statement's WHERE
clause.
Syntax: The basic syntax of AND operator with WHERE clause is as follows:
[ORDER BY column1, column2, .. columnN] [ASC | DESC]; For example, when a calculation is to be performed such as 10*3, 10/2 etc. and to display the
current system date, we could use the following queries.
You can use more than one column in the ORDER BY clause. Make sure whatever column you
are using to sort, that column should be in column-list.
Example: Consider the STUDENT table having the following records:
SQL Functions:
The SQL functions serve the purpose of manipulating data items and returning a result.
There are many built in functions included in SQL and can be classified as Group Functions and
Scalar Functions.
Group Functions:
Following is an example, which would sort the result in ascending order by NAME: o Functions that act on set of values are called group functions.
o A group functions can takes entire column of data as its arguments and produces a single
data item that summarizes the column.
o Following are the SQL group functions.
Function Description
AVG Returns average value of „N‟, ignoring NULL values
COUNT(expr) Returns the number of rows where „expr‟ is not NULL
Returns the number of rows in the table including duplicates and those with
COUNT(*)
Following is an example, which would sort the result in descending order by NAME: NULL values
MIN Returns minimum value of „expr‟
MAX Returns maximum value of „expr‟
SUM Returns sum of values „N‟
Scalar Functions:
o Functions that act on only one value at a time are called scalar functions.
o We can further classify the functions using the type of data with they are designed to work.
o SELECT COUNT (RegNo) FROM EXAMINATION WHERE CC = „C3‟ ; GROUP BY column1, column2
Example 1: To find the number of students in each college. Example: Consider the following CREATE TABLE command creates a new table called
SELECT CC, COUNT (CC) PRODUCT and add six columns, two which PID and Description specify not to accept NULLs.
FROM EXAMINATION CREATE TABLE PRODUCT
GROUP BY CC; (
Example 2: To find the number of students, sum, average, maximum, minimum marks in PID CHAR (4) NOT NULL,
computer science from each city. Description VARCHAR2 (25), NOT NULL
SELECT City, COUNT (City), SUM (Cs), AVG (Cs), MAX (Cs), MIN (Cs) CompanyId CHAR (10),
FROM EXAMINATION DOM DATE,
GROUP BY City; Type CHAR (10),
Price NUMBER (10,2)
SQL CONSTRAINTS: );
These are limiting the type of data that can go into a table. This constraint ensures that no rows have the same value in the specified column(s). A table must
have many unique keys.
This ensures the accuracy and reliability of the data into the database.
Example: UNIQUE constraint applied on PID of PRODUCT table ensures that no rows have the
SQL allows two types of constraints.
same PID value, as shown below
o Column level constraints: These constraints are defined along with the column definition
CREATE TABLE PRODUCT
when creating or altering a table structure. These constraints apply only to individual
(
columns. PID CHAR (4) NOT NULL UNIQUE,
o Table level constraints: These constraints are defined after all the table columns when Description VARCHAR2 (25), NOT NULL
creating or altering a table structure. These constraints apply to groups of one or more CompanyId CHAR (10),
DOM DATE,
columns. Type CHAR (10),
Following are the commonly used constraints available in SQL. Price NUMBER (10,2)
Constraints Description );
PRIMARY KEY Constraints:
NOT NULL Ensures that a column cannot have NULL value
A primary key is a field which uniquely identifies each row in a database table. A primary key in a
UNIQUE Ensures that all values in column are different
table has special attributes:
PRIMARY KEY Uniquely identified eac row in a database table.
By default this column is NOT NULL. It defines the column as a mandatory column i.e. the
FOREIGN KEY Uniquely identified each rown in any other database table
column cannot be left blank.
DEFAULT Provides a default value for a column when none is specified
The data held in this column must be unique.
CHECK Ensures that all values in a column satisfy certain condition.
Example:
NOT NULL Constraint: CREATE TABLE PRODUCT
(
By default column can hold NULL values. PID CHAR (4) PRIMARY KEY,
When a column is defined as NOT NULL then the column becomes a mandatory column. Description VARCHAR2 (25), NOT NULL
CompanyId CHAR (10),
It implies that a value must be entered into the column if the row is to be inserted for storage in the DOM DATE,
table. Type CHAR (10),
Price NUMBER (10,2)
);
o CARTESIAN JOIN: returns the Cartesian product of the sets of records from the two or 6. What is the difference between ORDER BY and GROUP BY clause used in SQL? Give example
more joined tables. for each. [June 2017]
7. List the relational operators supported by SQL.
Creating VIEWs: 8. Why the DROP command used? Write its syntax.
Database Views are created using the CREATE VIEW statement. 9. What are the difference between DROP and DELETE command?
Views can be created from a single table, multiple tables or another view. 10. Give the syntax and example for CREATE VIEW command in SQL.
To create a view, a user must have the appropriate system privilege according to the specific 11. Classify the built-in functions in SQL.
implementation.
Syntax: The basic CREATE VIEW syntax is as follows:
Five Marks Question:
SQL> CREATE VIEW view_name AS 1. Explain various group functions in SQL. [March 2015, March 2017, June 2017]
SELECT column1, column2….. 2. What is data definition language? Explain SELECT and UPDATE command. [June 2015]
FROM table_name 3. Describe any five logical operators available in SQL. [March 2016]
WHERE [ condition ]; 4. What is SQL? Explain the different SQL commands.
5. What is the purpose of CREATE command? Write the syntax and example of CREATE command.
Privileges and Roles: 6. Explain SELECT statement with syntax and with minimum 3 examples.
Privileges: Privileges defines the access rights provided to a user on a database object. 7. Explain 5 variations of SELECT command.
There are two types of privileges: 8. What are SQL constraints? Explain any two constraints.
o System Privileges: This allows the user to CREATE, ALTER, or DROP database objects.
****************
o Object privileges: This allows the user to EXECUTE, SELECT, INSERT, UPDATE or
DELETE data from database objects to which privileges apply.
Important Questions
Two Marks Questions:
1. Give the syntax and example for DELETE command in SQL. [March 2015]
2. List the data types supported in SQL. [June 2015]
3. Write the syntax for DELETE and INSERT commands in SQL. [March 2016]
4. Mention the logical operators used in SQL. [June 2016]
5. Give the syntax and example of UPDATE command in SQL. [March 2017]
Cost Factor: online with real-time audio, video and text chat in dynamic 3D environments.
o Personal computers have better price/performance ratio than micro computers. Interspace provides the most advanced form of communication available on the Internet
o So it is better to have PC's, one per user, with data stored on one shared file server today.
machine.
Elementary Terminology of Networks:
Communication Medium.
1. Nodes (Workstations):
o Using a network, it is possible for managers, working far apart, to prepare financial report
The term nodes refer to the computers that are attached to a network and are seeking to
of the company.
share the resources of the network.
o The changes at one end can be immediately noticed at another and hence it speeds up co-
Of course, if there were no nodes (also called workstations), there would be no network at
operation among them.
all.
Need of Networking: 2. Server:
File sharing provides sharing and grouping of data files over the network. A Server is also a computer that facilitates the sharing of data, software, and hardware
Printing sharing of computer resources such as hard disk and printers etc. resources like printers, modems etc on the network.
E-mail tools for communication with the e-mail address. Servers can be of two types:
Remote access able to access data and information around the globe. i. Non-dedicated servers ii. Dedicated servers
Sharing the database to multiple users at the same time by ensuring the integrity. Non-dedicated Servers:
On small networks, a workstation that can double up as a server is known as non-
dedicated server since it is not completely dedicated to the cause of serving.
1|Page Keerthi Kumar H M 2|Page Keerthi Kumar H M
Chapter 15- Networking Concepts II PUC, MDRPUC, Hassan Chapter 15- Networking Concepts II PUC, MDRPUC, Hassan
Such servers can facilitate the resource-sharing among workstations on a proportionately 3. Layer 3 – Network Layer:
smaller scale. The network layer is concerned
Since one computer works as a workstation as well as server, it is slower and requires more with controlling the operation of
memory. the subnet.
The (small) networks using such a server are known as PEER-TO-PEER networks. The main function is
determining how packets are
Dedicated Servers:
routed from source to
On bigger network installations, there is a computer reserved for server's job and its only job
destination.
is to help workstations access data, software and hardware resources.
4. Layer 4 – Transport Layer:
It does not double-up as a workstation and such a server is known as dedicated server.
The basic function of the
The networks using such a server are known as MASTER-SLAVE networks.
transport layer is to accept data
On a network, there may be several servers that allow workstations to share specific
from the above (session) layer,
resources. For example, file server, printer server and modem server. split it up into smaller units if
A Network Interface Unit is an interpreter that helps establish communication between the network layer, and ensure that the pieces all arrive correctly at the other end.
The NIU is also called Terminal Access Point (TAP). The session layer allows users on different machines to establish sessions between them.
It includes dialog control, token management and synchronization.
4. MAC address:
6. Layer 6 – Presentation Layer:
The MAC address refers to the physical address assigned by NIC manufacturer.
The presentation layer is concerned with the syntax and semantics of the information
OSI Reference Model: transmitted concerned with moving bits around the layer.
7. Layer 7 – Application Layer:
The Open Systems Interconnection (OSI) model is a reference tool for understanding data
The application layer contains a variety of protocols that are commonly needed by the user.
communications between any two networked systems.
For example HTTP which is the bases for the World Wide Web to access web pages.
It divides the communications process into seven layers.
The three lowest layers focus on passing traffic through the network to end system.
TCP/IP Model:
The top four layers come into play in the end system to complete the process.
The TCP/IP model uses four layers to perform the functions of the seven-layer OSI model.
The physical layer is concerned with transmitting raw bits over a communication channel. The lowest layer of the TCP/IP protocol hierarchy.
It also deals with mechanical, electrical and timing interfaces. It defines how to use the network to transmit an IP data.
2. Layer 2 - Data Link Layer: It encompasses the functions of physical and data link layer of OSI reference model.
The main function of the data link layer is to take a raw transmission facility and transform it 2. Layer 2 – Internet Layer:
into a line that appears free of transmission errors in the network layer. Provides services that equivalent to OSI network layer.
The primary concern of the protocol at this layer is to manage the connections across
It includes the OSI session, presentation o It is limited in its ability to queue messages at the receiving end; it is usually used with one of
above the transport layer. o Serial Line Internet Protocol was the first protocol for relaying the IP packets over dial-up
This includes all of the processes that involve user interaction. lines.
The application determines the presentation of the data and controls the session. o It defines an encapsulation mechanism, but little else.
o There is no support for dynamic address assignment, link testing or multiplexing different
Network Protocol: protocols over a single link.
A protocol is a set of rules and procedures that determine how a computer system receives and PPP:
transmits data. o Point to Point Protocol is the standard for transmission of IP packets over serial lines.
o The PPP is currently the best solution for dial-up internet connections, including ISDN.
TCP/IP Protocol:
o PPP is a layered protocol, starting with a link control protocol (LCP) for link establishment,
o Transmission Control Protocol / Internet Protocol.
configuration and testing.
o It is the basic communication language or protocol of the Internet.
o PPP supports both synchronized and unsynchronized lines.
o TCP/IP is a two-layer program, the higher layer Transmission Control Protocol (TCP)
manages the assembling of a message or file into smaller packets that are transmitted over the Types of network:
internet. A computer network means a group of networked components, i.e., computers are linked by
o The lower layer Internet Protocol (IP) handles the address part of each packet so that it gets means of a communication system.
to the right destination. There are three types of network.
HTTP Protocol: o Local Area Network (LAN)
o Hypertext Transfer Protocol. o Wide Area Network (WAN)
o It provides a standard for web browsers and servers to communicate. o Metropolitan Area Network (MAN)
o The HTTP is an application layer network protocol built on top of TCP. Local Area Network:
o HTTP clients (web browsers) and servers communicate via HHTP request and response Privately owned small networks that are confined to a localized area (e.g., an office, a building
messages. or a factory) are known as Local Area Networks (LANs).
The key purpose of a LAN is to serve its users in resource sharing.
5|Page Keerthi Kumar H M 6|Page Keerthi Kumar H M
Chapter 15- Networking Concepts II PUC, MDRPUC, Hassan Chapter 15- Networking Concepts II PUC, MDRPUC, Hassan
The hardware as well as software resources are shared through LANs. Network Topologies
LAN users can share data, information, programs, printers, hard disk, modems, etc. Network Topology refers to the arrangement of computers and other devices in a network.
It is fast with speed from 10 MBPS to 10 GBPS. Need for Topologies are: Cost, Flexibility, and Reliability.
LAN Configuration consists of: Network topologies can be classified as follows:
o A File Server: Stores all of the software that controls the network, as well as the software 1. Bus Topology
that can be shared by the computers attached to the network. 2. Star Topology
o A Workstation: Computers connected to the file server. These are less powerful than the 3. Ring Topology
file server. 4. Mesh Topology
o Cables: Used to connect the network interface cards on each computer. 5. Hybrid Topology
Advantages of Ring Topology This topology is robust, provides security and privacy.
o Short cable length Overall cost of this network is too high.
o No wiring closet space required
Data Communication Terminologies:
o Suitable for optical fibers.
Data channel: The information / data carry from one end to another in the network by channel.
o Each client has equal access to resources.
Baud & bits per second (bps): It’s used to measurement for the information carry of a
Disadvantages
communication channel.
o Node failure causes network failure
o Difficult to diagnose faults
Bandwidth: It is amount of information transmitted or receives per unit time. It is measuring in
Kbps/Mbps etc unit.
o Network reconfiguration is difficult
It consists of groups of star-configured workstations connected to a linear bus backbone cable. Due to variety of transmission media and network writing methods, selecting the most
The tree network topology uses two or more star networks appropriate media can be confusing.
The central computers of the star networks are connected to o Transmission rate, Distance, cost, easy of installation and resistance to environmental
Best suited for applications having hierarchical flow of data a. Guided b. Unguided
Advantages of a Tree Topology o Twisted Pair: Unshielded Twisted Pair (UTP), Shielded Twisted pair (STP)
UTP is the copper media inherited from telephone, which is being used for increasingly higher Types of Coaxial Cables:
data rates. The two most commonly used types of coaxial cables are Thicknet and Thinnet.
A UPT cable contains 2 to 4200 twisted pair. 1. Thicknet: This form of coaxial cable is thicker than Thinnet. The Thicknet coaxial cable
UTP is flexible, low cost media; it can be sued for voice or data communication. segments (while joining nodes of a network) can be up to 500 meters long.
It is available in the following five categories: 2. Thinnet: This form of coaxial cable is thinner and it can have maximum segment length of
1. CAT1: Voice-Grade communications only; No data 185 meters i.e. using these cables, nodes having maximum distance of 185 meters can be
transmission joined.
2. CAT2: Data-grade transmission up to 4 Mbps Advantages Disadvantages
3. CAT3: Data-Grade transmission up to 10 Mbps Data transmission rate is better compared Difficult to install, manage and
4. CAT4: Data-grade transmission up to 16 Mbps to Twisted pair reconfigure.
5. CAT5: Data-grade transmission up to 1000 Mbps Used for broadband connection. Expensive than twisted pair
The UTP cables can have a maximum segment length of 100 meters. Higher bandwidth up to 400 Mbps
Optical Fibers Both the transmitter and receiver use antennas to radiate and capture the radio signals.
Optical Fibers consist of thin strands of glass or glass like Advantages Disadvantages
material which are so constructed that they carry light from a Provide mobility It is an insecure communication.
source at one end of the fiber to a detector at the other end. Inexpensive. Susceptible to weather effects like rains,
The light sources used are either light emitting diodes (LEDs) It proves cheaper than digging trenches for thunder storms etc
or LASER Diodes (LDs). laying cables.
It transmits light rather than electronic signals eliminating the Free from land acquisition rights.
problem of electrical interference.
Microwave:
OFC has ability to transmit signals over much longer distances than coaxial cable and twisted pair.
Microwave transmission is line of sight transmission.
The bandwidth of the medium is potentially very high. For LEDs, this range is between 20-150
Mbps and higher rates are possible using LDs. The transmit station must be in visible contact with
the receive station.
It also capacity to carry information at vastly greater speed.
This sets a limit on the distance between stations
Advantages Disadvantages
depending on the local geography.
Transmit data over long distance with Difficult to install
Microwave operates at high operating frequencies of 3 to 10 GHz.
high security. Expensive as compared to other guided
This allows carrying large quantities of data due to their large bandwidth.
Data transmission is high. media
Advantages Disadvantages
Provide better noise immunity. Difficult to repair.
Maintenance easy than cables. Repeaters are required for long distance
Bandwidth is up to 100 Gbps
Suitable when cable cannot be used. communication.
Free from land acquisition rights. Less Bandwidth available.
Comparison table of Guided Transmission media:
Low cost land purchase ( Tower occupies Reflected from flat surfaces like water and
Cable Parameter Twisted Pair Cable Co-axial Cable Optical Fibre Cable
small area) metals.
Data Transfer Rate 10 Mbps – 10 Gbps 100 Mbps More than 100 Gbps
Carry high quantities of information due to
Data Transfer Range 100 Meters 185 Mts – 500 Mts Large distance
their high operating frequencies.
Interference More Less than T.P Nil
Cost of cable Lest cost More than T.P Very expensive Satellite communication:
A satellite consists of transponders (unit that receive on one frequency and retransmit on another)
Radio Wave
that are set in geostationary orbits directly over the equator.
The transmission making use of radio frequencies is termed as radio-wave transmission.
Satellite communication is special case of microwave relay system.
Any radio setup has two parts:
These geostationary orbits are 22,000 - 36,000
a. The transmitter b. The receiver
Km from the Earth’s surface.
The transmitter takes some sort of message, encodes it onto a sine wave and transmits it with radio
The uplink is the transmitter of data to the
wave.
satellite.
The receiver receives the radio wave and decodes the message from the sine wave it receives.
The downlink is the receiver of data.
Uplinks and downlinks are also called Earth stations because they are located on the Earth. Circuit Switching:
Advantages Disadvantages In this technique, first the complete physical connection between two computers is established
The area coverage through satellite Very expensive and then data are transmitted from the source computer to the destination computer.
transmission is large. Installation is complex. That is, when a computer places a telephone call, the switching equipment within the telephone
No line of sight restrictions. Signals sent to the stations can be tampered system seeks out a physical copper path all the way from sender telephone to the receiver's
Earth station which receives the signals by external interference. telephone.
can be fixed position or relatively mobile. The important property of this switching technique is to setup an end-to-end path connection
between computers before any data can be sent.
Apart from microwaves, radio waves and satellites, two other unguided media are also very popular. Message Switching:
These are infrared and laser waves. In this technique, the source computer sends data or the message to the switching office first,
which stores the data in its buffer.
Infrared:
It then looks for a free link to another switching office and then sends the data to this office.
This type of transmission uses infrared light to send data.
This process is continued until the data are delivered to the destination computers.
You can see the use of this type of transmission in everyday life - TV remotes, automotive garage
It is also known as store and forward. i.e., store first in switching office, forward later, one
doors, wireless speakers etc., all make use of infrared as transmission media.
jump at a time.
The infrared light transmits data through the air and can propagate throughout a room (bouncing
Packet Switching:
off surfaces), but will not penetrate walls.
Packet switching can be seen as an option that tries to combine the advantages of circuit and
The infrared transmission has become common in PDAs (Personal digital assistants) e.g., hand
message switching and to minimize the disadvantage of both.
held devices like palm pilots etc.
In Packet switching, a message is broken into smaller parts called packets.
The infrared transmission is considered to be a secure one.
A fixed size of packet which can be transmitted across the network is specified.
Similarly, a receiver can only receive data but cannot send it. A modem is a computer peripheral that allows you to connect and communicate with other
Data sent from computer to printer is an example of simplex mode. computers via telephone lines.
In simplex mode, it is not possible to confirm successful transmission of data. Modulation: A modem changes the digital data from your computer into analog data, a format that
It is also not possible to request the sender to re-transmit information. can be carried by telephone lines.
This mode is not widely used. Demodulation: The modem receiving the call then changes the analog signal back into digital
data that the computer can digest.
The modem modulates the signal at the sending end and demodulates at the receiving end.
Modems are of two types:
o Internal modems: The modems that are fixed
Half-Duplex Mode
within the computer
In half-duplex mode, data can flow in both directions but only in one direction at a time.
o External modems: The modems that are
In this mode, data is sent and received alternatively.
connected externally to a computer as other
It is like a one-lane bridge where two-way traffic must give way in order to cross the other.
peripherals are connected.
The Internet browsing is an example of half duplex mode.
The user sends a request to a Web server for a web page. RJ-45:
It means that information flows from user's computer to the web server. RJ-45 is short for Registered Jack-45 is an eight-wire connector, which
Web server receives the request and sends data of the requested page. is commonly used to connect computers on the local area networks i.e.,
The data flow the Web server to the user's computer. LANs especially Ethernets.
At a time a user can a request or receive the data of web page. The standard connector for unshielded twisted pair cabling is an RJ-45 connector.
Ethernet Card:
The computer that are part of Ethernet, have to install our
special card called Ethernet card.
Full-Duplex Mode
It is LAN architecture developed by Xerox Corp association
In full duplex-mode, data can flow in both directions at the same time.
with DEC and Intel.
It is the fastest directional mode of data communication.
It make use of Bus or Star topology and data transfer rates of 10 Mbps.
The telephone communication system is an example of full-duplex communication mode.
An Ethernet card contains connections for either coaxial or twisted pair cables (or both).
Two persons can talk at the same time.
If it is designed for coaxial cable, the connection will be BNC.
If it is designed for twisted pair, it will have a RJ-45 connection.
Some Ethernet cards also contain an AUI connector. This can be used to
Network Devices: attach coaxial, twisted pair, or fiber optical cables to an Ethernet card.
Modem: Hub:
Modem means Modulation/ Demodulation. A hub is a hardware device used to connect several computers together.
A concentrator is device that provides a central connection point for cables from workstations, Gateway:
servers, and peripherals. The term gateway is applied to a device, system or software application which has internetwork
In a star topology, twisted-pair wire is run from each workstation to a central concentrator. capability of joining dissimilar network.
Types of hub: It is node on network that provides entry to another network.
o Active hubs: It performs data translation and protocol conversions which is suitable to other network.
It electrically amplifies the signal as it moves from one connected device to another. Example: It needs to convert Ethernet traffic from the LAN to SNA (System Network
Active concentrators are used like repeaters to extend the length of a network. Architecture). It then routes SNA traffic to Mainframe. When Mainframe answers, the reverse
o Passive hubs: process occurs.
It allows the signal to pass from one computer to another without any change. Gateway can be implemented on software, hardware or a combination of both.
Gateway is that only the data format is translated, not the data itself.
Switch:
The switch is a telecommunication device grouped as one of computer network components. Wireless and Mobile Computing:
The switch is like Hub but built in with advanced features. Wireless refers to the method of transferring information between a computing device, such as a
The switch connects the source and destination directly which increases the speed of the network. personal data assistant (PDA), and a data source, such as an agency database server, without a
physical connection.
Repeater:
A Repeater is network device that amplifies and restore signals for long-distance transmission. Wireless communication:
It is used in long network lines, which exceed the maximum rated distance for a single run. Wireless communication is simply data communication without the use of landlines.
This may involve cellular telephone, two way radio, fixed wireless, LASER or satellite
Bridge:
communication.
A Bridge is a network device that establishes an intelligent connection between two local networks
Mobile computing means that the computing device is not continuously connected to the base or
with the same standard but with different type’s cables.
central network.
Router: Mobile devices include PDAs, Laptop computers and smart phones.
A router works like a bridge but can handle different protocols. GSM:
A Router is a network device that is used to separate different segments in a network to improve GSM is short for Global System for Mobile communications, which is one of the leading digital
performance and reliability. cellular systems.
The GSM standard for digital cell phones was established in Europe in the mid 1908s.
GSM uses narrowband TDMA, which allows eight simultaneous calls on the same radio
frequency.
TDMA is short for Time Division Multiple Access, a technology for delivering digital wireless
service using time-division multiplexing (TDM).
TDMA:
Time Division Multiple Access.
TDMA works by dividing a radio frequency into time slots and then allocating slots to, multiple
calls. In this way, a single frequency can support multiple, simultaneous data channels.
SIM card:
The SIM - Subscriber Identity Module - is a chip card; the size of a first class postage stamp.
A SIM is a computer chip that gives a cellular device its unique phone number.
It has memory (16 to 64 KB), processor and the ability to interact with the user.
CDMA:
CDMA is short for Code-Division Multiple Access, a digital cellular technology that uses spread-
spectrum techniques.
CDMA is a form of spread spectrum, which simply means that data is sent in small pieces over a
number of the discrete frequencies available for use at any time in the specified range.
WLL
Wireless in Local Loop (WLL or WiLL),
It is meant to serve subscribers at homes or offices.
Applications in Networking:
In WLL services, the telephone provided is expected to be as good as wired phone.
Its voice quality must be high - a subscriber carrying out long conversation must not be irritated SMS:
with quality; one must be able, to use speakerphones, cordless phones and parallel phones. Short Message Service (SMS) is the transmission of short text messages to and from a mobile
phone, fax machine and/or IP address.
GPRS
Messages must be no longer than some fixed number of alpha-numeric characters and contain
GPRS stands for General Packet Radio Service.
no images or graphics.
GPRS is used for wireless communication using a mobile device.
E-mail:
With the service you can access the internet, send emails and large data, download games and Electronic mail (e-mail) is sending and receiving message by computer.
watch movies.
Advantages:
EDGE: o Low cost: Electronic mail is an extremely cost-effective way to move information
around, especially when it must be moved quickly.
The new EDGE air interface has been developed specifically to meet the bandwidth needs of 3G.
o Speed: Electronic mail can be delivered almost as fast as the wire can carry it.
Enhanced Data rates for Global Evolution (EDGE) is a radio based high-speed mobile data
Voice Mail:
standard.
The voice-mail refers to e-mail systems that support audio.
It allows data transmission speeds of 384 Kbps.
Users can leave spoken messages for one another and listen to the messages by executing the
EDGE was formerly called GSM384.This means a maximum bit rate of 48 kbps per time slot.
appropriate command in the e-mail system.
EDGE is considered an intermediate step in the evolution of 3G WCDMA.
Chat:
The “G” in wireless networks refers to the “Generation” of the underlying wireless network Chatting is the most fantastic thing on Internet.
technology.
21 | P a g e Keerthi Kumar H M 22 | P a g e Keerthi Kumar H M
Chapter 15- Networking Concepts II PUC, MDRPUC, Hassan Chapter 15- Networking Concepts II PUC, MDRPUC, Hassan
The public can use a laptop, Wi-Fi phone or other suitable portable devices to access the safe to run but has hidden side effects.
Hotspots are public locations with free or fee-based wireless internet access. o A worm is a program designed to replicate. The program may perform any variety of
additional tasks as well.
WiMax: How Computer Viruses Spread?
WiMax is wireless digital communication system. It moves from computer to computer by attaching themselves to files or boot records of disks.
WiMax can provide Broadband Wireless Access (BWA) up to 30 miles for fixed stations and A virus travel from file to another on the same computer if the infected file executed, from
3-10 miles for mobile stations. computer memory to a file on the disk, on a disk that is carried from one computer to another.
WiMax requires a tower called WiMax Base Station, similar to cell phone tower, which is Damage:
connected to the internet using a standard wired high-speed connection. Can destroy file allocation table (FAT)
Can create bad sectors on the disk
VIRUS:
Can decrease the space on the hard disks by duplicating file.
VIRUS – “Vital Information Resource Under Siege”.
Can format specific tracks on the disk.
A computer virus is a computer program that can replicate itself and spread from one computer
Can destroy specific executable files
to another.
Can cause the system to hang.
Depend on the nature of a virus, it may cause damage of your hard disk contents, and/or
Virus Protection:
interfere normal operation of your computer.
The following guidelines to lead virus free computing life.
Characteristics of a computer virus:
o Never use a CD without scanning it for viruses.
23 | P a g e Keerthi Kumar H M 24 | P a g e Keerthi Kumar H M
Chapter 15- Networking Concepts II PUC, MDRPUC, Hassan Chapter 15- Networking Concepts II PUC, MDRPUC, Hassan
o Always scan files downloaded from the internet. o There are several types of firewall techniques-
o Never boot your PC from floppy. o Packet filter - accepts or rejects of packets based on user defined rules.
o Write protect your disks and make regular backup.. o Application gateway - security mechanism to specific application like FTP and Telnet
o Use licensed software. servers.
o Password protects your PC. o Circuit level gateway - applies security mechanism when a connection is established.
o Install and use antivirus software. o Proxy Server - Intercepts all messages entering and leaving the network.
o Keep antivirus software up to date.
Cookies :
Some of the antivirus are: Kaspersky, Quick Heal, K7, Norton 360, AVG, Avasta, McAFee.
Cookies are messages that a web server transmits to a web browser so that the web server can
Network Security: keep track of the user’s activity on a specific web site. Cookies have few parameters name,
Network security consists of the provisions and policies adopted by a network administer to value, expiration date.
prevent and monitor unauthorized access, misuse, modification of a computer network and
Hackers and crackers :
network accessible resources.
Hackers are more interested in gaining knowledge about computer systems and possibly using
The problem encountered under network security are:
this knowledge for playful pranks.
1. Physical Security holes: When individuals gain unauthorized physical access to a computer
Crackers are the malicious programmers who break into secure systems.
and tamper with files.
2. Software Security holes: When badly written programs or privileged software are Cyber Law:
compromised into doing things that they shouldn’t be doing.
It is a generic term, which refers to all the legal and regulatory aspects of internet and the
3. Inconsistent usage holes: When a system administrator assembles a combination of hardware
World Wide Web.
and software such that the system is seriously flawed from a security point of view.
India’s IT Act:
Protection Methods:
In India the cyber laws are contained in the IT Act 2000. Aims to provide legal infrastructure
1. Authorization - Authorization is performed by asking the user a legal login ID. If the user is
for e-commerce in India by governing transactions through internet and other electronic
able to provide a legal login ID, He/she is considered an authorized user.
medium.
2. Authentication - Authentication also termed as password protection as the authorized user is
CHAPTER 15 – NETWORKING CONCEPTS BLUE PRINT
asked to provide a valid password and if he/she is able to do this, he/she considered to be an
VSA (1 marks) SA (2 marks) LA (3 Marks) Essay (5 Marks) Total
authentic user.
3. Encryption Smart cards– conversion of the form of data from one form to another form. An 02 Question 01 Question - 01 Question 04 Question
Question no
encrypted smart card is a hand held smart card that can generate a token that a computer Question no 18 - Question no 37 09 Marks
07, 08
system can recognize. Every time a new and different token is generated, which even though
carked or hacked, cannot be used later. Important Questions
4. Biometric System – It involves unique aspect of a person's body such as Finger-prints, retinal
1 Marks Question:
patterns etc to establish his/her Identity.
1. Expand FTP. [March 2015, June 2017]
5. Firewall - A system designed to prevent unauthorized access to or from a private network is
2. What is network topology? [March 2015, March 2016]
called firewall. It can be implemented in both hardware and software or combination or both.
5 Marks Question: Open Source doesn’t just access to the source code. The distribution terms of Open Source
1. Explain any five network devices. [March 2015] Software must comply with the following criteria.
2. Give the measures for prevention virus. [June 2015, June 2017] 1. Free Redistribution
3. Explain the network security in detail. [March 2016, June 2016] 2. Source Code
4. What is networking? Explain the goals of networking. [June 2017] 3. Derived works
4. No Discrimination Against persons or groups
**************** 5. No Discrimination Against Fields or Groups
6. Distribution of License
7. License Must Not be Specific to a Product
8. The license must Not Restrict other Software
9. License Must Be technology Natural
OSS: Freeware:
OSS refers to open source software, which refers to software whose source code is available to The term freeware has no clear definition, but is generally used for software, which is available
customers and it can be modified and redistributed without any limitation. free of cost and which allows copying and further distribution, but not modification and whose
FLOSS: source code is not available.
FLOSS refers to Free Libre and open Source Software or to Free Livre and Open Source Freeware is distributed in Binary Form (ready to run) without any licensing fees.
Software. Shareware:
The term FLOSS is used to refer to software which is both free software as well as open source Shareware is software, offered as trial version (for limited period of time) with certain features
software. only available after the license is purchased.
Here the words Libre (a Spanish word) and Livre (a Portuguese’s word) mean freedom. Its source code is not available and modifications to the software are not allowed.
GNU: WWW (World Wide Web).
GNU is a Unix-like computer operating system developed by the GNU project. The World Wide Web (WWW) is a set of protocols that allows you to access any documents
It is composed wholly of free software. on the Net through a naming system based on URLs.
It refers to GNU’s Not Unix .GNU Project emphasizes on freedom and thus its logo type show WWW also specifies a way -- the Hypertext Transfer Protocol (HTTP) - to request and send a
a GNU, an animal living in freedom document over the internet.
FSF: Attributes of WWW
FSF is Free Software Foundation. FSF is a non-profit organization created for the purpose of o User friendly - www resources can be easily used with the help of browser.
supporting free software movement. o Multimedia documents - A web page may have graphic, audio, video, and animation
Richard Stallman founded FSF in 1985 to support GNU project and GNU licenses. etc at a time.
OSI: o Hypertext and hyperlinks - The dynamic links which can move towards another web
OSI is Open Source Initiative. It is an organization dedicated to cause of promoting open page is hyperlink.
source software. o Interactive - www with its pages support and enable interactivity between users and
Bruce Perens and Erics Raymond were the founders of OSI that was founded in February servers.
1998. o Frame - display of more than one section on single web page.
W3C is responsible for producing the software standards for World Wide Web. o Low cost of initial connection.
The W3C was created by Tim Berners-Lee in 1994. o It is accessible from anywhere.
o The search can be slow HTTP uses Internet addresses in a special format called a URL.
o It is difficult to filter and prioritize information A URL (Uniform Resources Locator) specifies the distinct address for each resource on the
o No guarantee of finding what one is looking for internet
o Net becomes overloaded because of large number of users URLs look like this: type://address/path
o No quality control over available data In URL,
Telnet (Remote Login): o type specifies the type of server in which the file is located,
Telnet (Teletype network) is an order Internet utility that lets you log on to remote computer o address is the address of the server,
systems. o path is the location within the file structure of the server, the path includes the list of
Telnet program gives you a character-based terminal window on another system. folders( or directories) where the desired file is located.
You get a login prompt on that system. If you’ve permitted access, you can work on that Consider the URL
system, just as you would if you were sitting next to it. http://www.yahoo.com or http://www.facebook.com
Web Browser: Domain name:
A Web Browser is software application that enables the user to view web pages, navigate web An internet address which is a character based is called a Domain name.
sites and move from one website to another. A domain name is away to identify and locate computer and resources connected to the
Some of the web browsers are Google Chrome, Internet Explorer, Netscape Navigator, Mozilla internet.
Firefox, and Opera. This type of domain name is also called hostname.
Web Server: Some most common domains are:
An internet host computer that many store thousand of websites.
Domain ID Meaning Domain Cou Meaning
A Web Server is a WWW server that responds made by web browsers.
.com Commercial .au Australia
Example: Apache, IIS, PWS (Personal web server for Windows 98).
.gov Government .in India
Web sites:
.mil Military .nz New Zealand
A Web site is collection of web pages, images, videos and other digital assets and hosted on a
.ac Academic .ca Canada
particular domain on the WWW.
.org Organization .jp Japan
Each web site has a unique address called URL.
.edu Education .uk United Kingdom
Web page:
A document that can be viewed in a web browser and residing on a website is a web page.
E-Commerce:
The web pages use HTTP.
o Home page - A web page that is the starting page and acts as an indexed page is home E-Commerce is the trade of goods and services with the help of telecommunications and
page. computers.
o Web portal - That facilitates various type of the functionality as website. E-Commerce involves the automation of a variety of business to consumer transaction through
Consumer-to-Business (C2B):
Customer directly contact with business vendors by posting their project work with set budget
online so that needy companies review it and contact the customer directly with bid.
Example: guru.com, freelancer.com
Consumer-to-Consumer (C2C)
E-commerce is simply commerce between private individuals or consumers.
Example: Ram buying smartphone from Sham using OLX
Advantages of e-commerce
Buying & selling can be done online at any time (24 hours) money.
It provides faster payments through Electronic Fund Transfer.
Online payment reduces work of carrying money to the shop and also saves money.
The consumer browses the catalog of products featured on the site and selects items to Customer can search for competitive prices quickly before purchasing the items.
purchase. The selected items are placed in the electronic equivalent of a shopping cart. Wider choice for item selection.
When the consumer is ready to complete the purchase of selected items, it provides a bill to Without going to the shops customers can view the products through websites thus saves time.
The Commerce Server site then forwards the order to a Processing Network for payment Needs more security.
processing and fulfillment. Some company may charge more for shipping or other transport.
There is the possibility of credit card number theft.
Different types of E-Commerce Mechanical failures can cause unpredictable effects on the total processes.
Business-to-Business (B2B)
Business-to-Consumer (B2C) IPR Issues:
Consumer-to-Business (C2B) IPR stands for Intellectual Property Rights.
Consumer-to-Consumer (C2C) Intellectual Property Rights (IPR) means copyrights, patents, and trademarks, designs etc held
Important Questions
1 Marks Question:
1. What is Open source software?
2. What are Freeware? [March 2015]
3. Define E-Commerce. [March 2016]
4. What is telnet? [June 2016]
5. Expand OSS and FLOSS.
3 Marks Question:
1. Explain Free software.
2. What is meant by shareware? Write its limitations [March 2016]
3. What is Web browser? Mention any two web browser. [March 2015, June 2015]
4. Give the advantages of WWW.
5. Define the terms webpage, website, web server. [June 2016]
6. Explain URLs.
7. What is E-Commerce? Explain types of E-commerce. [June 2015, March 2017]
8. What are the advantages and disadvantages of E-commerce?
9. Explain IPR.
****************