:: kendriya vidyalaya sangathan, jaipur region · the influence of technology forced cbse to...

63
Study Material – Class XII (Comp.Sc.) :: 1:: Kendriya Vidyalaya Sangathan, Jaipur Region

Upload: vandieu

Post on 06-May-2018

215 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Study Material – Class XII (Comp.Sc.) :: 1:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 2: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Rapid and major metamorphoses in the realm of the Computer world affected every dimension of our life. Today we are living into an Information age and modern IT practices is shaping our children.Children today need free access to technology and guidance in the responsible and effective use of the technology.The influence of technology forced CBSE to introduce Computer Science, Informatics Practices and Web Technologies at Senior Secondary Level.This booklet is specially designed tool for slow learners to cope with the complexity of the subject. It covers all the most relevant topics and questionnaires in the light of CBSE Examination. This book is outcome of In-service Course-2009 for PGT (Computer Science) conducted at K.V.No.2, Jaipur.I am very much thankful to Dr. K.P. Chamola, Assistant Commissioner, KVS, and Sri H.C. Chawala, Education Officer, Kendriya Vidyalaya of Jaipur Region for providing the opportunity to conduct In-service Course for PGT (Computer Science) in this Vidyalaya.I am also thankful to Mr. Aslam Parvez (Associate Director), Mr. Sanjay Gupta, Mr. Y. Rohilla, being the Resource Persons and all the PGT Comp.Sci who have attended the In-Service Course-2009, without whose contribution and assistance this material would not have seen the light of the day.

Dr. P.S. Ahluwalia(Course Director)In Service Course 2009For PGT (Comp. Sci)K.V.No.2, Jaipur

Study Material – Class XII (Comp.Sc.) :: 2:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 3: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Table of Contents

1. C++ Revision Tour 32. Object Oriented Programming 103. Function Overloading 134. Classes and Objects 155. Constructors and Destructors 216. Inheritance 257. Arrays 318. Database Concepts and SQL 369. Boolean Algebra 4510. Data Communication & Network Concepts 55

Study Material – Class XII (Comp.Sc.) :: 3:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 4: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Chapter – 1: C++ Revision Tour

Key Points Variables:-Variables represent named storage location whose values can be manipulated during program run.

For eg. int A; A is a variable name that will be use to store an integer value.

Keywords: The keywords are also identifiers but can not be user defined since they are reserved words.

For eg: int ,float, void etc are keywords that have special meaning.

Data types:- Data types are means to identify the type of data and associates operation for handling it.

There are two types of data types: Fundamental data types, Derived data types

Fundamental data types are int, float, char, double

Derived Data types:- From the fundamental types other can be derived by using the declaration operators. Ex: Array, structure and Pointer.

Operators in c++

The symbols that perform some predefined operation on operands.

There are five types of operators:● Arithmetic Operators: +, -, *, /, %● Relational Operators: >, <, >=, <=, !=, ==● Assignment Operators: =● Increment/Decrement Operators: ++, --● Logical operator : &&, ||, !

Flow of Control

To control the flow of the program there are three types of statements are used these are Selection Statements, Iteration Statements, Jumping Statements

Selection Statements: - These types of statements are only used for decision making. There are two types of selection statements named if(two way branching), switch(multiway branching.

Iteration Statements: - The iteration statement allows a set of instructions to be performed until a certain condition is fulfilled. It is also called loop.

There are three types of loops as follows:- for , while, do

For loop:-for loop is used to repeat a set of statements for specified no. of times. All the three parts i.e, initialization, condition checking, increment and decrement operations of the loop are listed in one line.

While loop: while loop is used when we want to repeat a set of statements till a particular condition is true. In case of while we have to put all the three parts in different lines.

Do..while loop: In case of Do while loop first the body of the loop will be executed and then the expression will be evaluated. Now if the expression is evaluate to true then the body of the loop will be executed again otherwise the control will move out of the loop body.

Jumping: The jump statements unconditionally transfer control anywhere in the program. There are three types of jumping statements as follows:

goto, break, continue

goto:-The goto statement is used to alter the program sequence by transferring the control to some other part of the program.

break: The break statement is used to break the loop statements or switch-case statement and the control comes out of the loop.

Study Material – Class XII (Comp.Sc.) :: 4:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 5: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

continue: continue statement is used to skip the current iteration and continue with next iteration

Arrays

Array is a collection of homogenous data type under the same name and stored in the continue manner. There are two types of array as follows

Single Dimensional Array: The simplest form of array is single dimensional arrays. An array definition specifies a variable name along with size to specify how many data items the array will contains.

Syntax: datatype array-name[size];

Mutiple Dimensional Array: Where we specify two or more dimension. Ex: A 2D array is used to store matrix.

Structure

Structure is a collection of variables under a single name. Variables can be of any data type: int, float, char etc. The main difference between structure and array is that arrays are collections of the same data type and structure is a collection of variables may be of different types under a single name. Example:

FunctionsA function is a named unit of a group of programs statements. This unit can be invoked from other parts of the program as and when required.The general form of a fiunction definition is as given below:

type function-name (parameter list){

body of the function}

Parameters can be passed to function in two manners: call by value and call by reference.The call by value method copies the values of actual parameters into the formal parameters, that is, the function creates its own copy of argument values and then uses them.When a function is called by reference, then, the formal parameters become references to the actual parameters in the calling function.

Study Material – Class XII (Comp.Sc.) :: 5:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 6: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Questions and Answers

2 Mark Questions

Q.1 Difference between Global and Local variable. Ans Local variable:- The local variable are the variable that are only accessible by the block of code in

which it declared. These variables are also called private variables. Global Variable:-Global variables are the variables that are accessible in entire program. Global variable

have global scope.

Q.2 Difference between entry control and exit control loop.Ans Entry control Loop: In the case of entry control Loop first the loop expression will be checked and

then the body of the loop will be executed.Example: for Loop, while LoopExit control Loop: in the case of exit control loop first the body of the loop will be executed then the given expression will be checked. It means that the body of the loop will execute atleast once.Example: do..while loop.

Q.3 what is the difference between # define and Const?Ans Both #define and const define constants, however #define can define simple constants without

considering datatype, whereas const can define almost any type of constant, including constant objects of structure and classes.

Q.4 Define the typedef Command with example.Ans typedef command defines a new name or an alias name for an existing type. For example, all

transactions generally involve amounts which are of double type, so for a bank application, we can safely provide an alias name as amount to predefine double type, we will write

typedef double amount. Now we can define any amount using the data type amount as

amount loan,balance;

Q.5 Differentiate between Logical error and Syntax error, with suitable example.Ans Logical Error: Logical error is an error which occurs because of wrong interpretation of logic.

For Example: if by mistake we divide a number with zero.Syntax Error: A syntax error is the error that occurs when statements are wrongly written violating rules of the programming language.

For example: Missing Semicolon. wrong use of Keywords.

Q.6 What is ternary operator? Is there any ternary operator available in C++? Which? Ans A ternary operator requires three operands. C++ has only one ternary operator or conditional operator

i.e ?:The syntax of conditional operator is :

(Conditional expression) ? expression 1: expression 2;it replaces simple if… else… statement.

Ex: large=(a>b)?a:b;

Q.7 Differentiate between break and continue statements.Ans break: The break statement terminates the loop and come out of the loop. For this purpose break

keyword is used.continue: continue statement forces the next iteration of the loop to take place, skipping the current iteration. For this purpose continue keyword is used.

Study Material – Class XII (Comp.Sc.) :: 6:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 7: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Q. 8(a) Name the Header file(s) that shall be needed for successful compilation of the following C++ code

void main() { int a[10];

for (int i=0;i<10;i++) {

cin>>a[i]; if(a[i]%2==0) a[i]=pow(a[i],3); else a[i]=sqrt(a[i]); if(a[i]>32767) exit(0);

} getch();

}Ans iostream.h, math.h, process.h, conio.h

Q. 9. Name the header files to which the following belong : (i) puts ( ) (ii) isalnum ( ) (iii) abs( ) (iv) strcmp( )

Ans (i) stdio.h (ii) ctype.h (iii) math.h (iv) string.h

Q.10. Name the header file of C++ to which following functions belong:(i) strcat() (ii) scanf() (iii) getchar() (iv) clrscr()Ans (i) string.h (ii) stdio.h (iii)

stdio.h (iv) conio.h

Q.11. Name the header files that shall be needed for the followingvoid main( ){char String[ ] = “Peace”;cout << setw(2)<<String;}

Ans (i) iomanip.h (ii) iostream.h

Q12. Write a structure specification that includes two structure variables-distance and time.The distance includes two variables both of type float called feet and inches.The time includes three variables – all of type int called hrs, mins and secs.Intialise such a structure with values 1345.00 feet, 8.5 inches, 10 hrs, 51 mins, 17 secs.

Ans struct distance {float feet;float inches;

};struct time { int hrs;

int mins;int secs;

};struct tour { distance d1;

time t1; };

tour t={{1345.00,8.5},{10,51,17}};

Q13. Write structure definition for structure containing the following:(i) rollno, name, grade.(ii) bookno, bookname, auther, price.

Ans struct stud

Study Material – Class XII (Comp.Sc.) :: 7:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 8: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

{ int rollno;char name[20];char grade;

};struct book { int bookno;

char bookname[30];char author[20];int price;

};

Q14 What is the difference between call by value and call by reference.Ans call by value method copies the values of actual parameters into the formal parameters, that is, the

function creates its own copy of argument values and then uses them. So any change in formal parameters won’t be visible in calling function.Whereas When a function is called by reference, then the formal parameters become references to the actual parameters in the calling function.

Q15 Find the output of the following program :#include<iostream.h>struct MyBox{ int length, breadth, height;};void Dimension(MyBox M){ cout<<M.length<<”x”<<M.breadth<<”x”<<M.height;}void main(){

MyBox B1={10,15,5},B2,B3;++B1.height;Dimension(B1);B3=B1;++B3.lenght;B3.breadth++;Dimension(B3);B2=B3;B2.height+=5;B2.lenght--;Dimension(B2);

}Ans

10 x 15 x 611 x 16 x 610 x 16 x 11

Q16 find the output of the following program:#include<iostream.h>void main(){

int U=10,V=20for(int i=1;i<=2;i++){

cout<< “[1]”<<U++<<”&”<<V-5<<endl;cout<< “[2]”<<++V<<”&”<<U+2<<endl;

}

Study Material – Class XII (Comp.Sc.) :: 8:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 9: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

}Ans. [1] 10 & 15

[2] 21 & 13[3] 11 & 16[4] 22 & 14

Q16 Find the correct possible output from the option:#include<stdlib.h>#include<iostream.h>void main(){

Randomize();Char Area[][10]={“North”, “South”, “East”, “West”};int ToGo;for(int i=0;i<3;;i++){

ToGo=random(2)+1;Cout<<Area[ToGo]<<”:”;

}}

Outputs:i. South : East : South :ii. North : South : East :iii. South : East : West:iv. South : East : East :

Ans. (i),(iv).

Q17 Rewrite the following program after removing the syntactical error(s) if any. Underline each correction.#include<iostream.h>Void main(){ First=10, Second=20;

