Sure Success 1-14 CS XII

37
Computer Science, Class XII, 2010-11 Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected] , 9950589919 1 Chapter No.1 (C++ Revision Tour) 1. Why main function is so special in C++. Give at least two reasons? /* CBSE 1999 */ 2. Differentiate between call by value & call by reference with a suitable example in C++. /*CBSE 2005, 2009, 2010 */ 3. What do you mean by actual parameter and formal parameter? Explain with an example? /*CBSE 2009 */ 4. Differentiate between global & local variable with a suitable example in C++. /* CBSE 2003 */ 5. Illustrate the use of #define in C++ to define a macro. /* CBSE 2006 */ 6. What do you mean by compile time and run time error? Give one example of each? 7. Difference between syntax and semantic error? Explain with an example? 8. What do you understand by syntax error, logical error & run time error? Explain with example. /*CBSE 2007 */ 9. Differentiate between break and continue statements. 10. How is entry controlled loop different from exit controlled loop? Explain with one example of each? 11. What do you mean by scope and lifetime of a variable? 12. What is the purpose of using a typedef command in C++. Explain with suitable example. /* CBSE 2008 */ 13. What is the difference between a typedef name and a reference name in C++? Explain with suitable example. 14. Difference between i) structure & array ii) structure & class. 15. What is variable scope? What is the difference between Local and Global scope? Explain with an example. 16. What are Nested Structures? Give an example. /* CBSE 2006 */ 17. What is the difference between #define & const? Explain through example. /* CBSE 2008 */ 18. Name the Header file(s) that shall be needed for successful compilation of the following C++ code? i) void main() { char st[20]; gets(st); if(isaplha(st[0]) cout<<”Starts with alphabet”; else cout<<strlen(st); } ii) void main( ) /*CBSE 2008 */ { char String[ ] = “Peace”; cout << setw(2)<<String; } iii) void main( ) /*CBSE 2007 */ { char String[20]; gets(String); strcat(String,”CBSE”); puts(String); }

description

Sure success.... if u read this...

Transcript of Sure Success 1-14 CS XII

Page 1: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 1

Chapter No.1(C++ Revision Tour)

1. Why main function is so special in C++. Give at least two reasons? /* CBSE 1999 */2. Differentiate between call by value & call by reference with a suitable example in C++.

/*CBSE 2005, 2009, 2010 */3. What do you mean by actual parameter and formal parameter? Explain with an example?

/*CBSE 2009 */4. Differentiate between global & local variable with a suitable example in C++. /* CBSE 2003 */5. Illustrate the use of #define in C++ to define a macro. /* CBSE 2006 */6. What do you mean by compile time and run time error? Give one example of each?7. Difference between syntax and semantic error? Explain with an example?8. What do you understand by syntax error, logical error & run time error? Explain with

example. /*CBSE 2007 */9. Differentiate between break and continue statements.10. How is entry controlled loop different from exit controlled loop? Explain with one

example of each?11. What do you mean by scope and lifetime of a variable?12. What is the purpose of using a typedef command in C++. Explain with suitable example.

/* CBSE 2008 */13. What is the difference between a typedef name and a reference name in C++? Explain

with suitable example.14. Difference between i) structure & array ii) structure & class.15. What is variable scope? What is the difference between Local and Global scope? Explain

with an example.16. What are Nested Structures? Give an example. /* CBSE 2006 */17. What is the difference between #define & const? Explain through example.

/* CBSE 2008 */

18. Name the Header file(s) that shall be needed for successful compilation of the followingC++ code?

i) void main(){ char st[20];

gets(st);if(isaplha(st[0])

cout<<”Starts with alphabet”;else

cout<<strlen(st);}

ii) void main( ) /*CBSE 2008 */{ char String[ ] = “Peace”;

cout << setw(2)<<String;}

iii) void main( ) /*CBSE 2007 */{ char String[20];

gets(String);strcat(String,”CBSE”);puts(String);

}

Page 2: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 2

19. Write the names of the header files to which the following functions belong.random( ), fabs( ), strcpy( ), gets( ), isupper(), tolower( ), isalnum( ), strcat( ), setw( ),abs( ), get( ), ceil( ), exit( ), floor( ), read( ), exp( ), open( ), puts( ), setprecision ( ),randomize( ), free( ), calloc( ), malloc( ), realloc( ), clrscr( ), strcmp( ), getc( ), scanf( ),getchar( ), printf( ), cos( ), gotoxy( ), getch( ), poly( ), sqrt( ), fseek( ), fopen( ), endl( ).

20. Rewrite the following program after removing the syntactical error(s) if any. Underlineeach correction.

i) #include<iostream.h> /* CBSE 2008 */void main( ){

First = 10, Second = 20;Jumpto(First;Second);Jumpto(Second);

}void Jumpto(int N1, int N2 = 20){

N1=N1+N2;count<<N1>>N2;

}

ii) #include<iostream.h> /* CBSE 2007 */const int Max 10;void main(){

int Numbers[Max];Numbers = {20,50,10,30,40};for(Loc=Max-1;Loc>=10;Loc--)

cout>>Numbers[Loc];}

iii) #include<iostream.h> /* CBSE 2005 */const int Multiple 3;void main( ){

Value = 15;for(int Counter = 1;Counter = <5;Counter ++, Value -= 2)

if(Value%Multiple = = 0)cout<<Value * Multiple;cout<<end1;

elsecout<<Value + Multiple <<endl; }

iv) #include<iostream.h> /* CBSE 2003 */void main( ){

int P[ ]={90,10,24,15};Q,Number=4;Q=9;for[int I=Number-1;I>=0,I--]

switch(I)

Page 3: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 3

{case 0;case 3:cout>>P[I]*Q<<endl;break;case 1:case 2: cout<<P[I]+Q;

}}

v) #include<iostream.h> /* CBSE 2006 */void main( ){struct STUDENT{

char stu_name[20];char stu_sex;int stu_age=17;

}student;gets(stu_name);gets(stu_sex);}

vi) #include <iostream.h>struct Pixels{ int Color,Style;}void ShowPoint(Pixels P){ cout<<P.Color,P.Style<<endl;}void main(){

Pixels Point1=(5,3);ShowPoint(Point1);Pixels Point2=Point1;Color.Point1+=2;ShowPoint(Point2);

}

21. Find the output of the following program:i) #include<iostream.h> /* CBSE 2008 */#include<ctype.h>void main( )

{char Text[ ] = “Mind@Work!”;for(int I=0; Text[I]!=”\0”;I++){

if(!isalpha(Text[I]))Text[I]=”*”;

else if(isupper(Text[I]))Text[I]=Text[I]+1;

elseText[I] = Text[I+1];

}

Page 4: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 4

cout<<Text;}

ii) #include<iostream.h> /* CBSE 2008 */void main( ){

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

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

}}iii) #include<iostream.h> /* CBSE 2007 */void Withdef(int HisNum=30){

for(int I=20;I<=HisNum;I+=5)cout<<I<<”,”;

cout<<endl;}void Control(int &MyNum){

MyNum+=10;Withdef(MyNum);

}void main(){

int YourNum=20;Control(YourNum);Withdef();cout<<”Number=”<<YourNum<<endl;

}iv) #include<iostream.h> /* CBSE 2005 */#include<string.h>#include<ctype.h>void Convert(char Str[ ],int Len){ for(int Count=0;Count<Len;Count++)

{if(isupper(Str[Count]))

Str[Count]=tolower(Str[Count]);else if (islower(Str[Count]))

Str[Count]=toupper(Str[Count]);else if(isdigit(Str[Count]))

Str[Count]=Str[Count]+1;else Str[Count]=”*”;

}}void main( ){char Text[ ]=”CBSE Exam 2005”;int Size = strlen(Text);

Page 5: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 5

Convert(Text,Size);cout<<Text<<endl;for(int C=0,R=Size - 1;C<=Size/2;C++,R--){

char Temp=Text[C];Text[C]=Text[R];Text[R]=Temp;

}cout<<Text<<endl;}