Jumpto(First, Second);Jumpto(second);

}Void Jumpto(int N1, int N2=20){ N1=N1+N2;

Cout<<N1>>N2;}

Ans.#include<iostream.h>Void main(){ int First=10, Second=20;

Jumpto(First, Second);Jumpto(Second);

}Void Jumpto(int N1, int N2=20){ N1=N1+N2;

Cout<<N1<<N2;}

Q18. Find the output of the following program :

#include<iostream.h>void exec(int a, int &b);void main(){ int a=10;

Study Material – Class XII (Comp.Sc.) :: 9:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 10: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

int b=20;cout<< a<< ‘\t’<<b;exec(a,b)cout<< a<< ‘\t’<<b;

}void exec(int a, int &b){

a=a+100;b=b+50;cout<< a<< ‘\t’<<b;

}Ans:

10 110 70 10 70

Study Material – Class XII (Comp.Sc.) :: 10:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 11: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

CHAPTER-2 : Object Oriented Programming

Key Points:

OOP: It means Object oriented programming which views a problem in terms of object rather than procedure.Object: An object is an identifiable entity with some characteristics and behavior.Class: A class is group of similar objects that share common properties and relationship.Data Abstraction: Abstraction refers to the act of representing essential features without including the background details or explanations.Encapsulation: The wrapping up of data members and member functions (that operate on the data) into a single unit (called class) in known as Encapsulation.Modularity: The act of dividing a complete program into different individual components (functions or modules) is called modularity.Inheritance: Inheritance is the capability of one class (sub class) of things to inherit characteristics or properties from another class (base class).Polymorphism: Polymorphism is the ability for a message or data to be processed in more than one form.

Questions and Answers

2 Mark Questions

Q1 What is programming paradigms? Give names of some popular programming paradigms?Ans:- It means an approach to programming or it defines the methodology of designing and implementing

programs using building blocks of a programming language. Ex: Object Oriented Programming, Procedural Programming

Q 2 What is the difference between Object Oriented Programming and Procedural Programming?Ans:- Object Oriented Programming Procedural Programming

1. It views a problem in term of objects.2. Features like data encapsulation,

polymorphism, inheritance etc. are present.

3. It follows Bottom- Up approach in program design.

1. It views a problem in terms of procedure rather than objects.2.Features like data encapsulation, polymorphism, inheritance etc. are not present.

3. It follows Top- Down approach in program design.

Q3 Define an object and a class with one example of each?Ans:- An object is an identifiable entity with some characteristics and behaviour.

Eg. Orange is an object. Its characteristics are: it is spherical shaped and its colour is orange & its behaviour is: it is juicy and sweet- sour taste.

A class is group of similar objects that share common properties and relationship.Eg. Parrot, sparrow and pigeon are objects that belongs to the class ‘Bird’.

Q4 Define Data Abstraction Concept of OOP with one example?Ans:- Data Abstraction: Abstraction refers to the act of representing essential features without including the

background details or explanations (i.e. Hiding of Data).Eg. While driving a car, you have to only know the essential features to drive a car such as gear & steering handling, use of clutch, accelerator and brakes etc. and not to know about how the engine working and internal wiring etc.

Q5 Define Encapsulation Concept of OOP with one example?

Study Material – Class XII (Comp.Sc.) :: 11:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 12: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Ans:- Encapsulation: The wrapping up of data members and member functions (that operate on the data) into a single unit (called class) in known as Encapsulation.Eg.The data members like rollno, name, marks & members functions like getdata ( ) and putdata ( ) are enclosed in a single unit called student class.

Q6 Define Inheritance Concept of OOP with one example?Ans:- Inheritance: Inheritance is the capability of one class of things to inherit characteristics or properties

from another class.The Class whose properties of data members are inherited, is called Base Class or Super Class and the class that inherits these properties, is called Derived Class or Sub Class.Eg. The class ‘Human’ inherits certain properties such as ability to speak, breathe, eat etc from the class ‘Mammal’ as these properties are not unique to humans & class ‘Mammal’ again inherits some of its properties from another class ‘Animal’.

AnimalMammalHuman

Q7 Define Polymorphism Concept of OOP with one example?Ans:- Polymorphism (poly +morph) means many forms i.e. ability for a message or data to be processed in

more than one form. It is implemented as Overloading and Virtual functions in C++.

Eg. ‘Human’ is a subclass of ‘Mammal’. Similarly ‘Dog’, ‘Cat’ are also subclasses of ‘Mammal’. If a message ‘see through daylight’ is passed to all mammals, they all will behave alike. But if a message ‘see through darkness’ is passed to all mammals, then humans and dogs will not be able to see where as cats will be able to see during night also.

Q8 How Data Abstraction and Encapsulation are interrelated?Ans:- Data Abstraction focuses upon the observable behaviour of an object where as Encapsulation focuses

upon the implementation that gives rise to this behaviour. So, we can say that Encapsulation is a way to implement Data Abstraction.

Q9 What are the advantages of inheritance?Ans:- i) It ensures the closeness with the real- world models.

ii) Reusability: One can derive a sub class from an existing base class and add new features in the sub class without modifying the inherited features.

iii) Transitive nature: If a class C has been declared as a sub class of B which itself is a subclass of A then C must also inherits the properties of A.

i.e. A → B, B → C Then A → C.

Q10 Give two advantages and disadvantages of OOP?Ans:- Advantages:

Study Material – Class XII (Comp.Sc.) :: 12:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 13: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

i) Re-use of code. ii) Its code is near to real world models.

Disadvantages:i) One needs to do proper planning, skills & design for OOP programming.ii) With OOP, classes tend to overly generalized.

Q11 How does a class enforce data-hiding and abstraction?Ans:- A class binds data members and its associated functions together into a single unit thereby enforcing

encapsulation. A class groups its members into three sections : private, protected and public. The private and protected members remain hidden from outside world. Thus through private and protected members, a class enforces data-hiding. The outside world is given only the essential and necessary information through public members, Rest of the things remain hidden, which is nothing but abstraction.

Q12 Give an example in C++ to show polymorphism implementation in C++.Ans:- In C++ polymorphism is implemented through function overloading. A function name having several

definitions that are differentiable by the number of types of their arguments is known function overloading.Eg. float area(float a) {

return a*a; }float area (float a, float b){return a*b;}

Study Material – Class XII (Comp.Sc.) :: 13:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 14: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

CHAPTER-3 : Function Overloading

Key Points:

Function overloading is one of the most powerful features of C++ programming language. It forms the basis of polymorphism (compile-time polymorphism).Function overloading is the practice of declaring the same function with different signatures. The same function name will be used with different number of parameters and parameters of different type. But overloading of functions with different return types are not allowed. For example let us assume an Add and Display function with different types of parameters. // Sample code for function overloading void AddAndDisplay(int x, int y) { cout<<"Integer result: "<<(x+y); } void AddAndDisplay(double x, double y) { cout<< " Double result: "<<(x+y); } void AddAndDisplay(float x, float y) { cout<< " float result: "<<(x+y);

}

Questions and Answers

2 Mark Questions

Q:1 What is function overloading? Give an example illustrating is use in C++ program? Ans: A function having several definitions that are differentiable by the number or types of their arguments

is known as function overloading.Example

Float area (float a){Return a * a;}Float area (float a, float b){Return a*b;}

Q2 How would you compare default arguments and function overloading? Ans: In case of default arguments, default values can be provided in the function prototype itself and the

function may be called even if an argument is missing(provided the default value for the missing argument is present in the prototype).But there is one limitation if you want to default a middle argument, then all the arguments on its right must also be defaulted.We can overload a function for all possible argument combination. It not only overcome the limitation of default arguments but also the compiler is saved from the trouble of testing the default value.

Q3 How does function overloading implement polymorphism? Ans: Polymorphism is the ability for a message or data to be processed in more than one form. Function

overloading is implement to function having (one name and)more than one distinct meanings.

Q4 Answer the questions (i) and (ii) after going through the following class:

Study Material – Class XII (Comp.Sc.) :: 14:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 15: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

class player{

int health;int age;

public:player() { health=6; age=18 } //Constructor1player(int s, int a) {health =s; age = a ; } //Constructor2player( player &p) { } //Constructor3~player() { cout<<”Memory Deallocate”; } //Destructor

};void main(){player p1(7,24); //Statement1player p3 = p1; //Statement3}

(i) When p3 object created specify which constructor invoked and why?(ii) Write complete definition for Constructor3?(iii) Which feature of object oriented programming is demonstrated using costructor1,constructor2, constructor3 in the above class player?

Ans: (i) Copy constructor is invoked when p3 object is created, because statement3 is assignment statement in which object p3 is initialize with object p1.(ii) player( player &p)

{ health = p.health age= p.age }

(iii) Function overloading (constructor overloading)

Study Material – Class XII (Comp.Sc.) :: 15:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 16: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

CHAPTER- 4 : Classes and Objects

Key Points:

Class: A class is a way to bind the data describing an entity and its associated functions together. A class makes a data type that is used to create objects of its type.

Objects: An instance of a class type is known as object.Method: It is a function that is part of a class. It is used to do things.Inline function: All functions defined inside a class and the functions whose definition starts with keyword inline are inline functions. Inline functions expand its code at the function call instead of jumping to the function code.Friend function: A friend function is non member function that is granted access to class private and protected members whereas, a friend class is a class whose member functions can access another class private and protected members.Access Specifiers: A class in C++ represents a group of data and associated functions divided into one or more of these parts: Public, Private and Protected.Nesting of member functions: When a member function is called by another member function, it is called nesting of member function.

Questions and Answers

2 Mark Questions

Q1. What is class? What is its significance?Ans. A class is a way to bind the data describing an entity and its associated functions together. Class

facilitates user defined data type or a type representing similar objects.Significance: The significance of classes lies in the fact that they can model real model entities effectively in the programming form. Real world entities not only posses characteristics but they also have an associated behavior.

Q2. What is the significance of access labels in a class?Ans. A class provides three access labels namely Private, Protected and public. A member declared as

private remains hidden form outside world and it can only be accessed by the member functions and friend functions of the class whereas protected members can be used by its child or derived class. A member declared as public is made available to the outside world. i.e. it can be accessed by any function, any expression in the program but only by using an object of the same class type. These access labels enforce data hiding and abstraction, OOP concepts.

Q3. What do you mean data members and member functions in OOPS?

Ans Data Members: Data members are the data type properties that describe the characteristics of a class. There may be zero or more data members of any type in a class.Member Functions: These are the set of operations that may be applied to objects of that class. There may be zero or more member functions for a class. They are referred to as the class interface.

Q4. How is a member function differ from an ordinary function?Ans Member functions have full access privilege to both the public and private members of the class while,

an ordinary functions have access only to the public members of the class.Member functions are defined within the class scope that is they are not visible outside the scope of class. Ordinary functions are also visible outside the scope of class.

Q5. How is memory allocated to a class and its objects?

Study Material – Class XII (Comp.Sc.) :: 16:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 17: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Ans When a class is defined, memory is allocated for its member functions and they are stored in the memory. When an object is created, separate memory space is allocated for its data members. All objects work with the one copy of member function shared by all.

Q6. What are the advantage and disadvantage of inline functions?Ans Advantage: The advantage of the inline function is that they run faster than the normal functions as

there will be no function calling overheads.Disadvantage: The disadvantage of inline function is that it takes more memory space because the body of the function substituted in place of function call.

4 Mark Questions

Q7. Suppose a class is defined as follows answer the following questions below:

class animal{

Private:char name[15];int legs;

Public:Void input(){

cin>>name>>legs;}Char *getname(){

return name; }int num_of_legs(){

return legs;}

};

(i) How many data members does the class animal have?Ans: 2

(ii) How many methods does the class animal have?Ans: 3

(iii) How to declare an object of Class Animal?Ans: Animal mydog;

(iii) Write statement to print the name and the number of legs of a dog object named mydog.Ans: Cout<<mydog.getname()<<”has”<<mydog.num_of_legs()<<”legs”<<endl;

Q8. Define a class student for the following specifications.Private members are :

rollno integername array of characters of size 20class_st array of characters of size 8marks array of integers of size 5percentage float Write a function to calculate that calculates overall percentage marks

Public members are:

Study Material – Class XII (Comp.Sc.) :: 17:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 18: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Readmarks( ) reads marks and invokes the calculate function Displaymarks( ) prints all the members of the class.

Ans: class student{ int rollno;

char name[20];char Class_st[8];int marks[5];float percentage;void calculate ();

public:void readmarks();void displaydata();

};void student :: calculate(){ int tot=0;

for(int i=0;i<5;i++){

tot=tot + marks[i]; }percentage=(tot/500)*100;

}void student :: readmarks(){ cout<<”Enter the roll number:”;

cin>>rollno;cout<<”Enter name:”;gets(name);cout<<”Enter class:”;gets(class_st);cout<<”Enter marks in five subjects:”;for(int i=0;i<5;i++){

cin>>marks[i];}calculate();

}void student :: displaydata(){

cout<<”Roll number is : ”<<rollno<<endl;cout<<”Name is : ”<<name<<endl;cout<<”class is : ”<<class_st<<endl;cout<<”Marks in five subjects :”;for(int i=0;i<5;i++){ cout<<marks[i]<<endl;}cout<<”Percentage is :”<<percentage<<”%”;

}

Q9. Define a class serial in C++ with the following specifications:Private members of class serial

Serialcode integerTitle 20 characterDuration floatNoofepisodes integer

Study Material – Class XII (Comp.Sc.) :: 18:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 19: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Public member function of class serialA constructor to initialize duration as 30 and noofepisodes as 10.Newserial() function to accept values for Serialcode and Title.Otherentries () function to assign the values of Duration and Noofepisodes with the help of corresponding values passed as parameters to this function.Dispdata() function to display all the data members on the screen.

Ans. class serial{ int serialcode;

char Title[20];float Duration;int Noofepisodes;

Public:serial(){ Duration =30;

Noofepisodes =10;}void Newserial(){ cout<<”\n Enter the code for serial :”;

cin>>serialcode;cout<<”\n Enter the title of a serial :”;gets(Title);

}

void otherentries(float dur, int noe){ Duration=dur;

Noofepisodes=noe;}

void Dispdata (){ cout<<”\n Serial Code :”<<serialcode;

cout<<”\n Title :”<<Title;cout<<”\n Duration :”<<Duration;cout<<”\n No. of Episodes :”<<Noofepisodes;

}};

Q. 10. A class TRAVEL with the following descriptions: Private members are :

Tcode, no_of_pass, no_of_buses integer (ranging from 0 to 55000)Place stringCalculate function Calculates no_of_buses according to the following rules :Number of passengers Number of busesLess than 40 1Equal to or more than 40 & less than 80 2Equal to or more than 80 3

Public members are:A function INDETAILS( ) to input all information except no_of_buses and invoke calculate function

A function OUTDETAILS( ) to display all the information.

Ans. class Travel{

unsigned int tcode;unsigned int No_of_pass;

Study Material – Class XII (Comp.Sc.) :: 19:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 20: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

unsigned int no_of_buses;char Place[20];void calculate();

public:void INDETAILS( );void OUTDETAILS( );

}; void Travel :: calculate( )

{

if (no_of_pass <40)no_of_buses=1;

else if (no_of_pass<80)no_of_buses=2;

elseno_of_buses=3;

}

void Travel :: INDETAILS( ) {

cout<<”Enter the Travel Code”<<endl;cin>>tcode;cout<<”Enter the no. of passengers”<<endl;cin>>no_of_pass;cout<<”Enter place”<<endl;gets(place);calculate();

}Void Travel :: OUTDETAILS( ){

cout<<”Tcode ”<<tcode;cout<<”Number of passengers ”<<no_of_pass;cout<<”Place”<<place;cout<<”Number of buses required are ”<<no_of_buses;

}

Q11. Define a class Library with following specifications:Private MembersBook_no, Book_Name, price, no_of_copies, no_of_copies_issuedPublic Members- Constructor() to initializes all the data members with values i.e book information- issue_book() to issue book from library by checking its availability.- return_book() to return book to library and update the data of the library.- display() to display book information.

Ans:class Library{int book_no;char book_name[20];int no_of_copies;int no_of_copies_issued;public://constructor to initialized all data membersLibrary(int b_no, char b_name[], int nc, int ni){

Study Material – Class XII (Comp.Sc.) :: 20:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 21: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

book_no=b_no;strcpy(book_name,b_name);no_of_copies=nc;no_of_copies_issued=ni;

}// function of issue book from libraryvoid book_issue(){

If no_of_copies>=1{

no_of_copies--;no_of_copies_issued++;

}else

cout<< “\n Book not available in library”;}//function to return book to the libraryvoid return_book(){

no_of_copies++;no_of_copies_issued--;

}void display(){

cout<< “\n Book Number :”<<book_no;cout<< “\n Book Name :”<<book_name;cout<< “\n No of copies :”<<no_of_copies;cout<< “\n Book issued :”<<no_of_copies_issued;

} }; //end of class

Study Material – Class XII (Comp.Sc.) :: 21:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 22: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

CHAPTER- 5 : Constructor & Destructor

Key Points:

Constructor: Constructor is a special member function of class whose task is to initialize data members of the object. It is automatically invoked when object of class is created. Its name is same as class name.The constructor functions have certain special characteristics:- Constructor functions are invoked automatically when the objects are created.Constructor has no return type even void.They can not be inherited.A destructor can not be static.Example:

class student{

private: int Rn, Marks;Public:

Student( ) // Constructor{

Rn=0;Marks=0;

}};

Types of constructor:Constructor has three types:

Default Constructor: A constructor takes no arguments is called default constructor. It is automatically invoked when an object is created without providing any initial values. In case, the programmer has not defined a constructor in the class, the compiler will automatically generate default constructor.Parameterized Constructor: A constructor can accept arguments is known as parameterized constructor. Parameterized constructor is used to initialize the data member of object with different values.Copy Constructor: A copy Constructor is used to initialize an object from another object. Copy constructor always takes argument as a reference object.

Destructor: As the name implies it is used to destroy the object that has been created by the Constructor. It is used to clean up the storage that is no longer required. Like a Constructor the destructor is a member function whose name is same as the class name but it is preceded by (~ )tilde sign. It is good practice to declare destructor in a program since it release memory space for future use.When controlled exited from main function then Destructor destroy the object obj1, because it is no longer accessible.

Characteristics of Destructor:It is automatically invoked when control exit from program or block and destroy the object .

● It never takes any arguments.● It has no return type● It can not be inherited.● A destructor can not be static.

Study Material – Class XII (Comp.Sc.) :: 22:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 23: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Questions and Answers

2 Mark Questions

Q1. Answer the questions (i) and (ii) after going through the following class: class Exam { int year; public: Exam (int y) {year=y;} //Constructor 1 Exam (Exam & t); ///Constructor 2}; Create an object, such that it invokes Constructor1. Write complete definition for Constructor 2.

AnsI. Exam obj1 (2009);II. Exam (Exam &t) { year=t.year; }

Q2. Answer the questions (i) and (ii) after going through the following class: class Science{

char Topic [20];int Weightage;public:Science ( ) //Function 1{

strcpy (Topic, “Optics”);Weightage = 30;cout<<“Topic Activated”;

}~Science( ) //Function 2{

cout<<“Topic Deactivated”;}

};(i) Name the specific features of class shown by Function 1 and Function 2 in the above example.(ii) How would Function 1 and Function 2 get executed?

Ans: (i) Function 1: Constructor/ Default Constructor Function 2: Destructor

(ii) Function1 is executed or invoked automatically when an object of class Science is created. Ex: Science s1;

Function 2 is invoked automatically when the scope of an object of class Science comes to an end.

Q3. Answer the questions (i) and (ii) after going through the following class :class Computer

{char C_name[20];char Config[100];public:

Computer(Computer &obj); // function1 Computer(); //function 2Computer(char *n,char *C); // function3

};

Study Material – Class XII (Comp.Sc.) :: 23:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 24: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

i. Complete the definition of the function1(ii) Name the specific feature of the OOPs shown in the above example

Ans: (i) Computer (Computer &obj){ strcpy (C_name, obj.C_name); strcpy(Config, obj.Config);}

(ii) Constructor overloading.Q4. Answer the questions (i) and (ii) after going through the following class: class Exam

{int Marks;char Subject[20];public:Exam () //Function 1{

Marks = 0;strcpy (Subject,”Computer”);

}Exam (char S []) //Function 2{

Marks = 0;strcpy(Subject,S);

}Exam (int M) //Function 3{

Marks = M;strcpy (Subject,”Computer”);

}Exam (char S[], int M) //Function 4{

Marks = M;strcpy (Subject,S);

}};

(i) Write statements in C++ that would execute Function 3 and Function 4 of class Exam.(ii) Which feature of Object Oriented Programming is demonstrated using Function1, Function 2,

Function 3 and Function 4 in the above class Exam?

Ans: (i) Exam obj1 (75); //To execute function 3: Exam obj2 (“computer”, 85); // To execute function 3

(ii) Constructor Overloading

Q5. Answer the question (i) and (ii) after going through the following class.class Bazar{

char Type[20];char Product[20];int Qty;float Price;Bazar( ){ strcpy(Type, “Electronic”);

strcpy(Product, “Calculation”);Qty = 10;Price = 225;

Study Material – Class XII (Comp.Sc.) :: 24:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 25: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

}public:void Disp( ){

cout<<Type<< “-” <<Product << “ :”<<Qty << “@” <<price <<endl;}

};