v) #include<iostream.h> /* CBSE 2004 */void main( ){

int var1=5,var2=10;for(int i=1;i<=2;i++){

cout<<var1++<<’\t’<< -- var2<<endl;cout<<var2--<<’\t’<<++ var1<<endl;

}}vi) #include<iostream.h> /* CBSE 2003 */int Execute(int M){if(M%3==0)

return M*3;else

return M+10;}void Output(int B=2){for(int T=0;T<B;T++)

cout<<Execute(T)<<”*”;cout<<endl;}void main( ){

Output(4);Output( );Output(3);

}

vii) #include<iostream.h> /* CBSE 2001 */#include<conio.h>int g=20;void func(int &x,int y){ x=x-y;

y=x*10;cout<<x<<”,”<<y<<’\n’;

}

Page 6: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 6

void main( ){ int g=7;

func(g,::g);cout<<g<<”,”<<::g<<’\n’;func(::g,g);cout<<g<<”,”<<::g<<’\n’;

}viii) #include<iostream.h> /* CBSE 2000 */int func(int &x,int y=10){ if(x%y==0) return ++x;else return y--; }void main( ){

int p=20,q=23;q=func(p,q);cout<<p<<q<<endl;p=func(q);cout<<p<<q<<endl;q=func(p);cout<<p<<q<<endl;

}ix) #include<iostream.h> /* CBSE 1998 */void Execute(int &X,int Y=200){

int TEMP=X+Y;X+=TEMP;if(Y!=200)

cout<<TEMP<<X<<Y<<endl;}void main( ){ int A=50,B=20;

Execute(B);cout<<A<<B<<endl;Execute(A,B);cout<<A<<B<<endl;

}x) #include<iostream.h> /* CBSE 2005 */struct MyBox{

int Length,Breadth,Height;};void Dimension(MyBox M){ cout<<M.Length<<”x”<<M.Breadth<<”x”;

cout<<M.Height<<endl;}void main( ){

MyBox B1={10,15,5},B2,B3;++B1.Height;Dimension(B1);B3=B1;

Page 7: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 7

++B3.Length;B3.Breadth++;Dimension(B3);B2=B3;B2.Height+=5;B2.Length--;Dimension(B2);

}xi) #include<iostream.h> /* CBSE 2003 */struct Pixel{ int C,R;};void Display(Pixel P){ cout<<”col”<<P.C<<”Row”<<P.R<<endl;}void main( ){ Pixel X={40,50},Y,Z;

Z=X;X.C+=10;Y=X;Y.R+=20;Z.C-=15;Display(X);Display(Y);Display(Z);

}(xii) #include <iostream.h>#include <ctype.h>void Encrypt(char T[]){

for (int i=0;T[i]!='\0';i+=2)if (T[i]=='A' || T[i]=='E') T[i]='#';

else if (islower(T[i])) T[i]=toupper(T[i]);else T[i]='@';

}void main(){ char Text[]="SaVE EArtH";//The two words in the string Text

//are separated by single spaceEncrypt(Text);cout<<Text<<endl;

}22. In the following program, find the correct possible output(s) from the options:

i) #include<stdlib.h> /* CBSE 2008 */#include<iostream.h>void main( ){

randomize( );char City[ ][10]={“DEL”,”CHN”,”KOL”,”BOM”,”BNG”};int Fly;for(int I=0; I<3;I++)

Page 8: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 8

{Fly=random(2) + 1;cout<<City[Fly]<<”:”;

}}Outputs:(i) DEL : CHN : KOL:(ii) CHN: KOL : CHN:(iii) KOL : BOM : BNG:(iv) KOL : CHN : KOL:

ii) #include<stdlib.h> /* CBSE 2007 */#include<iostream.h>void main( ){ randomize( );

int Marks[]={99,92,94,96,93,95},MyMarks;MyMarks = Marks [1+random(2)];cout<<MyMarks<<endl;

}(i) 99 (ii) 94 (iii) 96 (iv)None of the above.

iii) #include<stdlib.h> /* CBSE 2007 */#include<iostream.h>void main( ){

randomize( );int Score[ ] = {25,20,34,56,72,63},Myscore;Myscore = Marks [1+random(2)];cout<<Myscore<<endl;

}(i) 25 (ii) 34 (iii) 20 (iv) None of the above.

iv) #include<stdlib.h> /* CBSE 2005 */#include<iostream.h>void main( ){ randomize( );

int Num,Rndnum;cin>>Num; //If Num=5Rndnum = random(Num) + 5;for(int N = 1;N<=Rndnum;N++)

cout<<N<<. .; }Output Options:(i) 1 2 3 4 (ii) 1 2(iii) 1 2 3 4 5 6 7 8 9 (iv) 1 2 3

v) void main (){ char serial[] = {'A', 'B', 'C', 'D'};int number[] = { 2, 6, 7, 3};clrscr();randomize();

Page 9: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 9

cout << " The winner is : ";cout << serial [random(3)];for (int i = 0; i < 4; i++)

cout << number[sizeof(int) + random(2) - 1 ];getch();

}Outputs:(i) The winner is : A2776(ii) The winner is : D6766(iii) The winner is : B6767(iv) The winner is : C3672

23. In the following program, if the value of N given by the user is 15, what maximum andminimum values the program could possibly display?#include <iostream.h>#include <stdlib.h>void main(){

int N,Guessme;randomize();cin>>N;Guessme=random(N-3)+10;cout<<Guessme<<endl;

}

Chapter No.2(Object Oriented Programming)

1. Explain all the features or five basic concepts of OOPs (i.e. Data Abstraction,Encapsulation, Modularity, Inheritance and Polymorphism) with example.

2. “While implementing encapsulation, abstraction is also implemented”. Comment.3. Encapsulation is one of the major properties of OOP? How is it implemented in C++?4. Reusability of classes is one of the major properties of OOP. How is it implemented in

C++? /* CBSE 2001 */5. Define the following terms: (i) Inheritance (ii) Encapsulation. /* CBSE 1998 */

Chapter No.3(Function Overloading)

1. Illustrate the concept of function overloading with the help of an example. /*CBSE 2003, 2000*/2. What do you understand Polymorphism? Give an example illustrating its use in a C++

program. /* CBSE 2004 */3. How does function overloading implement polymorphism?

Page 10: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 10

Chapter No.4(Classes and Objects)

1. How does a class enforce data hiding, abstraction and encapsulation?2. What is the significance of private, protected and public access specifiers in a class?3. Differentiate between public and private visibility modes in context of Object Oriented

Programming using a suitable example illustrating each. /* CBSE 2008*/4. Illustrate the use of inline function in C++ with help of an example. /* CBSE 2006 */5. What is the global class and local class? Explain with suitable example.6. What is static data member and static member function? Give suitable example using

C++ code to illustrate them.7. What do you mean by static data members of a class? Explain the characteristics of a

static data member. /* CBSE 2002 */8. Define the term Data Hiding in the context of Object Oriented Programming. Give a

suitable example using a C++ code to illustrate the same. /*CBSE 2005,2010 */9. Define the term Data Encapsulation in the context of Object Oriented Programming. Give

a suitable example using a C++ code to illustrate the same. /*CBSE 2005,2010 */

10. Rewrite the following program after removing the syntactical errors (if any).Underline each correction.

i) #include [iostream.h]class PAYITNOW{

int Charge;PUBLIC:

void Raise(){cin>>Charge;}void Show{cout<<Charge;}

};void main(){

PAYITNOW P;P.Raise();Show();

}

ii) #include <iostream.h> /* CBSE 2010*/class FLIGHT{ long FlightCode;

char Description[25];public

void AddInfo( ){cin>>FlightCode; gets(Description);}void ShowInfo{cout<< FlightCode<<”:”<<Description<<endl;}

};void main(){ FLIGHT F;

AddInfo.F();ShowInfo.F();

}

Page 11: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 11