void main( ){ Bazar B; //statement1

B.Disp( ); //statement2}(i) Will statement 1 initialize all the data member for object B with the values given in the Function1 ? (Yes OR No). Justify your answer suggesting the correction(s) to be made in the above code.(ii)What shall be the possible output when the program gets executed ? (Assuming, if required the suggested corrections are made in the program)

Ans. (i) No, Since the default constructor Bazar( ) is declared inside private: section, it can not initialize the objects declared outside the class. Correction needed is the constructor Bazar( ) should be declared inside public: section.

(ii) Electronic-calculator 10 @ 225

Study Material – Class XII (Comp.Sc.) :: 25:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 26: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

CHAPTER- 6 : Inheritance

Key Points:

Inheritance is the capability of one class inherit properties from another class. There are two type of class one is base class and another is derived class. Derived class inherits from the base class. Inheritance may take place in many form. There are different type of inheritance:1. Single inheritance:- one class inherited by one class.

2. Multiple inheritance : - One child inherited from two or more base classes

3. Multilevel inheritance: one class inherited by another class. Another class inherited by one another class.

4. Hierarchical inheritance:- two class inherit one class

5. Hybrid inheritance:- combines two or more forms of inheritance.

Study Material – Class XII (Comp.Sc.) :: 26:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 27: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Questions and Answers

4 Mark Questions

Q1. Answer the questions (i) to (iv) based on the following code : Class abc{

int a;char ch[10];float cost; void ss();

public:int n;abc(); //Constructorvoid get_data(); // member functionvoid put_data(); //member function

};Class xyz : public abc{

int a[10];char ch;void xx();

public:xyz(); //Constructorvoid read_data(); //member functionvoid write_data(); //member function

};

(i) What is the size of object xyz in bytes(ii) Write name of all the member function accessible form the object of class xyz.(iii)Which class constructor will be called first at the time of declaration of an object of class xyz.(iv) Name the data member(variable) which accessible from the object of class abc.

Ans. (i) Calculate the size: 2+10+4+2+20+1=39

(ii) get_data() and put_data from abc class read_data() and write_data from xyz class.

(iii) Abc() then xyz()(iv) n

Study Material – Class XII (Comp.Sc.) :: 27:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 28: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Q2. Answer the questions (i) to (iv) based on the following code : class Employee{

int id;protected :

char name[20];char doj[20];

public :Employee();~Employee();void get();void show();

};class Daily_wager : protected Employee{

int wphour;protected :

int nofhworked;public :

void getd();void showd();

};class Payment : private Daily_wager{

char date[10];protected :

int amount;public :

Payment();~Payment();void show();

};(i) Name the type of Inheritance depicted in the above example.(ii) Name the member functions, which are accessible by the objects of class Payment.(iii) From the following, Identify the member function(s) that can be called directly from the

object of class Daily_wager class show(), getd(), get()(iv) Find the memory size of object of class Daily_wager.(v) Is the constructors of class Employee will copied in class Payment? Due to inheritance.

Ans: (i) Multilevel inheritance(ii) void show()(iii) getd() (iv) 46 Note: Employee= 2+20+20 =42 daily_wager=2+2 =04 total =46(v) not copied

Q3. Consider the following code and answer the questions: class typeA{

int x; protected:

Study Material – Class XII (Comp.Sc.) :: 28:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 29: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

int k1; public:

typeA(int m);void showtypeA();

};class typeB : public typeA{

float p,q; protected:

int m1;void intitypeB();

public:typeB(float a, float b);void showtypeB();

};class typeC : private typeB{

int u,v; public:

typeC(int a, int b);void showtypeC();

};(i) How much byte does an object belonging to class typeC require?(ii) Name the data member(s), which are accessible from the object(s) of class typeC.(iii) Name the data members, which can be accessed from the member functions of class typeC?(iv) Is data member k1 accessible to objects of class typeB?

Ans:- (i) 18Class a= 2+2 =4

Class b=4+4+2 =10 Class c= 2+2 =4 Total =18(ii) None(iii) m1,k1,u,v (iv) No

Q4. Answer the question (i) to (iv) based on the following code:Class Medicines{

char Category[10];char Dateofmanufacture[10];char Company[20];

public:Medicines();void entermedicinedetails();void showmedicinedetails();

} ;class Capsules : public Medicines{ protected:

char capsulename[30];char volumelabel[20];

public:float Price;Capsules();

Study Material – Class XII (Comp.Sc.) :: 29:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 30: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

void entercapsuledetails();void showcapsuledetails();

} ;class Antibiotics : public Capsules{ int Dosageunits; char sideeffects[20]; int Usewithindays;public:

Antibiotics();void enterdetails();void showdetails();

} ;(i) How many bytes will be required by an object of class Medicines and an object of class

Antibiotics respectively?(ii) Write names of all the member functions accessible from the object of class Antibiotics.(iii) Write names of all the members accessible from member functions of class Capsules.(iv) Write names of all the data members which are accessible from objects of class Antibiotics.

Ans: (i) medicines=40 and antibiotics=118Note: Medicines =10+10+20 =40

Capsules =30+20+4 =54Antibiotics =2+20+2 =24Total= 118

(ii)entermedicinedetails(), showmedicinedetails(), entercapsuledetails(), showcapsuledetails(), void enterdetails(); showdetails();

(iii) entermedicinedetails(),showmedicinedetails(), entercapsuledetails(), showcapsuledetails(), price, capsulename, volumelabel

(iv) price

Q5. Answer the following questions (i) to (iv) based on the following code :class DRUG

{ char catg[10];

protected: char DOF[10], comp[20]; public:

DRUG( );void endrug( );void showdrug( );

};class TABLET : public DRUG{

protected:char tname[30],volabel[20];

public:TABLET( );void entab( );void showtab( );

};class PAINKILLER : public TABLET{

int dose, usedays; char seffect[20];

public :

Study Material – Class XII (Comp.Sc.) :: 30:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 31: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

void entpain( );void showpain( );

};(i) How many bytes will be required by an object of TABLET?(ii) Write names of all the data members accessible from member functions of class TABLET?(iii) Write names off all members functions accessible from object of class PAINKILLER.(iv) Write names of all data members accessible from member functions of class PAINKILLER.

Ans: i) 90drug=10+10+20=40Tablet=30+20 =50Total =90

ii) tname, volabel, DOF, Compiii) endrug(), showdrug(),entab(),showtab(), entpain(), showpain()iv) does, usedays, tname, valabel, seffect, catg, comp, DOF

Study Material – Class XII (Comp.Sc.) :: 31:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 32: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

CHAPTER-7 : Arrays

Key Points:

An array is a finite, ordered set of homogeneous elements that stored in contiguous memory locations, elements can be accessed by the index.There are two type of array.

● Single Dimension Array (1-D)● Two Dimension Array (2-D)

Single Dimension Array:- One dimensional array is simply a named group of finite number of similar data elements under one index. e.g.

10 30 20 50 30 20 25 29 29 50 elements0 1 2 3 4 5 6 7 8 9

Index

Two Dimension Array:- Two dimensional array is simply a named group of finite number of similar data elements under two index. e.g.

A[0,0] A[0,1] A[0,2] A[0,3]A[1,0] A[1,1] A[1,2] A[1,3]A[2,0] A[2,1] A[2,2] A[2,3]

Address Calculation in Arrays-We may compute the address of any subscript of array in memory. Since, array is stored in contiguous memory locations. The facts like base address and data type of array elements should be consider in address calculation.

1. Address Computation of Single dimensional array- Since the elements of one dimensional array are stored in the memory location by sequential allocation techniques, the address of Ith element of the array can be obtained, if we know-(a) The Base address (the address of first element) of the array and denoted by B.(b) The size of the element in the array denoted by S and LB is Lower bound. In ‘C++ language LB is 0.

Address of Ith Element = B+(I – LB) * s

2. Address Computation of Two -dimensional array:Since elements of the two-dimensional array can be stored in the computer memory in contiguous manner in row wise order.

In general, the address of an array element may be computed as-

Address of an element = Base address +(no of elements before this element) * size

Let B is base address, S is size of each element, M and N is the number of row and column respectively. We obtain the formula as follows-

Address of a[i,j]=B+S [(i*N)+j]Operations on ArrayTraversing:- Accessing (or Printing ) the elements of array.Insertion: Insertion of an element in the array at specified position or at end.Deletion: Removing an element from an array from specific location.Searching: Finding a given value in the array.Sorting: Arranging elements of the array in Ascending or descending order.

Study Material – Class XII (Comp.Sc.) :: 32:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 33: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Q.1 write a program to show a linear search.Answer:-

#include<iostream.h>#include<conio.h>

int search(int A[], int size,int N){ clrscr();

int i; for(i=0;i<size;i++) { if(A[i]==N)

{ return(i); }

} return(-1); }Q.2 Suppose A,B,C are array of integer of size M,N and M+N respectively. The numbers in array A

appears in ascending order while the numbers in array B is in descending order. Write a user defined function in c++ to produce IIIrd array.(by merging solution) Answer:-#include<iostream.h>#include<conio.h>void merge(int A[],int M,int B[],int N,int C[]){int a,b,c;

for(a=0,b=N-1,c=0;a<M&&b>0;) { if(A[a]<=B[b]) { C[c]=A[a];

c++; a++;

}else

{ C[c]=B[b]; c++; b--;

}}

if(a<M) { while(a<=M) c[c++]=A[a++]; } else { while(b>=0) c[c++]=B[b--]; } }Q.3 Suppose a one dimensional array ARR containing integers arranged in ascending order. Write

a user defined function in C++ to search for one integer from ARR with the help of binary search method. The function should return an integer 0 to show absence of the number & the integer 1 to show the presence of the number in the array. The function should have three parameters as (1) an array ARR (2) the number DATA to be searched (3) number of element N.Answer:-

#include<iostream.h>#include<conio.h>

Study Material – Class XII (Comp.Sc.) :: 33:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 34: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

int Bsearch(int ARR[],int n, int Data){ int beg,last,mid;

beg=0;last=n-1;while(beg<=last){mid = (beg+last)/2;if(Data = =ARR[mid])return 1;else if (Data>Arr[mid])beg = mid+1;elselast = mid-1;return 0;

} Q.4 write a function to sort an array using selection sort method.Answer:-

void insert(int a[], int size){ int i, j, n, t;clrscr();for (i=0;i<n-1;i++) { for (j=i+1;j<n;j++)

{ if (a[i]> a[j]){ t = a[i];

a[i]=a[j];a[j]=t;

}}

}}

Q.5 Write a function to implement bubble sort to sort an array.Answer:-

void bubble(int a[], int size){ int i, j, n, temp;clrscr();for (i=0;i<n-1;i++){ for (j=0;j<n-1-I; j++)

{ If( a[j]>a[j+1]){

temp = a[j];a[j] = a[j+1];a[j+1] = temp;

}}

}}

Q6. An array MAT [20][10] is stored in the memory along the row with each element occupying 4 bytes of memory. Find out the base address & the address of elements MAT [10][5], if the location of MAT [3][7] is stored at address 1000.

Answer:-Let Base address is BNo. of column (n) = 10Element size (W) = 4

Study Material – Class XII (Comp.Sc.) :: 34:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 35: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Lowest Row & Column indices { } address of Ith , Jth element of array in row major order is :Address of MAT [I][J] = B+{u{I- }+{J- }MAT [3][7] = 1000

1000 = B+4(10(3-6)+(7-0))1000 = B+4(30+7)1000 = B+4(37)1000 = B+148B = 1000 – 148B = 852

MAT [10][5] = 852+4(10(10-0)+(5-0)) = 852+4(100+5) = 852+4(105) = 852+420 = 1272

Q7. Write a function in C++ which accepts an integer array & its size as arguments/parameters & assign the elements into a two dimensional array of integers in the following format:-

If the array is 1,2,3,4,5,6 then resultant 2D array =

1 0 0 0 0 01 2 0 0 0 01 2 3 0 0 01 2 3 4 0 01 2 3 4 5 01 2 3 4 5 6

And if the array is 1, 2, 3 then resultant 2D array =1 0 01 2 01 2 3

Answer:-void func(int arr[], int size){int a2[20][20];int i,j;for (i=0;i<size;i++){

for (j=0;j<size;j++){ if(i>=j)

a2[i][j] = arr[j]; else

a2[i][j] = 0;cout<< a2[i][j]<<” ”;}

cout<<endl;}}

Q8: Write a function in C++ which accepts an integer array & its size as arguments/Parameters and assign the elements into two dimensional arrays of integers in the following formatIf the array is 1, 2, 3,4,5,6 then resultant 2D array = 1 2 3 4 5 6

Study Material – Class XII (Comp.Sc.) :: 35:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 36: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

1 2 3 4 5 01 2 3 4 0 01 2 3 0 0 01 2 0 0 0 01 0 0 0 0 0And if the array is 1, 2, 3 then resultant 2D array =

1 2 31 2 01 0 0

Answer:-void func(int arr[], int size){ int a2[20][20]; int i,j;for (i=0;i<size;i++){

for (j=0;j<size;j++){ if ((size-i)<j)

a2[i][j] = 0;else

a2[i][j] = arr[j];cout<< a2[i][j]<<””;}

cout<<endl;}}

Q.9: An array MAT [30][10] is stored in the memory column wise with each element occupying & bytes of memory. Find out the base address & the address of elements MAT [20][5] , if the location of MAT [5][7]is stored at the address 1000.

Answer:-Base address BNo. of rows (m) = 30Element size (W) = 8Lowest Row & Column indices { } address of Ith , Jth element of array in column major order is :Address of MAT [I][J] = B+W(m(J- )+ (I- ))MAT [5][7] = 10001000 = B+8(30(7-0)+(5-0))1000 = B+8(210+5)1000 = B+8(215)1000 = B+1720B = 1000 – 1720B = -720Hence Base address is -720.Now address of MAT [20][5] is computed as:MAT [20][5] = -720+8(30(5-0)+(20-0)) = -720+8(150+20) = -720+8(170) = -720+1360 = 640Hence address of MAT [20][5] is 640.

Study Material – Class XII (Comp.Sc.) :: 36:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 37: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

CHAPTER- 8 : Data Base Concept & SQL

Key Points:

Database is a collection of different kinds of data which are connecting with some relation. In different way, it is a computer based record keeping system. The collection of data referred to as a database.

A database management system is answer to all these problems as it provides a centralized control of the data.

Advantages of Database:

1. It reduce the data redundancy 2. Control data inconsistency3. Facilitate sharing of data4. Databases enforce standards5. Ensure data security6. Integrity can be maintained

Data: It is row facts, figures, characters, etc with which we have to start.Information: The processed data or meaningful data is known as information.Database: An organized collection of relational data is called as database.DBMS: It is a Database Management System. It is a system used for create database, store the data, secure it and fetch data whenever required. MS Access, Oracle are the example of DBMS.

Data Models :The external level and conceptual level user certain data structures to help utilize the database efficiently. There are three data models that are used for database management system are:1. Relational Data Model2. Hierarchical Data Model 3. Network Data Model

Commonly used Terms related to Data Base:

Tuple : The rows of tables are generally referred to as Tuples.

Attributes : The columns of tables are generally referred to as attributes.

Degree : The number of attributes in a relation determine the degree of a relation. A Table having five columns is said to be a relation of degree five.

Cardinality : The number of tuples (rows) in relation (table) is called the Cardinality of the relation.

Primary Key : It is a set of one or more attributes that can uniquely identify tuples within the relation. For e.g. EmpNo. is the primary key for the table Employee.

Candidate Key : All attributes combinations inside a relation that can serve as primary key are Candidate keys as they are having the candidature to work as the Primary Key.

Alternate Key : A candidate key that is not the primary key but can be used in place of primary key is called an alternate key.

SQL – Structured Query Language:SQL is the set of commands that is recognized by nearly all the RDBMS. It is a language that enables us to create and operate on relational databases, which are sets of related information stored in tables.

Processing Capabilities of SQL:

Study Material – Class XII (Comp.Sc.) :: 37:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 38: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Classification of SQL Statements:

● Data Definition Language (DDL) Commands● Data Manipulation Language (DML) Commands● Transaction Control Language (TCL) Commands● Data Control Language (DCL) Commands.

DDL Commands :

It allows us to perform tasked related to data definition. Through these commands user can Create, alter and drop schema objects (structure definition) of the table. Major DDL commands are-CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX, ALTER INDEX, DROP INDEX, RENAME, TRUNCATE are the example of DDL commands.

DML Commands :

It is a set of commands that enables users to access or manipulate data as stored in the table or relation.SELECT, INSERT INTO, DELETE, UPDATE are the example of DML commands.

TCL Commands :

A transaction is successfully completed if and only if all its constraints are successfully completed. To manage and control the transactions, the transaction control commands are used.COMMIT, ROLLBACK, SAVEPOINT are the example of TCL commands.

DCL Commands :

DCL commands are used to manage the access rights and security of the database and tables.GRANT and REVOKE are the example of DCL commands.

Data Types in SQL:

Data Types are means to identify the types of data and associated operations for handling it. There are various data types in SQL:

■ char (size) : Fixed length character data of length size bytes.■ Varchar2 (size) : Variable length character string having maximum length size bytes.■ Number (p, s) : Number having precision p and scale s.■ Date: Valid date range from January 1, 4712 BC to December 31, 4712 AD.

Syntax of SQL Commands

1. Create Table : This command is to to create a table.Syntax :

CREATE TABLE <table name>( <column name> <data types>[(size)] [,<column name> <data types>[(size)]….);

Eg. Create table student (rollno number(2), name varchar2(20), dob date);

Constraints:

Study Material – Class XII (Comp.Sc.) :: 38:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 39: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

SQL provides various Constraints which are used to validate data items i.e. prevent invalid data entry into the table.

● Not Null Constraint: It ensures that the column cannot contain a NULL value.● Unique Constraint: It insures the uniqueness of the data entered in a column. A column having

unique constraints can not have duplicate values.● Primary Key: It ensures two things : (i) Unique identification of each row in the table. (ii) No

column that is part of the Primary Key constraint can contain a NULL value.● Check Constraint: Sometimes we may require that values in some of the columns to be within a

certain range or they must satisfy certain conditions. In such situation we can use Check constraints.

Example- Create table student(RollNo number(2) Primary Key,Name varchar2(20) Not Null,Dob date,City varchar2(20) Unique, Age number(2) check (age<12) );

2. Drop Table: It is used to delete a table.Syntax : Drop Table <table name>;Example- Drop Table student;

3. Alter Table : It is used to add, delete or modify the column in the existing table.Syntax :Alter Table <table name> Add|Modify|Drop <column definition>;

Example. To add column To modify a column To delete a columnAlter table Student Add Class number(2);

Alter table StudentModify (rollno number(3));

Alter table studentDrop column city;

4. Update:It is used to modify the data of column(s) in an existing table.Syntax :Update Table <table name> Set <column name>=<expression> [<condition>];

Example-Update studentSet name = ‘Rahul Sharma’Where rollno = 5;

5. Insert into: It is used to insert a record into the table.Syntax : Insert Into <table name> Values( <list of values>);

Example-Insert into StudentValues(1, ‘Amit Sharma’, ’12-Jun-1990’, ‘Jaipur’);

Note: The sequence of values should be matched with the order of column definition in the table, otherwise we should give the column names along with table name.

6. Delete: It is used to delete a record(s) from the table.Syntax : Delete From <table name> [ Where <condition>];Example-

1. Delete from Students;It will delete all the records from the table students.

Study Material – Class XII (Comp.Sc.) :: 39:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 40: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

2. Delete from students where city = ‘Ajmer’;It will delete all the records of students who belong to the Ajmer city only.

7. Select : It is the most commonly used SQL command, and used to access the records from the table or a group of tables.

Syntax :SELECT [distinct] <column list> FROM <table list>[WHERE <condition>][Order by <column name> [Asc|Desc]];

Examples:select * from students;- It lists all data from the table students.select rollno, name from students;- It displays only rollno and name of the students from the Student table.select * from students where class = 12;- It displays data from table students for class 12 only.select * from students where class = 12 and city = ‘Jaipur’;- It displays data whose class is 12 and city is Jaipur.select name from students where name like ‘A%’;- It displays name of students which is started with ‘A’ character.select distinct city from students;- It displays the distinct value of city column from the table students.select rollno, name from students order by dob;- It displays rollno and name from the table students in ascending order of their dob.select rollno, name from students order by dob desc;- It displays rollno and name from the table students in descending order of their dob.

SQL Functions :

SQL supports several functions which can be used to compute and access numeric, character and date columns of a table. These functions can be applied on a group of rows. These functions return only one value for a group and therefore, they are called aggregate or group functions. The examples of commonly used functions are-

SUM() :Select sum(salary) from employee;AVG() :Select avg(salary) from employee;MIN() :Select min(salary) from employee;MAX() :Select max(salary) from employee;COUNT():Select count(*) from employee;

Group By Clause :The rows of a table can be grouped together based on a common value by using the Group By clause in the Select command in SQL.

Study Material – Class XII (Comp.Sc.) :: 40:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 41: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Syntax:SELECT <Aggregate function<column name>, <column name >…..FROM <table(s)>GROUP BY <column name>;Example.

Select age, count (rollno)From studentGroup by age;

Output :Age Count(rollno)12 317 214 5

Group-By-Having Clause :It is used to apply some condition on the Group. Note that Having clause can be used only with Group By clause.

Example: Select classFrom studentsGroup by classHaving count(*) > 5;

This query will display the class of students in which more than five students are enrolled.

Study Material – Class XII (Comp.Sc.) :: 41:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 42: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Questions and Answers

2 Mark Questions

Q1. What is a relation? What is the difference between a tuple and an attribute? Ans. A relation is a table having atomic values, unique rows and unordered rows and columns.

A row in a relation is known as tuple where as a column in a relation is called as Attribute. Q2. Explain the following terms; (a) Primary Key (b) Candidate KeyAns Primary Key: A set of one or more attributes that can uniquely identify tuples within the relation.

Candidate Key: All attribute combination inside a relation (with table) that can serve as Primary Key.

Q3. Define the following terms: (i) Degree (ii) CardinalityAns (i) Degree: The number of attributes (columns) in a relation determines the degree of a relation.

(ii) Cardinality: The number of tuples (rows) in a relation is called the cardinality of the relation.Q4. What is Data Model? Explain the name of Data Model.Ans A Data Model is a collection of conceptual tools for describing data, data relations etc.

Three Types of Data Model used are: - 1. Relational Model 2. Network Model 3. Hierarchical Model

Q5. What is the difference between Primary Key and Alternate Key?Ans Set of one or more attributes that can uniquely identify tuples within the relation is called Primary

Key where as a candidate key is not the primary key is called an alternate key.Q6. Explain Database System and its advantages.Ans Database is a collection of different kinds of data which are organized in such a way so that insertion, deletion, updation, sorting and searching becomes easier. Telephone Directory is the common example of Database.

Advantages 1. It reduce the data redundancy 4. Control data inconsistency2. Facilitate sharing of data 5. Databases enforce standards3. Ensure data security 6. Integrity can be maintained

Q7. What are DDL and DML?Ans Data Definition Language (DDL) allows us to perform tasks related to Define Data information.

Commands used in DDL are: CREATE , ALTER, DROP etc.

Data Manipulation Language (DML) allows to modify the data values available inside the table Commands used in DML are: DELETE, UPDATE, INSERT etc.

6 Marks Questions

Q8. Consider the following tables GAMES and PLAYER. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii)

GAMESGCode GameName Number PrizeMoney Date101 CaromBoard 2 5000 23-jan-2004102 Badminton 2 12000 12-dec-2003103 TableTennis 4 8000 14-feb-2004104 Chess 2 9000 01-jan-2004105 LawnTennis 4 25000 19-mar-2004

PLAYERPCode Name GCode1 Arjun 101

Study Material – Class XII (Comp.Sc.) :: 42:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 43: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

2 Ravi 1053 Jignesh 1014 Nihir 1035 Sohil 104

I. To display the name of players who plays CaromBoard.II. To display details of those game which are having PrizeMoney more than 8000.III. To display the details of those games whose name starts from character ‘B’.IV. To display the details of those games which start after 01-jan -2004.V. Select COUNT(DISTINCT number) from games;VI. Select MAX(date) , MIN(date) from games;VII. Select AVG(PrizeMoney) from games Group by Number Having count(GCode) > 2;VIII. Select GameName from games Where date BETWEEN ’10-Jan-2004’ AND ’20-Feb-2004’;

Ans I. Select name from player, games where gamename=’CaromBoard’ and player.Gcode=Games.Gcode;

(II) Select GameName from games where PrizeMoney>8000; (III) Select GameName from games where GameName like ‘B%’; (IV) Select * from Games where date >’ 01-jan -2004’; (V) 2

4 (VI) MaX Date Min Date

19-mar-2004 12-dec-2003 (VII) 16500 (VIII) CaromBoard Table TennisQ9. Consider the following tables EMPLOYEES and EMPSALARY. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii)

EMPLOYEESEMPID FNAME LNAME ADDRESS CITY010 Akash Kumar Malviya Nagar Jaipur105 Ajit Singh Delhi Road Agra152 Mohit Nayak Bandra Mumbai215 Deepak Narwal Holy Palace Mumbai225 Aman Soni Palwal Haryana

EMPSALARYEMPID SALARY BENEFITS DESIGNATION010 15000 2000 Manager105 12000 1500 Manager152 8000 800 Salesman215 10000 1000 Clerk225 16000 2000 Manager

i. To display Fname, Lname, Address and City of all employees living in Mumbai from the table EMPLOYEES.

ii. To display the content of EMPLOYEES table in descending order of Fname.iii. To display the Fname, Lname and Total Salary of all Managers from the Table EMPLOYEES

and EMPSALARY, where Total Salary is calculated as Salary + Benefits.iv. To display the Maximum Salary among Managers and Clerks from the table EMPSALARYv. Select FName, Salary from EMPLOYEES, EMPSALARY where DESIGNATION=‘Salesman’

AND EMPLOYEES.EMPID= EMPSALARY.EMPIDvi. SELECT Count (Distinct Designation) from EMPSALARY

Study Material – Class XII (Comp.Sc.) :: 43:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 44: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

vii. SELECT designation, SUM (Salary) from EMPSALARY Group by Designation Having count (*) >2;

viii. Select Sum (Benefits) from EMPLOYEES where DESIGNATION IN(‘clerk’, ‘manager’);Ans

i. Select Fname, Lname, Address, City from Employees where city=’Mumbai’;ii. Select * from Employees ORDER BY Fname Desc;iii. Select Fname, Lname, Salary +Benefits ‘Total Salary’ from Employees, Empsalary where

Employees.EMPID = Empsalary.EMPID;iv. Select MAX (Salary) from Empsalary Group By Designation having Designation IN

(‘Manager’, ‘Clerk’);v. Mohit 8000vi. 3vii. Manager 43000viii. 6500

Q10. Consider the following tables Books and Issued. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii)