11. Define a class named ADMISSION in C++ with the following descriptions:Private Members: /* CBSE 2006 */AD_NO integer(Ranges 10 to 2000)NAME Array of characters (String)CLASS CharacterFEES FloatPublic Members:Function Read_Data( ) to read an object of ADMISSION type.Function Display( ) to display the details of an object.Function Draw-Nos.( ) to choose 2 students randomly from an array of 100 objects oftype ADMISSION passes as an argument to the function and display the details. Userandom function to generate admission nos. to match with AD_NO from the array.

12. Define a class Teacher with the following class specification. /*CBSE1999*/Private members:Name 20 charactersSubject 10 charactersBasic, DA, HRA, Salary floatCalculate( ) function computes the salary and returns it.Salary is sum of Basic, DA and HRAPublic members:ReadData( ): Function accepts the data values and invoke the calculate function.DisplayData( ):Function prints the data on the screen.

13. Define a class TEST in C++ with following description:Private Members

a. TestCode of type integerb. Description of type stringc. NoCandidate of type integerd. CenterReqd (number of centers required) of type integere. A member function CALCNTR() to calculate and return the number of centers as

(NoCandidates/100+1)Public Members

• A function SCHEDULE() to allow user to enter values for TestCode, Description,NoCandidate & call function CALCNTR() to calculate the number of Centres

• A function DISPTEST() to allow user to view the content of all the data members.

14. Define a class Flight in C++ with following description:Private Members

• A data member Flight number of type integer• A data member Destination of type string• A data member Distance of type float• A data member Fuel of type float• A member function CALFUEL() to calculate the value of Fuel as per the

following criteriaDistance Fuel<=1000 500more than 1000 and <=2000 1100more than 2000 2200

Page 12: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 12

Public Members• A function FEEDINFO() to allow user to enter values for Flight Number,

Destination, Distance & call function CALFUEL() to calculate the quantity ofFuel

• A function SHOWINFO() to allow user to view the content of all the datamembers

15. Define a class BALANCED_MEAL in C++ with following description:Private Members:

Access number IntegerName of Food String of 25 charactersCalories IntegerFood type StringCost FloatAssignAccess( ) Generates random numbers

between 0 to 99 and return it.Public Members

• A function INTAKE( ) to allow the user to enter the values of Name of Food, Calories,Food type, cost and call function AssignAccess() to assign Access number.

• A function OUTPUT( ) to allow user to view the content of all the data members, if theFood type is fruit.

Chapter No.5(Constructors and Destructors)

1. What is the use of a constructor function in a class? Give a suitable example for aconstructor function in a class.

2. Why is a destructor function required in classes? Illustrate with the help of an example./*CBSE 2000*/

3. What is a default constructor? How does it differ from destructor? /*CBSE 2006*/4. Differentiate between a Constructor and Destructor in context of class and object. Give

suitable example in C++. /*CBSE 2007*/5. Differentiate between a constructor and destructor function.6. Differentiate between default & copy constructor with a suitable example. /*CBSE 2005*/7. Differentiate between default & parameterized constructor with suitable example.8. What is a copy constructor? What do you understand by constructer overloading?

/*CBSE 1998*/9. Explain the concept constructor overloading with a suitable example.

10. Answer the questions (i) and (ii) after going through the following class: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};

Page 13: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 13

void main(){ player p1(7,24); //Statement1

player p3 = p1; //Statement2}(i) When p3 object created specify which constructor invoked and why?(ii) Write complete definition for Constructor3?

11. Answer the questions (i) and (ii) after going through the following program:class Match{ int Time;public:

Match() //Function 1{Time=0;cout<<”Match commences”<<end1;}

void Details() //Function 2{cout<<”Inter Section Basketball Match”<<end1;}Match(int Duration) //Function 3{Time=Duration;cout<<”Another Match begins now”<<end1;}

Match(Match &M) //Function 4{Time=M.Duration;cout<<”Like Previous Match ”<<end1;}

};i) Which category of constructor - Function 4 belongs to and what is the purpose of

using it?ii) Write statements that would call the member Functions 1 and 3.

12. Answer the questions (i) and (ii) after going through the following class:class Seminar{ int Time;public:

Seminar() //Function 1{Time=30;cout<<”Seminar starts now”<<end1;}

void Lecture() //Function 2{cout<<”Lectures in the seminar on”<<end1;}Seminar(int Duration) //Function 3{Time=Duration;cout<<”Seminar starts now”<<end1;}

~Seminar() //Function 4{ cout<<”Vote of thanks”<<end1;}

};iii) In Object Oriented Programming, what is Function 4 referred as and when does it

get invoked/called?iv) In Object Oriented Programming, which concept is illustrated by Function 1 and

Function 3 together? Write an example illustrating the calls for these functions.

Page 14: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 14

13. Answer the questions (i) and (ii) after going through the following program: /*CBSE 2008*/#include <iostream.h>#include<string.h>class bazaar{ char Type[20] ;char product [20];int qty ;float price ;bazaar() //function 1{ strcpy (type , “Electronic”) ;

strcpy (product , “calculator”);qty=10;price=225;}

public :void Disp() //function 2{ cout<< type <<”-“<<product<<”:” <<qty<< “@” << price << endl ;}};void main (){ Bazaar B ; //statement 1

B. disp() ; //statement 2}(i)Will statement 1 initialize all the data members for object B with the values given in thefunction 1? (YES OR NO). Justify your answer suggesting the correction(s) to be made in theabove code.(ii) What shall be the possible output when the program gets executed? (Assuming, ifrequired _ the suggested correction(s) are made in the program).

14. Define a class Society with the following specifications.Data members :

Private Members :society_name char (30)house_no integerno_of_members integerflat char(10)income float

Member Functions:Public members:

A constructer to assign initial values of society_name as “MahavirNagar”, flat as “A Type”, house_no as 56, no_of_members as 6, income as50000.input( ) – to read data members.alloc_flat( ) – To allocate flat according to income

income >=50000 - Flat “ A Type”income >=25000 and income <50000 - Flat “ B Type”income <25000 - Flat “ C Type”

show( ) – to display all details.15. Define a class Play in C++ with the following specifications: /*CBSE 2003*/

Private members of class Play?�?�Playcode integer?á?áPlaytitle 25 character?¬?¬Duration float?v?vNoofscenes integer

Page 15: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 15

Public member function of class Play?Ø?ØA constructer function to initialize Duration as 45 and Noofscenes as 10.?q?qNewplay() function to take values for Playcode and Playtitle.??Moreinfo() to assign the values of Duration and Noofscenes with the help of correspondingvalues passed as parameters to this function.?=?=Showplay() function to display all the data members on the screen.

16. Defne a class WEAR in C++ with following description : /*CBSE 2008*/Private members :code stringType stringSize integermaterial stringPrice real numberA function calprice( ) that calculates and assign the value of price as follows :For the value of material as “WOOLEN”

Type Price(Rs.)------- -------------Coat 2400Sweater 1600

For material other than “WOOLEN” the above mentioned price gets reduced by 30%.Public members :A constructor to get initial values for code, Type & material as “EMPTY” & size and pricewith 0.A function INWEAR( ) to input the values for all the data members except price which willbe initialized by function calprice( ).Function DISPWEAR( ) that shows all the contents of data members

17. Define a class Employee in C++ with the following specification:Private Members:

• ename an array of char of size[50] ( represent employee name)• deptname an array of char of size[20] ( represent department name)• salary integer ( represent total salary of an employee)• bonus float• CalBonus() This function calculate the total bonus given to an employee

according to following conditionsDeptname BonusAccounts 4 % of salaryHR 5% of salaryIT 2% of salarySales 3% of salaryMarketing 4% of salary

Public Members:• Constructor to initialise ename and deptname to NULL and salary and bonus to 0.• A function read_info to allow user to enter values for ename, deptname,salary & Call

function CalBonus() to calculate the bonus of an employee.• A Function disp_info() to allow user to view the content of all the data members.

Page 16: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 16

Chapter No.6(Inheritance)

1. Illustrate the concept of Inheritance with the help of an example. /* CBSE 2002 */2. What are the different types of inheritance (Single, Multiple, Hierarchical, Multilevel,

Hybrid)? Explain all with an example in C++ code?3. What do you understand by visibility modes in class derivations? What are these modes?