Table: BooksBookId BookName AuthorName Publishers Price Type QtyC0001 Fast Cook Lata Kapoor EPB 355 Cookery 5F0001 The Tears William First Publ 650 Fiction 20T0001 My First C++ Brain& Brooke EPB 350 Text 10T0002 C++ Brainworks A.W. Rossaine TDH 350 Text 15F0002 Thunderbolts Anna Roberts First Publ 750 Fiction 50

Table: IssuedBookId QuantityIssuedT0001 4C0001 5F0001 2

i. To show Book Name, Author Name and Price of books of First Publ Publishersii. To list the names from books of Text typeiii. To display the names and price from books in ascending order of their price.iv. To increase the price of all books of EPB publishers by 50v. To display the BookId, BookName and QuantityIssued for all books which have been issuedvi. To insert a new row in the table Issued having the following data : “F0003” , 1vii. Give the output of the following queries based on the above tables:

(a) Select Count(*) from Books;(b) Select Max(Price) from Books where Quantity >= 15;(c) Select BookName, AuthorName from Books where Publisher =”EPB”;(d) Select Count (Distinct Publishers) from Books where Price>=400;

Ans.i. Select BookName, AuthorName, Price from Books

where Publishers= ‘First Publ’;ii. Select BookName from Books where Type=’text’;iii. Select name, price from books order by price;iv. Update set price = price + 50 where publisher= ‘EPB’;v. Select BookId, BookName, QuantityIssued from Books, Issued where Books.BookId =Issued.BookId;vi. Insert into Issued values ( ‘F0003’,1);

(a) 5(b) 750

Study Material – Class XII (Comp.Sc.) :: 44:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 45: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

(c) Fast Cook Lata Kapoor My First C++ Brain & Brooke(d) 2

Study Material – Class XII (Comp.Sc.) :: 45:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 46: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

CHAPTER- 9 : Boolean Algebra

Key Points:

Boolean algebra (or Boolean logic) is a logical calculus of truth values, developed by George Boole in the 1840s. Boolean algebra is the algebra of two logical values. These are usually taken to be 0 (False) and 1(True).

Minterm => A minterm is a product of all the literals within the logic system.Maxterm => A maxterm is a sum of all the literals within the logic system.Canonical form => A Boolean expression composed entirely either of minterms or maxterms, is referred to as canonical expression.

Important postulates/Laws of Boolean algebra:

■ The Associative Law○ X + (Y + Z) =(X + Y) + Z○ X.(Y.Z)=(X.Y).Z

■ The Distributive Law○ X.(Y + Z) = X.Y + X.Z○ X + Y.Z = (X + Y) (X +Z)

■ Commutative Law○ X + Y = Y + X○ X.Y = Y.X

■ Absorption Law○ X + X.Y = X○ X.(X + Y) = X

■ Idempotent Law○ X + X = X○ X.X = X

■ Involution Law○ (X’)’ = X

■ Complementarity Law○ X + X’ = 1○ X.X’ = 0

■ De Morgan’s Theorem○ (X + Y)’ = X’.Y’○ (X .Y)’ = X’ + Y’

Questions and Answers

1 Mark Questions

Q1. Write the equivalent Boolean expression for the following logic circuit.

Answer: - F=A.B’+C’.D

Q2. Write the equivalent Boolean expression for the following logic circuit:-

Study Material – Class XII (Comp.Sc.) :: 46:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 47: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Answer:- F=W.X’+Y’.Z

Q3. Write the equivalent expression for the following Logic Circuit:-

Answer: - F= (A+C)’.(A+B)’.(B+C)’

Q4. Write the equivalent expression for the following Logic Circuit:-

Answer: - F=(A+C).(A+B).(B+C)’

Q5. Write the equivalent expression for the following Logic Circuit:

Answer:- X.Y’+X’.Y+X’.Y’

Q6. Represent the Boolean expression X.Y+Y.Z with the help gatesAnswer:-

Q7. Represent the Boolean expression X+Y’.Z with the help Gates.

Answer:-

Q8. Represent the Boolean expression X’.Y.+Y’.Z with the help Gates.

Answer:-

Study Material – Class XII (Comp.Sc.) :: 47:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 48: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Q9. Represent the Boolean expression A.B.+A’.B’ with the help Gates.Answer:-

Q10. Represent the Boolean expression A’.B’+A’.C with the help Gates.Answer:-

2 Mark Questions

Q1. State De Morgan’s Theorems and verifies the same using truth table.Answer: - This theorem states that:-

(X.Y)`=X`+Y`Proof from truth table:-

X Y X.Y (X.Y)`(LHS) X` Y` X`+Y`(RHS)0 0 0 1 1 1 10 1 0 1 1 0 11 0 0 1 0 1 11 1 1 0 0 0 0

Since LHS=RHL, hence proved

Q2. State Distributive law and verify the same using truth table.Answer: - This theorem states that:-

X(Y+Z)=X.Y+X.Z

X Y Z Y+Z X.(Y+Z) LHS XY XZ X.Y+X.Z RHS0 0 0 0 0 0 0 00 0 1 1 0 0 0 00 1 0 1 0 0 0 00 1 1 1 0 0 0 0

Study Material – Class XII (Comp.Sc.) :: 48:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 49: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

1 0 0 0 0 0 0 01 0 1 1 1 0 1 11 1 0 1 1 1 0 11 1 1 1 1 1 1 1

Since LHS=RHL hence proved

Q3. State and verify Associative Law.Answer: - This theorem states that:-

1ST Law X+(Y+Z)=(X+Y)+Z2nd LawX.(Y.Z)=(X.Y).Z

Proof - 1ST Law X+(Y+Z)=(X+Y)+Z

X Y Z Y+Z X+(Y+Z) LHS X+Y (X+Y)+Z RHS0 0 0 0 0 0 00 0 1 1 0 0 00 1 0 1 0 0 00 1 1 1 0 0 01 0 0 0 0 0 01 0 1 1 1 0 11 1 0 1 1 1 01 1 1 1 1 1 1

Since LHS=RHL hence provedProof - 2nd Law X.(Y.Z)=(X.Y).Z

X Y Z Y.Z X.(Y.Z) LHS X.Y (X.Y).Z RHS0 0 0 0 0 0 00 0 1 0 0 0 00 1 0 0 0 0 00 1 1 1 0 0 01 0 0 0 0 0 01 0 1 0 0 0 01 1 0 0 0 1 01 1 1 1 1 1 1

Study Material – Class XII (Comp.Sc.) :: 49:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 50: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Since LHS=RHL hence proved

Q4. State and verify Absorption Law in Boolean algebra.Answer: - This theorem states that:-