./* CBSE 1999 */4. Define Multilevel and Multiple Inheritance in context of Object Oriented Programming.

Give suitable example to illustrate the same. /* CBSE 2006 */5. Differentiate between Private and Protected members of class in context of inheritance

using C++. /* CBSE 2008, 2007 */6. How does inheritance influence the working of constructors and destructors?

7. Answer the questions (i) to(iv) based on the following code : /* CBSE 2008 */class Dolls{ char Dcode[5];

protected:float Price;void CalcPrice(float);public:Dolls();void DInput();void DShow();

};class SoftDolls:public Dolls{ char SDName[20];

float Weight;public:SoftDolls();void SDInput();void SDShow();

};class ElectronicDolls:public Dolls{ char EDName[20];

char BatteryType[10];int Batteries;public:ElecronicDolls();void EDInput();void EDShow();

};(i)Which type of Inheritance is shown in the above example?(ii)How many bytes will be required by an object of the class ElectronicDolls?iii)Write name of all data members accessible from member function of the classSoftDolls.(iv)Write name of member functions accessible an object of the class ElectronicDolls?

Page 17: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 17

8. Answer the questions (i) to(iv) based on the following code: /* CBSE 2007 */class Trainer{ char TNo[5],Tname[20],specialization[10];

int Days;protected :float Remuneration;void AssignRem(float);public:Trainer();void TEntry();void TDisplay();

};class Learner{ char Regno[10],LName[20],Program[10];

protected:int Attendance,grade;public:Learner();void LEntry();void LDisplay();

};class Institute:public Learner,public Trainer{ char ICode[10],IName[20];

public:Institute();void IEntry();void IDisplay();

};(i)Which type of inheritance is depicted by above example ?(ii)Identify the member function(s) that cannot be called directly from the objects of classInstitute from the following TEntry(), LDisplay(), IEntry()(iii)Write name of all member(s) accessible from member functions of class institute.(iv)If class institute was derived privately from class Learner and privately from classTrainer, then name the member function(s)that could be accessed through Objects of classInstitute.9. Answer the questions (i) to(iv) based on the following code: /* CBSE 2005 */

class Medicine{ char Category[10];

char Date_of_manufacture[10];char Company[20];public:Medicine();void entermedicinedetails();void showmedicinedetails();

};class capsule:public Medicine{ protected:

char capsule_name[30];char volume_lable[20];public:

Page 18: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 18

float Price;capsules();void entercapsuledetails();void showcapsuledetails();

};class Antibiotics:public Capsule{ int Dosage_units;

char side_effects[20];int Use_within_days;public:Antibiotics();void enterdetails();void showdetails();

};(i)How many bytes will be required by an object of class Medicines and an object of classAntibiotics respectively?(ii)Write the names of all the member functions accessible from the object of classAntibiotics.(iii)Write the names of all the members accessible from member functions of classcapsules.(iv)Write names of all the data members which are accessible from objects of classantibiotics.

10. Consider the following and answer the questions given below: /* CBSE 1999 */class vehicle{ int wheels;

protected:int passenger;void inputdata(int,int);void outputdata();

};class heavy_vehicle:protected vehicle{ int diesel_petrol;

protected:int load:public:void readdata(int,int);void writedata();

};class bus:private heavy_vehicle{ char make[20];

public:void fetchdata(char);void displaydata();

};(i)Name the base class and derived class of the class heavy_vehicle.(ii)Name the data member(s) that can be accessed from function displaydata( ).(iii)Name the data member(s) that can be accessed by an object of bus class.(iv)Is the member function outputdata( ) accessible to the objects of heavy_vehicle class?

Page 19: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 19

Chapter No.7(Data File Handling)

1. What do you mean by ios::trunc, ios::nocreate, ios::noreplace and ios::binary file mode?2. Distinguish between ios:: ate and ios :: app?3. Differentiate between functions read() and write(). /* CBSE 1999 */4. Write name of two member functions belonging to fstream class./* CBSE 1998 */5. Distinguish between ios::out and ios::app. /* CBSE 2001*/6. Name two member functions of ofstream class. /* CBSE 2000*/7. Write a function in C++ to count the number of uppercase alphabets present in a text file“ARTICLE.TXT”. /* CBSE 2008 */8. Write a function in C++ to print the count of the word is as an independent word in a text fileDIALOGUE.TXT. /* CBSE 2007 */For example,if the content of the file DIALOGUE.TXT isThis is his book. Is this book good?Then the output of the program should be 2.9. Given a binary file GAME.DAT, containing records of the following structure type.struct Game /* CBSE 2007 */{ char GameName[20] ;char Participate[10][30] ;} ;Write a function in C++ that would read contents from the file GAME.DAT and creates a filenamed BASKET.DAT copying only those records from GAME.DAT where the game name is“Basket Ball”.10. Observe the program segment given below carefully,and answer the question that follows:class Labrecord /* CBSE 2007 */{ int Expno ;char Experiment[20] ;char Checked ;int Marks ;public :void EnterExp( ) ; //function to enter Experiment detailsviod ShowExp( ) ; //function to display Experiment detailschar RChecked( ) //function to return Expno{return Checked ;}void Assignmarks (int M) //function to assign Marks{ Marks = M ; }} ;void ModifyMarks( ){ fstream File ;File.open (“Marks.Dat”, ios :: binary || ios :: in || ios :: out) ;Labrecord L ;int Rec=0 ;while (File.read ( (char*) &L,sizeof (L) ) ){ if (L.RChecked( )= =”N”)L.Assignmarks (0)elseL.Assignmarks (10)……………………………………………… //Statement 1

Page 20: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 20

………………………………………………. //Statement 2Rec++ ;}File.close( ) ; }If the function ModifyMarks ( ) is supposed to modify marks for the records in the fileMARKS.DAT based on their status of the member Checked (containg value either “Y” or“N”).Write C++ statements for the statement 1 and statement 2,where, statement 1 is required toposition the file write pointer to an appropriate place in the file and statement 2 is to perform thewrite operation with the modified record.11. void main( ) /* CBSE 2006 */{ char ch = “A” ;fstream fileout(“data.dat”, ios::out) ;fileout<<ch ;int p = fileout.tellg( )cout<<p ;}What is the output if the file content before the execution of the program is the string “ABC”.12. Write a function to count the number of words present in a text file named “PARA.TXT”.Assume that each word is separated by a single blank/space character and no blanks/spaces in thebeginning and end of the file. /* CBSE 2006 */13. Following is the structure of each record in a data file named “COLONY.DAT”.struct COLONY /* CBSE 2006 */{ char Colony_Code[10] ;char Colony_Name[10]int No_of_People ;} ;Write a function in C++ to update the file with a new value of No_of_People. The value ofColony_Code and No_of_People are read during the execution of the program.14. void main( ) /* CBSE 2006 */{ char ch = “A” ;fstream fileout(“data.dat”, ios :: app) ;fileout<<ch ;int p = fileout.tellg( ) ;cout << p ;}What is the output if the file content before the execution of the program is the string “ABC”.15. Write a function to count the number of blank spaces present in a text file named“PARA.TXT”. /* CBSE 2006 */16. Write a function in C++ to count and display the number of lines starting with alphabet “A”present in a text file “LINES.TXT”. /* CBSE 2005 */Example :If the file “LINES.TXT” contains the following lines,A boy is playing there.There is a playground.An aeroplane is in the sky.Alphabets and numbers are allowed in the password.The function should display the output as 3.17. Given a binary file APPLY.DAT, containing records of the following class Applicant.class Applicant /* CBSE 2005 */{ char A_Rno[10] ; //Roll number of applicantchar A_Name[30] ; //Name of applicant

Page 21: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 21

int A_Score ; //Score of applicantpublic :void Enrol( ){ gets(A_Rno) ; gets(A_Name) ; cin >> A_Score ;}void Status( ){cout << setw(12) << A_Admno ;cout << setw(32) << A_Name ;cout << setw(3) << A_Score << endl ;}int ReturnScore( ) {return A_Score ;}} ;Write a function in C++, that would read contents of file APPLY.DAT and display the details ofthose Students whose A_Score is above 70.

18. Write a function to count the number of VOWELS present in a text file named“PARA.TXT”. /* CBSE 1998 */19. Write a function in C++ to search for a BookNo from a binary file “BOOK.DAT”, assuming

the binary file is containing the objects of the following class.class BOOK{

int Bno;char Title[20];

public:int RBno(){return Bno;}void Enter(){cin>>Bno;gets(Title);}void Display(){cout<<Bno<<Title<<endl;}

};20. Write a function in C++ to count the words “to” and “the” present in a text file“POEM.TXT”. /* CBSE 2010 */21. Write a function in C++ to count the number of words starting with capital alphabet present in a textfile DATA.TXT.22. Observe the program segment given below carefully and fill in the blanks marked by thestatement1 and statement 2 using Seekg() and tellg() functions for performing the required task

#include <fstream.h>class Car

{char No_Plate[15],Car_type[20];public :

/* function to count the total no. of records in a file */int Countrec();

};int Car::Countrec(){

fstream file ;file.open(“ Veh.dat”,ios::binary| ios::in);_______________________________ //statememt1int bytes = ________________________ //statement 2int Count = bytes/sizeof(Car);

Page 22: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 22

file.close();return Count;

}

23. Write a function in C++ to search & display the details of all trains, whose destination is“Delhi” from a binary file “TRAIN.DAT”, assuming the binary file is containing the objects ofthe following class. /* CBSE 2010 */

class TRAIN{

int Tno;char From[20];char To[20];

public:char* GetFrom( ){return From;}char* GetTo( ){return To;}void Input(){cin>>Tno;gets(From);gets(To);}void Show(){cout<<Tno<<From<<To<<endl;}

};

24. Write a function in C++ to add new object at the bottom of the binary file “Train.Dat”.Assuming that binary file is containing the objects of the following class:

class Train{

int Tno;char Tname[20];char start_place[20];

public:void enter( ) { cin>>Tno ; gets(Tname) ; gets(start_place);}void display( ) { cout<<Tno << Tname << start_place; }char *ret_place( ){

return start_place;}

};

Chapter No.8(Pointers)

1. Differentiate between static and dynamic memory allocation.2. What is role of new and delete operator in memory allocation?3. What do you mean by memory leaks? What are possible reasons for it? How can memoryleaks be avoided?4. What is “this” pointer? What is its significance? Give an example to illustrate the use of it inC++. /* CBSE 2006 */5. Distinguish between /* CBSE 2001 */int *ptr=new int(5); int *ptr=new int[5];

Page 23: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 23

6. Find the output of the following program:#include<iostream.h>

int a=10;void main(){

void demo(int &,int,int*);int a=20,b=5;demo(::a,a,&b);

cout<<::a<<a<<b<<endl;}void demo(int &x,int y,int *z){

a+=x;y*=a;*z=a+y;

cout<<x<<y<<*z<<endl;}

7. Find the output of the following program: /* CBSE 2006 */#include<iostream.h>#include<string.h>class student{ char *name;int l ;public:student( ) {l=0; name=new char I1+1]; }student (char *s){ I =strlen(s); name=new char[I+1];strcpy (name,s);}void display( ) {cout<<name<<endl;}void manipulate(student & a, student & b){ I = a. I + b.I;delete name;name=new char[I+1];strcpy(name, a.name);strcat(name, b.name);}};void main( ){ char * temp = “Jack”;student name1 (temp), name2(” Jill”), name3(”John”),S1,S2;S1 .manipulate (name1, name2);S2.manipulate (SI, name3);S1.display ( );S2.display ( );}

Page 24: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 24

8. Find the output of the following program: /* CBSE 2006 C */#include < iostream.h>void main( ){ int *Pointer Array [10];int marks [ = {75, 68, 90, 34, 0, 10, 90, 65};for (int I = 0; marks [ I]!=0; I++){ PointerArray [I]=&marks[I];* (PointerArray [I] ) += 5;}int index = 0;while(index < I ){ int p=*(PointerArray[index] );if(p >=60) cout <<p<<’,’;index ++;}}9. What will be the output of the following program : /* CBSE 2004 */#include<iostream.h>#include<ctype.h>#include<conio.h>#include<string.h>void ChangeString(char Text[], int &Counter){char *Ptr = Text;int Length = strlen (Text);for ( ;Counter<Length-2; Counter+=2, Ptr++){* (Ptr + Counter) = toupper( * (Ptr + Counter) );}}void main( ){clrscr();int Position = 0;char Messaget[] = “Pointers Fun”;ChangeString (Message, Position);cout<<Message<<“ @ “<<Position;}10. Find the output of the following program : /* CBSE 2007 */#include<iostream.h>void main(){int Numbers[] = {2,4,8,10};int *ptr = Numbers;for (int C = 0; C<3; C++){cout<< *ptr << “@”;ptr++;}cout<<endl;

Page 25: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 25

for(C = 0; C<4; C++){(*ptr)*=2;--ptr;}for(C = 0; C<4; C++)cout<< Numbers [C]<< “#”;cout<<endl;}

Chapter No.9(Arrays)

1. An array MAT [20] [10] is stored in the memory along the row with each element occupying 4bytes of memory. Find out the base address and the address of element MAT[10][5] if thelocation of MAT [3][7] is stored at the address 1000. /* CBSE 2006 */2. An array MAT [15] [7] is stored in the memory along the column with each elementoccupying 2 bytes of memory. Find out the base address and the address of element MAT [2][5], if the location of MAT [5] [4] is stored at the address 100. /* CBSE 2006 C */3. X is 2D array [10 X 5]. Each element of array is stored in 2 memory locations. If X [1,1]begins at address 150, find the location of X[3,4]. Use row major formula.4. An array ARR[5][5] is stored in the memory with each element occupying 2 bytes of space.Assuming the base address of ARR to be 1500, compute the address of ARR[2][4], when thearray is stored : (i) Row Wise (ii) Column Wise /* CBSE 2004 */5. If an array B[11][8] is stored as column wise and B[2][2] is stored at 1024 and B[3][3] at1084. Find the address of B[5][3].6. A 2-d array defined as A[4..7, -1..3] requires 2 words of storage space for each element.calculate the address of A[6,2], given the base address as 100, also calculate the address ofA[7,0] If the array is stored in row major order.7. Assume an array S containing elements of structure student is required to be arranged indescending order of marks. Write a C++ function to arrange the same with the help of bubblesort. The array and its size is required to be passed as parameters to the function.

struct student{ int rollno;

char name[25];float marks;

};8. A one-dimensional array SCORE is containing long data type arranged in ascending order.Write a user defined function in C++ to search for a number from SCORE with the help ofbinary search method. The function should return an integer -1 to show absence of the numberand integer 1 to show presence of the number in the array. The function should have threeparameters as (1) an array SCORE, (2) the number SDATA to be searched, (3) number ofelements N.9. Write a function in C++, which accepts an integer array and its size as arguments and swapsthe elements of every even location with its following odd location. /*CBSE 2008, 2004*/Example: if an array of nine elements initially contains the elements as

2,4,1,6,5,7,9,23,10then the function should rearrange the array as

4,2,6,1,7,5,23,9,10

Page 26: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 26

10. Write a function in C++ which accepts an integer array and its size as arguments and replaceselements having even values with its half and elements having odd values with twice its value.Example : if an array of five elements initially contains the elements as /* CBSE 2007 */3, 4, 5, 16, 9then the function should rearrange the content of the array as6, 2, 10, 8, 1811. Write a function in C++ to find the sum of diagonal elements from a 2 dimensional array oftype float. Use the array and its size as parameters with float as its return type. /* CBSE 2004 */12. Write a function in C++ to print the sum of all the values which are either divisible by 2 or aredivisible by 3 present in a two-dimensional array passed as the argument to the function. /* CBSE 2005*/13. Write a function in C++ to merge the contents of two sorted arrays A & B into third array C.Assuming array A and B are sorted in ascending order and the resultant array C is also requiredto be in ascending order.14. Write a function in C++ to merge the contents of two sorted arrays A & B into third array C.Assuming array A is sorted in ascending order, B is sorted in descending order, the resultantarray is required to be in ascending order.15. Write a function in C++ to combine the contents of two equi-sized arrays A and B bycomputing their corresponding elements with the formula 2*A[i]+3*B[i]; where value i variesfrom 0 to N-1 and transfer the resultant content in the third same sized array.16. Write a function in C++ to find the sum of both left and right diagonal elements from a twodimensional array (matrix).17. Write a function in C++ which accepts an integer array and its size as arguments/parameters andexchanges the values of first half side elements with the second half side elements of the array.Example: /*CBSE 2005*/If an array of eight elements has initial content as2,4,1,6,7,9,23,10The function should rearrange the array as7,9,23,10,2,4,1,618. Write a function in C++ which accepts a 2D array of integers and its size as arguments anddisplays the elements of middle row and the elements of middle column. /* CBSE 2007 */[Assuming the 2D Array to be a square matrix with odd dimension i.e. 3×3, 5×5, 7×7 etc...]Example, if the array content is3 5 47 6 92 1 8Output through the function should be :Middle Row : 7 6 9Middle Column : 5 6 1

19. Write a function in C++ which accepts an integer array and its size as arguments/parametersand assign the elements into a two dimensional array of integers in the following format:If the array is 1, 2, 3,4,5,6 if the array is 1, 2, 3The resultant 2 D array is given below The resultant 2 D array isgiven below /* CBSE 2006 */

If the array is 1, 2, 3, 4, 5, 6The resultant 2 D array is given below

If the array is 1, 2, 3The resultant 2 D array is givenbelow

111

022

003

000

000

000

111

022

003

Page 27: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 27

111

222

333

444

055

006

20. Write a function in C++ to print the product of each row of a two dimensional integer arraypassed as the argument of the function. /* CBSE 2008 */

Example: if the two dimensional array contains

20 40 10

40 50 30

60 30 20

40 20 30

Then the output should appear as :Product of Row 1= 8000Product of Row 2= 60000Product of Row 3= 36000Product of Row 4= 24000

21. Write a function in C++ to find sum of rows from a two dimensional array.

22. Write a function UpperHalf ( ) which takes a two dimensional array A, with size N rows andN columns as argument and point the upper half of the array.

Eg: If A is 2 3 1 5 0 The output will be 2 3 1 5 07 1 5 3 1 1 5 3 12 5 7 8 1 7 8 10 1 5 0 1 0 13 4 9 1 5 5

23. Write a function LowerHalf ( ) which takes a two dimensional array A, with size N rows andN columns as argument and point the lowerr half of the array.

Eg: If A is 2 3 1 5 0 The output will be 27 1 5 3 1 7 12 5 7 8 1 2 5 70 1 5 0 1 0 1 5 03 4 9 1 5 3 4 9 1 5

24. Write a user defined function in C++ which accepts a squared integer matrix with odd dimensions(3*3, 5*5 …) & display the square of the elements which lie on both diagonals. For eg. :

2 5 73 7 25 6 9

The output should be:Diagonal one : 4, 49, 81Diagonal two : 49, 49, 25

Page 28: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 28

Chapter No.11(Database Concepts)

1. What is a Candidate Key, Primary Key and Alternate key? /* CBSE 2006, 2007, 2008 */2. What do you understand by the terms Primary Key and Degree & Cardinality of a relation inrelational database? /* CBSE 2005 */3. Define domain, keys and foreign key?4. What is the purpose of a key in a table? Give an example of a key in a table. /*CBSE 2009 */5. What is the importance of a primary key in a table? Give suitable example of primary key from a tablecontaining some meaningful data. /* CBSE 2007, 2010 */6. Explain Cartesian product of two relations. /* CBSE 2001 */7. What is a relation? What is the difference between a tuple and an attribute? /* CBSE 1998 */

Chapter No.12(Structured Query Language)

1. What are DDL and DML? Give two examples of each. /* CBSE 2002, 2006 */2. Study the following tables FLIGHTS and FARES and write SQL commands for the questions(i) to (iv) and give outputs for SQL queries (v) to (vi). /* CBSE 2006 */

TABLE: FLIGHTSFL_NO STARTING ENDING NO_FLIGHTS NO STOPS

IC301 MUMBAI DELHI 8 0

IC799 BANGALORE DELHI 2 1

MC101 INDORE MUMBAI 3 0

IC302 DELHI MUMBAI 8 0

AM812 KANPUR BANGALORE 3 1

IC899 MUMBAI KOCHI 1 4

AM501 DELHI TRIVANDRUM 1 5

MU499 MUMBAI MADRAS 3 3

IC701 DELHI AHMEDABAD 4 0

TABLE: FARES

FL_NO AIRLINES FARE TAX%

1C701 Indian Airlines 6500 10

MU499 Sahara 9400 5

AM501 Jet Airways 13450 8

IC899 Indian Airlines 8300 4

1C302 Indian Airlines 4300 10

1C799 Indian Airlines 10500 10

MC101 Deccan Airlines 3500 4

Page 29: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 29

i. Display FL_NO and NO_FLIGHTS from “KANPUR” to “BANGALORE” from thetable FLIGHTS.

ii. Display the contents of the table FLIGHTS in the ascending order of FL_NO.iii. Display the FL_NO and fare to be paid for the flights from DELHI to MUMBAI using

the tables FLIGHTS and FARES, where the fare to be paid = FARE + FARE *TAX%/100.

iv. Display the minimum fare “Indian Airlines” is offering from the table FARES.v. SELECT FL_NO, NO_FLIGHTS, AIRLINES from FLIGHTS, FARES where

STARTING=’DELHI’ and FLIGHTS.FL_NO=FARES.FL_NO;vi. SELECT count (distinct ENDING) from FLIGHTS;

3. Consider the following tables ACTIVITY and COACH. Write SQL commands for thestatements (i) to (vi) and give outputs for SQL queries (vii) to (xii)

Table: ACTIVITYACode ActivityName ParticipantsNum PrizeMoney ScheduleDate1001 Relay 100x4 16 10000 23-Jan-20041002 High jump 10 12000 12-Dec-20031003 Shot Put 12 8000 14-Feb-20041005 Long Jump 12 9000 01-Jan-20041008 Discuss Throw 10 15000 19-Mar-2004

Table: COACHPCode Name ACode1 Gulam Nabi 10012 Roma Khanna 10083 Amit Bohra 10014 Bhupendra 1003

(i) To display the name of all activities with their Acode in descending order.(ii) To display sum of PrizeMoney for each of the Number of participants groupings (asshown in column ParticipantsNum 10,12,16)(iii) To display the coach’s name and ACode in ascending order of ACode from the tableCOACH.(iv) To display the content of the ACTIVITY table whose ScheduleDate earliar than01-JAN-2004 in ascending order of ParticipantNum.(v) To display details of those activities which are having PrizeMoney more than 7000(vi) To display the content of the ACTIVITY table in ascending order of ScheduleDate(vii). SELECT COUNT(DISTINCT ParticipantsNum) FROM ACTIVITY;(viii)SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM ACTIVITY;(ix) SELECT SUM(PrizeMoney) FROM ACTIVITY;(x) SELECT SUM(PrizeMoney) FROM ACTIVITY Group By ParticipantNum;(xi) SELECT DISTINCT ACode FROM COACH;(xii) SELECT AVG(PrizeMoney) FROM ACTIVITY;

4. Write SQL commands (a) to (m) and outputs (n) to (s) on the basis of Teacher relation givenbelow:

No Name Age Department DateofJoin Salary Sex1 Jugal 34 Computer 10-JAN-97 12000 M2 Sharmila 31 History 24-MAR-98 20000 F3 Sandeep 32 Maths 12-DEC-96 30000 M4 Sangeeta 35 History 01-JUL-99 40000 F

Page 30: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 30

5 Rakesh 42 Maths 05-SEP-97 25000 M6 Shyam 50 History 27-JUN-98 30000 M7 Manoj 44 Computer 35-FEB-97 21000 M8 Rina 33 Maths 31-JUL-97 19500 F

a) To show all information about the teachers of History department.b) To increment the salary by 20% of those teachers who is getting salary more than