1ST Law X+XY=X2nd Law X.(X+Y)=X

Proof of 1ST Law X+XY=XL.H.S

=X+XY=X(1+Y) From Distribution Law=X.1 From OR Law 1+Y=1=X From AND Law X.1=XR.H.S. Hence Proved

Proof of 2nd Law X.(X+Y)=XL.H.S=X.(X+Y)=X.X+XY From Distribution Law=X+X.Y From AND Law X.X=X=X(1+Y) From Distribution Law=X.1 From OR Law 1+Y=1=X From AND Law X.1=XR.H.S. Hence Proved

Q5. State and Verify Duality Principal.Answer: - This theorem states that:-

Principal of duality in Boolean algebra states that from every Boolean relation, another Boolean relation can be derived by

(i) Changing (+) with (.)(ii) Changing (.) with (+)(iii) Replacing 1 by 0 and 0 by 1.If Eq1 is X+1=1 THEN Eq2 is X.0=0

Verification:-

X 1 X+1=1 Eq1 X 0 X.0=0 Eq20 1 1 0 0 01 1 1 1 0 0

Q6. Write the equivalent canonical product of sum expression for the following sum of product expression: F(X, Y, Z) = Σ (0, 2, 4, 5).Answer:-

If there is 3 variable i,e. X,Y, Y then there is total 8 number in the set that are (0,1,2,3,4,5,6,7).

Study Material – Class XII (Comp.Sc.) :: 50:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 51: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Now compare these set with given set and drop those which are common, rest of the number is the answer. Hence in this example 0, 2, 4, 5 are common then drop them and rest numbers are

F(X,Y,Z)= π(1,3,6,7)

Q7. Write the equivalent canonical product of sum expression for the following sum of product expression: F(X, Y, Z) = Σ (1, 3, 6, 7).Answer:-

If there is 3 variable i,e. X,Y, Y then there is total 8 number in the set that are (0,1,2,3,4,5,6,7).

Now compare these set with given set and drop those which are common, rest of the number is the answer. Hence in this example 1,3,6,7 are common then drop them and rest numbers are

F(X,Y,Z)= π(0, 2, 4, 5)

Q8. Write the equivalent canonical form as sum of product expression for the following product of sum expression: (X’+Y+Z’).(X’+Y+Z).(X’+Y’+Z’)

Answer :- First Draw the table of Max term, Now compare in with one pair of sum is matched placed a 0 on corresponding.Now place the Min term that is 1 in rest of position in function F, Now chose Min term corresponding to 1 with sum that is :-=X`.Y`.Z`+ X.Y.Z`+ X`.Y.Z+ X`.Y.Z`+ X`.Y`.Z Answer

X Y Z MAXTERM F MINTERM0 0 0 X+Y+Z 1 X`.Y`.Z`0 0 1 X+Y+Z` 1 X`.Y`.Z0 1 0 X+Y`+Z 1 X`.Y.Z`0 1 1 X+Y`+Z` 1 X`.Y.Z1 0 0 X`+Y+Z 0 X.Y`.Z`1 0 1 X`+Y+Z` 0 X.Y`.Z1 1 0 X`+Y`+Z 1 X.Y.Z`1 1 1 X`+Y`+Z` 0 X.Y.Z

Q9. Write the equivalent canonical SOP expression for the following POS expression: (X+Y+Z).(X’+Y’+Z).(X’+Y’+Z’)

Answer :- First Draw the table of Max term, Now compare in with one pair of sum is matched placed a 0 on corresponding.Now place the Min term that is 1 in rest of position in function F, Now chose Min term corresponding to 1 with sum that is = X.Y`.Z+ X.Y`.Z`+ X`.Y.Z+ X`.Y.Z`+ X`.Y`.Z Answer

X Y Z MAXTERM F MINTERM0 0 0 X+Y+Z 0 X`.Y`.Z`0 0 1 X+Y+Z` 1 X`.Y`.Z0 1 0 X+Y`+Z 1 X`.Y.Z`0 1 1 X+Y`+Z` 1 X`.Y.Z1 0 0 X`+Y+Z 1 X.Y`.Z`1 0 1 X`+Y+Z` 1 X.Y`.Z1 1 0 X`+Y`+Z 0 X.Y.Z`1 1 1 X`+Y`+Z` 0 X.Y.Z

Q10. Write the equivalent canonical SOP expression for the following POS expression: (X+Y’+Z’).(X+Y’+Z).(X+Y+Z’)

Study Material – Class XII (Comp.Sc.) :: 51:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 52: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Answer :- First Draw the table of Max term, Now compare in with one pair of sum is matched placed a 0 on corresponding.Now place the Min term that is 1 in rest of position in function F, Now chose Min term corresponding to 1 with sum that is

X.Y.Z + X.Y`.Z + X.Y`.Z` + X`.Y.Z + X`.Y`.Z`

X Y Z MAXTERM F MINTERM0 0 0 X+Y+Z 1 X`.Y`.Z`0 0 1 X+Y+Z` 0 X`.Y`.Z0 1 0 X+Y`+Z 0 X`.Y.Z`0 1 1 X+Y`+Z` 1 X`.Y.Z1 0 0 X`+Y+Z 1 X.Y`.Z`1 0 1 X`+Y+Z` 1 X.Y`.Z1 1 0 X`+Y`+Z 0 X.Y.Z`1 1 1 X`+Y`+Z` 1 X.Y.Z

3 Mark Questions

Q1. Reduce the following Boolean expression using K - Map :F(A, B, C, D,) = π (5, 6, 7, 8, 9, 12, 13, 14, 15)Answer:- Place 0 at the place of numbers and then creates pairs of possible 2 or 4 or 8 or 16 maxterm

CDAB 00 01 11 1000

0 1 3 2

014 5

070

60

11120

130

150

140

1080

90

11 10