21000.c) To display teacher name, age, department for male teachers from Teachers table.d) To list name of female teachers who are in History department.e) To list name and department of those teachers in which date of joining is before

24-MAR-98 from teacher table in descending order of their name.f) To insert a new row in teacher table with following data:

9, ‘Rahul’, 27, ‘Computer’, ’10-SEP-98’, 22500, ‘M’.g) To list name of all teachers with their join date in descending order.h) To show the name of those teachers who have first alphabet as ‘S’ and third

alphabet as ‘n’ from teacher table.i) To display the second largest salary from teacher table.j) To count the numbers of those teachers who join before 12-JUL-97.k) To decrease the salary of all teachers of Maths department by 500.l) To find the total salary of those teachers who are working in Maths department.m) To delete the records of those teachers whose age is greater than equal to 40.n) select sum (Salary) from teacher where Department= ‘History’;o) select count (distinct Department) from Teachers;p) select avg (Salary) from Teacher where DateofJoin > ’31-JUL-97’;q) select max (Age) from Teacher where Sex= ‘F’;r) select count (*) from Teachers where DateofJoin < ’12-JUL-97’;s) select name, age, department from teacher where Sex= ‘M’ ;

5. Consider following tables STOCK and DEALERS and write SQL commands for the questions(i) to (iv) and give outputs for SQL queries (v) to (viii). /* CBSE 2010 */Tables: STOCKItemNo Item Dcode Qty UnitPrice StockDate5005 Ball Pen 0.5 102 100 16 31-Mar-105003 Ball Pen 0.25 102 150 20 01-Jan-105002 Gel Pen Premium 101 125 14 14-Feb-105006 Gel Pen Classic 101 200 22 01-Jan-095001 Eraser Small 102 210 5 19-Mar-095004 Eraser Big 102 60 10 12-Dec-095009 Sharpener Classic 103 160 8 23-Jan-09Tables: DEALERSDcode Dname101 Reliable Stationers103 Classis Plastic102 Clear Deals

i) To display details of all items in the STOCK table in ascending order of StockDate.ii). To display Item No and Item name of those items from STOCK table whose UnitPrice ismore than Rupees 10.iii). To display details of those items whose dealer code is 102 or quantity in stock is morethan 100 from STOCK table.

Page 31: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 31

iv) To display maximum UnitPrice of items for each dealer individually as per Dcode fromSTOCK table.v) select count(distint dcode) from stock;vi) select Qty*UnitPrice from stock where itemno=5006;vii) select item, dname from stock S, dealer D where S.dcode=D.dcode and itemno=5004;viii) select min(stockdate) from stock;

Chapter No.13(Boolean Algebra)

1. State and verify Associative Law? /* CBSE 2006, 2005 */2. State and verify De Morgan’s theorem. /* CBSE 2006 Comp., 2007 */3. State and verify Distributive Law. /* CBSE 2006 */4. State and verify Absorption law in Boolean- Algebra algebrically./*CBSE 2008, 2004, 2009*/5. State and verify second Distributive law by algebraic method in Boolean Algebra.6. State and verify IdempotenceLaw.7. State and verify ComplementarityLaw.8. State and verify Commutative Law.9. State and verify third distributive Law.10. State Involution Law and verify the same using truth table.11. Verify the following algebraically: /* CBSE 2010 */

X’.Y + X.Y’ = (X’+Y’)(X+Y)12.Write the equivalent expression for the following logical circuit: /* CBSE 2006 */

13. Write the equivalent expression for the following logical circuit: /* CBSE 2006 Comp. */

14. Write the equivalent expression for the following Logical Circuit: /* CBSE 2006 */

Page 32: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 32

15. Write the equivalent expression for the following Logical Circuit: /* CBSE 2010 */

16. Express P+Q ’R in canonical POS form. /* CBSE 2006 */17. Reduce the following Boolean expression using K-Map: /* CBSE 2006 Comp. */

F(P,Q,R,S)=?•(l,3,5,8,11,12,15 )18. Reduce the following Boolean expression using K-Map: /* CBSE 2006 */

F(P, Q, R, S) = pÆ(0,3,5,6,7, 11, 12, 15)19. Express P+Q’R in canonical SOP form. /* CBSE 2006 */20. Reduce the following Boolean expression using K-Map. /* CBSE 2006 */

F(P, Q ,R, S) = ?ƒ(0,3,5,6,7,11,12,15)21. Reduce the following Boolean expression using K-Map. /* CBSE 2010 */

F(A,B,C,D) = ?Y(3,4,5,6,7,13,15)22. Reduce the following Boolean expression using K - Map: /* CBSE 2009 */

H(U,V,W,Z) = Σ(0,1,4,5,6,7,11,12,13,14,15)23. Draw a Logical Circuit Diagram for the following Boolean Expression: /* CBSE 2008 */

A . (B + C')24. Convert the following Boolean expression, into its equivalent Canonical Product of SumForm(POS) : A. B' .C + A'. B. C + A'. B. C' /* CBSE 2008 */25. Reduce the following Boolean expression using K - Map: /* CBSE 2008 */

F(A,B,C,D) = Σ(0,1,2,4,5,8,9,10,11)26. Obtain a simplified form for the following Boolean Expression using Karnaugh’s Map :F(a, b, c, d) = ?Ù?Ù(0, 1, 2, 4, 5, 7, 8, 9, 10, 11, 14) /* CBSE 2004 */27. Reduce the following Boolean expression using K - Map: /* CBSE 2005 */F (A, B, C, D) = p+?+(0, 1, 2, 3, 4, 5, 10, 11, 15)28. Write the equivalent Canonical Product of Sum Expression for the following Sum of ProductExpression F(X, Y, Z) = ?}?}(0, 2, 4, 5) /* CBSE 2007 */29. Reduce the following Boolean expression using K-Map: /* CBSE 2007 */F(A, B, C, D) = pÏ(5,6,7,8,9,12,13,14,15)30. Convert the following Boolean expression into its equivalent Canonical Sum of ProductForm(SOP): (X’+Y+Z’).(X’+Y+Z).(X’+Y’+Z).(X’+Y’+Z’).31. Draw logical circuit diagram for the following Boolean expression. F= AB + B’C + C’A’32. Write the equivalent canonical POS expression for the following SOP expression:F(x,y,z)=S<(0,2,5,6).33. Prove that XY+YZ+YZ’=Y algebraically.

34. If F(w,x,y,z) = ∏ (1,3,5,7,,8,9,10,11,12,13,14,15) , obtain the simplified form using K-Map.35. State Duality principle. Give the dual of the expression: ft+t’y36. Draw the circuit diagram for the following Boolean expression :

(A+B)(A’+B)(A+B’)37. Reduce the following Boolean expressions using K-Map:

i) F(A,B,C,D)= ?�(0,1,2,4,5,8,9,10,11)ii) F (A, B, C, D) =?»(0,2,3,4,6,7,8,10,12)iii) F(A,B,C,D)= p_(0,1,2,4,5,6,8,10)

Page 33: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 33

iv) F(a,b,c,d)=?<?<?<0,2,4,5,7,8,10,12,13,15)v) F(a,b,c,d) = ?Ñ(0,1,3,4,5,7,8,9,11,12,13,15)vi) F(U,V,W,Z)= pe(0,1,3,5,6,7,10,14,15)vii) F(A,B,C,D) = pú(5,6,7,8,9,12,13,14,15)

38. Write the POS form of a Boolean function F, which is represented in a truth table as follows:/* CBSE 2009*/

U V W F0 0 0 10 0 1 10 1 0 00 1 1 01 0 0 11 0 1 11 1 0 01 1 1 1