Answer:- F=(A`+C).(B`+D`).(B`+C`)

Q2. Reduce the following Boolean expression using K . Map :F(U, V, W, Z) = Σ(0,1,2,3,4,10,11)

Answer:- Place 1 at the place of numbers and then creates pairs of possible 2 or 4 or 8 or 16 minterm F(U, V, W, Z )=U’.V’+V’.W+U’W’Z’

WZUV 00 01 11 10

Study Material – Class XII (Comp.Sc.) :: 52:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 53: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

0001

11

31

21

0141

5 7 6

1112 13 15 14

108 9 11

1101

Q3. Reduce the following Boolean expression using K . Map :F(A, B,C, D,) = π (0,3,5,6,7,11,12,15)

Answer:- Place 0 at the place of numbers and then creates pairs of possible 2 or 4 or 8 or 16 maxterm

Answer is – (C’+D’).(A+B’+D’).(A+B’+C’).(A+B+C+D).(A’+B’+C+D)

Q4. Reduce the following Boolean expression using K . Map :F(U, V, W, Z) = Σ(0,1,2,3,4,10,11)Answer:- Place 1 at the place of numbers and then creates pairs of possible 2 or 4 or 8 or 16 minterm

WZUV 00 01 11 1000

01

11

3 1

21

014 5 7 6

Study Material – Class XII (Comp.Sc.) :: 53:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 54: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

1112 13 15 14

10 8 9 11

1

10

1

Answer:- U’.V’+V’.W

Q5. Reduce the following Boolean expression using K . Map :F(P, Q, R, S,) = Σ(0,3,5,6,7,11,12,15)

Answer:- Place 1 at the place of numbers and then creates pairs of possible 2 or 4 or 8 or 16 minterm F=R.S+P’.Q.S+P’.Q.R+P’.Q’.R’.S’+P.Q.R`.S`

RSPQ 00 01 11 1000

0 1

1 3 1

2

014 5

17 1

61

1112 1

13 15 1

14

108 9 11

110

Q6. Reduce the following Boolean expression using K . Map :F(A, B, C, D,) = Σ(0,1,2,3,4,5,10,11,15)

Answer:- Place 1 at the place of numbers and then creates pairs of possible 2 or 4 or 8 or 16 minterm F=A’.C’+A’.B’+A.C.D

CDAB 00 01 11 1000

01

11

31

21

Study Material – Class XII (Comp.Sc.) :: 54:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 55: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

014 1

5 1

7 6

1112 13 15

114

108 9 11

110

Q7. Obtain a simplified form for a Boolean expression:F( U, V, W,Z) = π0,1,3,5,7,9,10,11,12,13,14,15) (Answer:- Z’.(U’+W’).(U+V+W).(U’+V’+W)

WZUV 00 01 11 1000

00

1 0

30

2

014 5

070

6

1112 0

13 0

150

140

108 9

0110

100

Study Material – Class XII (Comp.Sc.) :: 55:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 56: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

CHAPTER- 10 : Communication and Network Concepts

Key Points:

A network is a collection of interlinked computers by means of a communication system. It facilitates resource sharing, increased reliability, reduced costs, and increased fast communication.

Today’s Internet has evolved from ARPANET (Advanced Research Projects NETwork) of U.S Department of Defense.

Switching:-Techniques that are used for transmitting data across the network. Various switching techniques are:- Circuit switching:- where complete physical connection is setup prior to communication.

Message switching:- which follows store and forward principal for complete message. Packet switching:- which follows store and forward principle for packets.

Transmission media:-A network can have any of these transmission media: Twisted pair cable, Coaxial cable, Optical

fiber, Microwave, Radio wave, Satellite etc.

Types of Network:- On the basis of geographical spread, networks can be classified into LAN (Local Area Network), MAN(Metropolitan Area Network) and LAN(Local Area Network).

RJ 45 (Registered Jack 45) is a eight wire connector, which is commonly used to connect computers on LANs – especially Ethernets.

Repeater is a device that amplifies a signal being transmitted on the network.

Bridge is a device that links two identical networks together.

Protocol: - A protocol means the set of rules. Protocol defines standardized formats for data packets, techniques for detecting and correcting errors and so on. Some most common protocols are

HTTP (Hyper Text Transfer Protocol) FTP (File Transfer Protocol), TCP/IP (Transmission Control Protocol/Internet Protocol)

Wireless communication is simply data communications without the use of wires.

TDMA:-Time Division Multiple Access technology divides a radio frequency into time slots and then allocates allots to multiple calls.

CDMA:-Code Division Multiple Access uses a spread spectrum technique where data is sent in small pieces over a number of discrete frequencies available for use. Each user’s signal is spread over the entire bandwidth by unique spreading code. At the receivers end, the same unique code is used to recover the signal.

SMS(Short Message Service) is the transmission of short text message to and from mobile phone and computer.

Email (Electronic Mail) is sending and receiving message by computer.A web Browser is a WWW client that navigates through the World Wide Web and displays web pages .A web server is a WWW server that responds to the request made by web browser.

Study Material – Class XII (Comp.Sc.) :: 56:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 57: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

URL(Uniform Resource Locator) specifies the distinct address for each resource on the internet. An Internet address, which is character, based is called domain name.

Cookies are messages that a Web server transmits to a web browser so that the web server can keep track of the user’s activity on a specific Web site.

Viruses are malicious program that damage data and files and cause harm to computer system. eg- Trojan horses, worms.

Topologies: The pattern of interconnection of nodes in a network is called topology. Most popular topologies are Star, Bus, Ring, Mesh, Tree.

Questions and Answers

1 Mark Questions

Q.1 What are Routers?Answer:- A Router is a network device that is used to separate different segments in a network to improve performance and reliability. A router works like a bridge but can handle different protocols.

Q.2 Define the following:-(i) Hub (ii) SwitchAnswer:-Hub:- A hub is a hardware device used to connect several computers together. Hubs can be either passive or active.Switch:- A switch is a device that is used to segment networks into different sub-networks called subnet.

Q.3 What is the difference between LAN and MAN?Answer:-Small computer networks that are confined to a localized area such as building, campus and organization are known as Local Area Network(LAN) whereas MAN are networks spread over a city eg- cable TV.

Q.4 What is chatting? Is it necessary to be online while chatting?Answer:-Online textual talk, in real time , is called Chatting.

Yes, it is necessary to be online while chatting.

Q.5 Write two advantages and disadvantages for STAR topology.Answer:- Advantages of STAR topology:

● Centralized distribution and control.● Easy to build and access

Disadvantages of STAR topology:● Central node dependency● Use of more cable length.

Q6. What are firewalls?Answer:- Firewalls are defensive barriers that fence off a private network from the internet. It is used to define limited access of network resources

Q7. What are cookies?Answer:- A Cookie is messages given to a web browser by a web sever during accessing of a web site involving user name and password etc.

Q. 8. What are bridge and gateways?Answer:- Bridge:- A bridge is a network device that established an intelligent connection between two similar networks with the same protocols.

Study Material – Class XII (Comp.Sc.) :: 57:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 58: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Gateway: - A Gateway is a device that connects dissimilar networks, having different protocols.

Q.9. How is Coaxial cable different from Optical Fiber?Answer:- Coaxial cable:- It consist of a solid wire core surrounded by one or more foil or braided wire shields, each separated from the other by some kind of insulators. Coaxial cable carries electrical signals. Optical Fiber: - It is made with thin strands of glass or glass-like material known as Fiber, which are able to carry light signals from the source to destination. The main advantage of this cable is their complete immunity to noise and faster speed.

Q. 10. What is Telnet? What does it do?Answer:- The telnet is a facility that facilitates remote login. Remote login is the process of accessing a network from the remote place without actually being present at the actual place of working.

2 Mark Questions

Q.11 What is the difference between XML and HTML? Write two differences.

Answer:- The major differences between XML and HTMLXML HTML-Doesn’t specify either semantics or tag set.-It is a language for documents containing structured information and all semantics are defined by the applications that process them.

-The semantics and tag set are fixed.-It is a language used to design the layout of a document and to specify the hyperlinks.

Q12. Expand the following terminologies:(i) TCP/IP (ii) XML (iii) CDMA (iv) WLL Answer:-

(i) TCP/IP:- Transmission Control Protocol/Internet Protocol(ii)XML:- eXtensible Markup Language(iii)CDMA:- Code division Multiple access(iv) WLL:- Wireless Local Loop.

Q13. What is a Modem? What is its function?

Answer:- A modem is a computer peripheral that connects a workstation to other workstation via telephones lines and facilitates communications. It is short form for modulation/Demodulation.

Modem converts digital signals to analog signals (A/F (Audio Frequency)) tones which are in the frequency range that the telephone lines can transmit and also it can convert transmitted tones back to digital information.

Q.14 How is a Hacker different from a Cracker?Answer:-Hackers: These are he persons who get unauthorized access to the websites and replace them with other website or unlawful information.Crackers: The Persons by using certain software to trap authenticated information to crack the security codes such as user names and password to illegally access the information on computers are called crackers.

Q.15 What is the significance of Cyber Law?Answer:- Cyber law is punishable act and bound to all the peoples who involved in transactions using cyber technologies, suitable punishments can be awarded under cyber crime act and its various sections before the Court of Law.

Q.16 Differentiate between Internet and Intranet.

Study Material – Class XII (Comp.Sc.) :: 58:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 59: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Answer:- Internet is a Network of networks spread over the Globe which are interconnected by various media know as backbone and satellite also.Intranet is a network that exists exclusively within an organization and that is based on Internet Technology and designed to facilitate the customers as well as concerned people.

Q.17 Write one advantage of BUS topology as compared to STAR topology.Answer: - Finding Fault or Error in star topology is easier than bus topology. Since faulty node can easily be identified in the network, by removing its connection from the center Hub/Switch may solve the problem but in a bus topology, a faulty node must be rectified at the point where the node is connected to the network.

Q.19 Expand the following terms:(i) FTP (ii) HTML (iii) GSM (iv) WWWAnswer:- (i) File Transfer Protocol

(ii) Hyper Text Markup Language (iii) Global system for Mobile Communication (iv) World Wide Web

Q.20 Expand the following terms:(i) LAN (ii) SMS (iii) MAN (iv) CDMA Answer:- (i) Local Area Network (ii) Short Message Service (iii) Metropolitan area Network (iv) Code Division Multiple Access

Q.21 Expand the following terms:

(i) HTTP (ii) SMTP (iii) PPP (iv) URLAnswer:- (i) Hypertext Transfer Protocol

(ii) Simple Mail Transfer Proctocol (iii) Point to Point Protocol (iv) Uniform Resource locator

Q.22 Expand the following terms:

(i) MODEM (ii) RJ-45 (iii) ARPANET (iv) ISP Answer:- (i) MOdulator DEModulator

(ii) Registered Jack-45(iii) Advanced Research Projects Agency(iv) Internet Service Provider

4 Mark Questions

Q.23 “Bhartiya Connectivity Association” is planning to spread their offices in four major cities in India to provide regional IT infrastructure support in the field of Education & Culture. The company has planned to setup their head office in New Delhi in three locations and have named their New Delhi offices as “Front Office”, and “Back Office” and “Work Office” located in other three major cities of India. A rough layout of the same is as follows:

INDIAEAST OFFICENEW DELHIFRONT OFFICEWORK OFFICEBACK OFFICEWEST OFFICESOUTH

Study Material – Class XII (Comp.Sc.) :: 59:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 60: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

OFFICE

Approximate distances between these offices as per network survey team are as follows:Place From Place To DistanceBack Office Front office 10 KMBack Office Work office 70 MeterBack Office East office 1291 KMBack Office West office 790 KMBack Office South office 1952 KM

In continuation of the above, the company experts have planned to install the following number of computers in each of their offices:

Back Office 100Front Office 20Work Office 50East Office 50West Office 50South Office 50

(i) Suggest network type for connecting each of the following sets of their offices:

■ Back Office and Work Office ■ Back Office and South Office

(ii) Which device you will suggest to be produced by the company for connecting all the computers within each of their offices out of the following devices?

a. Hub/Switch b. Modem c. Telephone (iii) Which of the following communication medium, you will suggest to be produced by the company for connecting their local offices in New Delhi for very effective and fast communication.

a. Telephone cable b. Optical Fiber c. Ethernet Cable (iv) Suggest the layout for connecting each office.

Answers:-i. MAN

WANii. Hub/Switch required connecting computers of their officesiii. Optical Fiber.iv. Cable Layout:

INDIAEAST OFFICE

Study Material – Class XII (Comp.Sc.) :: 60:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 61: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

NEW DELHIFRONT OFFICEWORK OFFICEBACK OFFICEWEST OFFICESOUTH OFFICE

Q. 24 The cyber mind organization has set up its new branch at Delhi for its office and web activities. It has 4 blocks of buildings as shown in diagram:

Block ABlock BBlock CBlock D

Distance between various Blocks: Number of ComputersBlock A to Block B----- 40 mtr Block A ----- 25Block B to Block C----- 120 mtr Block B ----- 50Block C to Block D----- 60 mtr Block C ----- 125Block A to Block D----- 170 mtr Block D ----- 10Block B to Block D----- 150 mtrBlock A to Block C----- 70 mtr

(i) Suggest the most suitable place to house the server of this organization with a suitable reason with justification.(ii) Suggest a most suitable cable layout of connections between the Wing and topology.(iii) Suggest the placement of the following device with justification:Repeater Hub/Switch(iv) The organization is planning to link its head office situated in the city in hilly region where cable connection is not feasible, suggest an economic way to connect it with reasonably high speed.

Study Material – Class XII (Comp.Sc.) :: 61:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 62: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

Answer:- (i) The most suitable place/block to house the server of this organization would be Block C, as this block contains the maximum number of computers, thus decreasing the cabling cost for most of the computers as well as increasing the efficiency of the maximum computers in the network.

b) Star Topology Total Length of cable required: 70 + 120 + 60

(ii) a) Bus Topology Total length of cable required: 40 + 70 + 60 = 170 mtrs

Block ABlock BBlock CBlock D

(iii) In Bus Topology only a Repeater required between Block A & Block C because the distance is large.In Star Topology Repeater required between Block A & Block C and that between Block B & Block CA Hub/Switch required interconnecting the different computers in each block.

(iv) The most economic way to connect it with a reasonable high speed would be use radio wave transmission, as they are easy to install, can travel long distances, and penetrate buildings easily, so they are widely used for communication, both indoors and outdoors. Radio waves also have the advantage to being omni directional.

ACBDQ25. A industry has setup its new center at Canaught Place for its office and web based activities. The company compound has 4 buildings as shown in diagram:

Distance between various Blocks: Number of ComputersBlock A to Block B ----- 60 mtr Block A ----- 150Block B to Block C ----- 125 mtr Block B ----- 15Block C to Block D ----- 170 mtr Block C ----- 15Block A to Block D ----- 90 mtr Block D ----- 25Block B to Block D ----- 25 mtrBlock A to Block C ----- 50 mtr

Study Material – Class XII (Comp.Sc.) :: 62:: Kendriya Vidyalaya Sangathan, Jaipur Region

Page 63: :: Kendriya Vidyalaya Sangathan, Jaipur Region · The influence of technology forced CBSE to introduce Computer Science, ... Data Communication & Network Concepts 55 ... Class XII

(i) Suggest the most suitable place to house the server of this organisation with a suitable reason.(ii) Suggest a cable layout of connections between the buildings.(iii)Suggest the placement of the following device with justification:Internet Connecting Device Hub/Switch(iv) The organization is planning to link its sale counter situated in various parts of the same city, which type of network out of LAN, MAN or WAN will be formed? Justify.

(b) Star Topology Total Length of cable required: 60 + 125 + 25 = 210 mtrs

(i) The most suitable place/building to house the server of this organization would be Building A,

as this block contains the maximum number of computers, thus decreasing the cabling cost for most of the computers as well as increasing the efficiency of the maximum computers in the network.

(ii) (a) Bus TopologyTotal length of cable required: 50 + 60 + 25 = 135 mtrs

BCAD ACBD

(iii) Building A – Internet Connecting DeviceA Hub/Switch required to interconnecting different computers in each block. (iv) MAN is the suitable network because MAN is the networks that link computer facilities within a city.

Study Material – Class XII (Comp.Sc.) :: 63:: Kendriya Vidyalaya Sangathan, Jaipur Region