39. Write the SOP form of a Boolean function G, which is represented in a truth table as follows:/* CBSE 2010 */

P Q R G0 0 0 00 0 1 00 1 0 10 1 1 11 0 0 11 0 1 01 1 0 11 1 1 1

Chapter No.14(Networking Concepts)

1. What is the significance/role of ARPANET in the computer network? /* CBSE 2010 */2. Name two transmission media for networking. /* CBSE 2006 */3. Differentiate between Hackers and Crackers. /* CBSE 2006, 2008 */4. Explain function of Modem and Switch. /* CBSE 2006 */5. Write one advantage & disadvantage of BUS topology as compared to STAR topology.

/* CBSE 2006 */6. Differentiate between Internet and Intranet. /* CBSE 2006 */7. Write one difference between coaxial and optical cable. /* CBSE 2004 */8. Define Packet Switching and message switching. /* CBSE 2004, 2005 */9. Name two switching techniques used to transfer data between two terminals (computers).

/*CBSE 2009*/10. Write two application of Cyber Law. /* CBSE 2005 */11. What do you understand by the terms Cookies and Firewall? /* CBSE 2005 */12. Which of the following unit measures the speed with which data can be transmitted from onenode to another node of a network? Also, give the expansion of the suggested unit. /* CBSE 2007 */(i) Mbps (ii) KMph (iii) MGps

Page 34: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 34

13. Which of the following is not a unit for data transfer rate? /* CBSE 2010 */(i) mbps (ii) kbps (iii) sbps (iv) gbps

14. What are router, gateway, bridge, switch and repeater?15. Differentiate between uploading & downloading16. What is a topology? Write short note on Bus topology, Star topology and Ring topology.17. Differentiate between Telnet & FTP .?18. What is a switch? How is it different from hub?19. What is the difference between CDMA and GSM technologies20. What are spam mails? How can you protect your mailbox from spams?21. What do you understand by network security? Give any two techniques.22. Expand the following terminologies: /* CBSE */

CDMA, GSM, HTML, XML, SMS, MAN, WAN, LAN, FTP, WWW, URL, HTTP, PPP,SLIP, TCP/IP, WLL, RJ-45, ARPANET, ISP, DHTML, SIM, GPRS, ISDN, W3C,TDMA, FSF, OSI, GNU, FLOSS, OSS.

23. How is free software different from OSS?24. What is the purpose of using a Web Browser? Name any two commonly used Web

Browser. /* CBSE 2010 */25. Give difference between LAN, MAN and WAN. /* CBSE 2009 */26. What is protocol? Define working of TCP and IP protocol?27. What is protocol? Which protocol is used to copy a file from/to a remotely located

server? /* CBSE 2009 */28. Define OSS, Free software, Freeware, Shareware, FLOSS, GNU, FSF, OSI, W3C,

Proprietary software.29. How Trojan Horse and Worms spread?30. What is the difference between Virus and Worms in the computers? /* CBSE 2010 */31. What term do we use for a software/hardware device, which is used to block

unauthorized access while permitting authorized communication? This term is also usedfor a device or set of devices configured to permit, deny, encrypt, decrypt, or proxy all (inand out) computer traffic between different security domains based upon a set of rulesand other criteria. /* CBSE 2010 */

32. If someone has hacked your website, to whom you lodge the complain?33. What do you mean by IP address? How is it useful in computer security?34. Which of the following is not a client side script.

(i) VB script (ii) Java scripts (iii) ASP (iv) PHP35. Knowledge Supplement Organization has set up its new center at Mangalore for its office

and web based activities. It has 4 blocks of buildings as shown in the diagram below:/* CBSE 2010 */

Block A Block C

Block B Block D

Page 35: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 35

Center to center distances between various blocksBlack A to Block B 50 mBlock B to Block C 150 mBlock C to Block D 25 mBlock A to Block D 170 mBlock B to Block D 125 mBlock A to Block C 90 m

Number of ComputersBlack A 25Block B 50Block C 125Block D 10

e1) Suggest a cable layout of connections between the blocks.e2) Suggest the most suitable place (i.e. block) to house the server of this organization

with a suitable reason.e3) Suggest the placement of the following devices with justification

(i) Repeater(ii) Hub/Switch

e4) The organization is planning to link its front office situated in the city in a hilly regionwhere cable connection is not feasible, suggest an economic way to connect it withreasonably high speed?

e5) The organization is planning to connect its International Office situated in Mumbai.Which out of the following wired communication links, will you suggest for a veryhigh speed connectivity?

Telephone Analog LinesOptical FiberEthernet Cable

36. Ravya Industries has set up its new center at Kaka Nagar for its office and web basedactivities. The company compound has 4 buildings as shown in the diagram below:

Center to center distances between various buildings is as follows:Harsh Building to Raj Building 50 mRaz Building to Fazz Building 60 mFazz Building to Jazz Building 25 mJazz Building to Harsh Building 170 mHarsh Building to Fazz Building 125 mRaj Building to Jazz Building 90 m

RajBuilding

FazzBuilding

HarshBuilding

JazzBuilding

Page 36: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 36

Number of Computers in each of the buildings is follows:Harsh Building 15Raj Building 150Fazz Building 15Jazz Bulding 25

e1) Suggest a cable layout of connections between the buildings.e2) Suggest the most suitable place (i.e. building) to house the server of this organisation

with a suitable reason.e3) Suggest the placement of the following devices with justification:

(i) Internet Connecting Device/Modem(ii) Switch

e4) The organisation is planning to link its sale counter situated in various parts of thesame city, which type of network out of LAN, MAN or WAN will be formed? Justifyyour answer.

37. INDIAN PUBLIC SCHOOL in Darjeeling is setting up the network between its differentwings. There are 4 wings named as SENIOR(S), JUNIOR(J), ADMIN(A) and HOSTEL(H).

Distance between various wings are given below:

Wing A to Wing S 100m

Wing A to Wing J 200m

Wing A to Wing H 400m

Wing S to Wing J 300m

Wing S to Wing H 100m

Wing J to Wing H 450m

Number of Computers

Wing A 10

Wing S 200

Wing J 100

Wing H 50

i. Suggest a suitable Topology for networking the computer of all wings.ii. Name the wing where the Server is to be installed. Justify your answer.

iii. Suggest the placement of Hub/Switch in the network.iv. Mention an economic technology to provide internet accessibility to all wings. The

organization is planning to link its head office situated in Delhi with the offices atSrinagar. Suggest an economic way to connect it; the company is ready to compromiseon the speed of connectivity. Justify your answer.

Page 37: Sure Success 1-14 CS XII

Computer Science, Class XII, 2010-11

Mohd. Hashim, PGT (Computer Sc.), E-mail: [email protected], 9950589919 37

38. "China Middleton Fashion" is planning to expand their network in India, starting with twocities in India to provide infrastructure for distribution of their product. The company hasplanned to set up their main office units in Chennai at three different locations and have namedtheir offices as "Production Unit", "Finance Unit" and "Media Unit". The company has itscorporate unit in Delhi.

Approximate distances between these Units is as follows:

From To Distance

Production Unit Finance Unit 70 Mtr

Production Unit Media Unit 15 KM

Production Unit Corporate Unit 2112 KM

Finance Unit Media Unit 15 KMIn continuation of the above, the company experts have planned to install thefollowing number of computers in each of their office units:

Production Unit 150

Finance Unit 35

Media Unit 10

Corporate Unit 30i. Suggest the kind of network required (out of LAN, MAN, WAN) for connecting

each of the following office units:Production Unit and Media UnitProduction Unit and Finance Unit

ii. Which one of the following devices will you suggest for connecting all thecomputers within each of their office units?

Switch/Hub, Modem, Telephoneiii. Which of the following communication media, will you suggest to be procured

by the company for connecting their local office units in Chennai for veryeffective (High Speed) communication?

Telephone Cable, Optical Fiber, Ethernet Cableiv. Suggest a cable/wiring layout for connecting the company's local office units

located in Chennai. Also, suggest an effective method/technology for connectingthe company's office unit located in Delhi.