Upload
buitruc
View
237
Download
6
Embed Size (px)
Citation preview
2D
Computer Science [Question Bank for Final Revision]
[Assignment/XII/083/Final Revision/YK]
Yogesh Kumar
Assignment/XII/083/Final Revision/YK
2 ( © Yogesh Kumar)
Index
S.No. Topic Page
1. Header Files 4
2. Descriptive Questions of C++ 5
3. Finding Errors 6
4. Finding Outputs 8
5. Questions based on given class 18
6. Defining a class 20
7. Inheritance 24
8. Functions on 1D arrays 31
9. Fuctions on 2D arrays 33
10. Address calculation 35
11. Sorting 36
12. Merging 36
13. Stacks 37
14. Infix to Postfix expression 38
15. Evaluation of Postfix expression 38
16. Queues 39
17. Text File operations 40
18. Binary File operations 42
19. RDBMS – Descriptive Questions 49
20. SQL – writing queries and finding output 50
21. Postulates and theorems of Boolean algebra 56
22. Proving/verifying identities of Boolean algebra 56
23. K-Map 56
24. Logic diagrams 57
25. Finding expression from given Truth Table 57
26. Communication Technologies – descriptive questions 59
27. Network setup 47
ANSWERS
66
All suggestions to improve this book are most welcome.
Readers can also contact me to clear their doubts.
Email: [email protected], Phone (Kuwait): +965 65891262
Assignment/XII/083/Final Revision/YK
3 ( © Yogesh Kumar)
If anyo
Marks Distribution of the Board Question Paper
Q. No. Topics Marks
1. Revision of class XI C++ 12
2. OOP concepts
(Classes and objects, constructors and
destructors, inheritance)
12
3. Data Structures 14
4. Data File Handling 6
5. RDBMS and SQL 8
6. Boolean Algebra 8
7. Computer Network 10
Assignment/XII/083/Final Revision/YK
4 ( © Yogesh Kumar)
1. Header Files
iostream.h
1. cin
2. cout
3. read()
4. write()
5. seekg()
6. seekp()
7. tellg()
8. tellp()
9. getline()
10. get()
11. put()
conio.h
1. clrscr()
2. getch()
3. getche()
4. getpass()
5. gotoxy()
stdio.h
1. gets()
2. puts()
3. scanf()
4. printf()
5. getchar()
6. putchar()
7. getc()
8. putc()
9. rename()
10. remove()
stdlib.h
1. random()
2. randomize()
3. itoa()
4. atoi()
5. exit()
string.h
1. strlen()
2. strcmp()
3. strcmpi()
4. strcat()
5. strrev()
6. strcpy()
7. strupr()
8. strlwr()
ctype.h
1. isupper()
2. islower()
3. toupper()
4. tolower()
5. isdigit()
6. isspace()
7. isalpha()
8. isalnum()
math.h
1. pow()
2. sqrt()
3. abs()
4. fabs()
5. log()
6. cos()
7. sin()
8. tan()
9. floor()
10. ceil()
iomanip.h
1. setw()
2. setprecision()
3. setiosflags
fstream.h
1. open()
2. close()
3. eof()
Assignment/XII/083/Final Revision/YK
5 ( © Yogesh Kumar)
2. Descriptive Question (C++)
(i) State the difference between Object Oriented Programming and Procedural Programming.
(ii) What is the difference between a binary file and a text file?
(iii) What is the difference between a local variable and a global variable? Also, give a suitable C++ code to
illustrate both. (CBSE 2011)
(iv) Differentiate between members, which are present within the private visibility mode with those which
are present within the public visibility mode. (CBSE 2011)
(v) What is the difference between the members in private visibility mode and the members in public
visibility mode inside a class? Also give a suitable C++ code to illustrate both. (CBSE 2012)
(vi) What is the difference between seekg() and tellg()
(vii) Differentiate between syntax error, logical error and runtime error in C++?
(viii) Write any two differences between constructor and destructor. Write the function headers for
constructor and destructor of a class Member. (CBSE 2013)
(ix) What is the difference between actual and formal parameters? Give a suitable example to illustrate it
using a C++ code. (CBSE 2012, 2014)
(x) Write 4 characteristics of a constructor function used in a class. (CBSE 2014)
(xi) What is the benefit of using function prototype for a function? Give a suitable example to illustrate it
using a C++ code. (CBSE 2013)
(xii) What is typedef? Give a suitable example to illustrate it using a C++ code.
(xiii) What is the importance of main() function? Give a suitable example to illustrate it using a C++ code.
(xiv) What is a constant? How it is different from a macro?
(xv) What is a reference variable? Give an example.
(xvi) What are preprocessor statements? State any two examples.
(xvii) Define function overloading? Give a suitable example to illustrate it using a C++ code.
(xviii) Define a class? How it is different from a structure?
(xix) Define data hiding, data encapsulation, inheritance, and abstraction?
(xx) How does a global variable accessed inside a function?
(xxi) What is a copy constructor? State when a copy constructor is invoked?
(xxii) Find the correct identifiers out of the following, which can be used for naming variable, constants or
functions in a C++ program: (CBSE-Delhi 2015)
While, for, Float, new, 2ndName, A%B, Amount2, _Counter
(xxiii) What is a copy constructor? Give a suitable example in C++ to illustrate with its definition within a class
and a declaration of an object with the help of it. (CBSE-Delhi,Outside Delhi 2015)
(xxiv) Find the correct identifiers out of the following, which can be used for naming Variable, Constants or
Functions in a C++ program: (CBSE-Outside Delhi 2015)
For, while, INT, NeW, delete, 1stName, Add+Subtract, name1
(xxv) Observe the following program very carefully and write the names of those header file(s), which are
essentially needed to compile and execute the following program successfully: (CBSE- Delhi 2015)
typedef char TEXT[80];
void main()
TEXT Str[] = “Peace is supreme”;
int Index=0;
while (Str[Index]!=’\0’)
if (isupper(Str[Index]))
Str[Index++]=’#’;
else
Str[Index++]=’*’;
puts(str);
Assignment/XII/083/Final Revision/YK
6 ( © Yogesh Kumar)
(xxvi) Observe the following program very carefully and write the name of those header file(s), which are essentially needed to compile and execute the following program successfully:
(CBSE-Outside Delhi 2015) typedef char STRING[80];
void main()
STRING Txt[] = "We love Peace";
int Count=0;
while (Txt[Count]!='\0')
if (isalpha(Txt[Count]))
Txt[Count++]='@' ;
else
Txt[Count++]='#' ;
puts (Txt) ;
3. Finding Errors Observe each of the following C++ code very carefully and rewrite it after removing any/all syntactical errors with each correction underlined. Note: Assume all required header files are already being included in the program. (i) #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);
(ii) #include <iostream.h>
void main()
struct movie
char movie_name[20];
char movie_type;
int ticket_cost = 100;
MOVIE;
gets(movie_name);
gets(movie_type);
(iii) #include <iostream.h>
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<<endl;
Assignment/XII/083/Final Revision/YK
7 ( © Yogesh Kumar)
else
cout<<Value+multiple<<endl;
(iv) #include [iostream.h]
class PAYITNOW
int charge;
PUBLIC:
void Raise() cin>>charge;
void Show() cout<<charge;
;
void main()
PAYITNOW P;
P.Raise();
Show();
(v) #include [iostream.h]
typedef char Text(80);
void main()
Text T="Indian";
int Count = strlen(T);
cout<<T<<'has'<<Count<<'characters'<<endl;
(CBSE 2011)
(vi) #include <iostream.h>
class BOOK
long BId, Qty;
Public:
void Purchase() cin>>BId>>Qty;
void Sale
cout<<setw(5)<<BId<<"Old:"<<Qty<<endl;
cout<<"New:"<<--Qty<<endl;
;
void main()
BOOK B;
B.Purchase();
Sale();
B.Sale()
(CBSE 2012)
(vii) #define Convert(P, Q) P+2*Q;
void main()
Float A, B, Result;
cin>>A>>B;
Result = Convert[A,B];
cout<<"Output:"<<Result<<endline;
(CBSE 2013)
(viii) typedef char[50] STRING;
void main()
Assignment/XII/083/Final Revision/YK
8 ( © Yogesh Kumar)
City STRING;
gets(City);
cout<<City[0]<<' \t<<City[2];
cout<<City<<endline;
(CBSE 2014)
(ix) #Define float Max=70.0; Void main()
int Speed
char Stop=’N’;
cin>>Speed;
if Speed>Max
Stop=’Y’;
cout<<Stop<<end;
(CBSE-Delhi 2015)
(x) #Define float MaxSpeed=60.5;
void main()
int MySpeed
char Alert='N' ;
cin»MySpeed;
if MySpeed>MaxSpeed
Alert='Y' ;
cout<<Alert<<endline;
(CBSE-Outside Delhi 2015)
4. Finding Output (a) Find the output of the following programs
Note: Assume all required header files are already being included in the program.
(i) void NewText(char String[], int&Position)
char *Pointer = String;
int Length = strlen(String);
for (;Position <Length-2; Position +=2, Pointer++)
*(Pointer+Position)= toupper(*(Pointer+Position));
void main()
int Location = 0;
char Message[] = "Dynamic Act";
NewText(Message, Location);
cout<<Message<<"#"<<Location;
(ii) void Computer(char str[])
char *Name = str;
for (int x =0; x < strlen(Name); x++)
if (islower(Name[x]))
Name[x] = toupper(Name[x]);
else if (isupper(Name[x]))
Assignment/XII/083/Final Revision/YK
9 ( © Yogesh Kumar)
if (x %2 == 0)
Name[x] = tolower(Name[x]);
else Name[x] = Name[x-1];
puts(Name);
void main()
char str1[] = "ComPUteR";
Computer("ComPUteR");
cout<<str1<<endl;
Computer(str1);
cout<<str1;
(iii) int v1 = 5, v2= 10;
for (int x = 1; x <= 2; x++)
cout<<++v1<<'\t'<<v2--<<endl;
cout<<--v2<<'\t'<<v1++<<endl;
(iv) void Print(char *P)
P = "Pass"; cout<<"value is: "<<P<<endl;
void main()
char *q = "Best of Luck";
Print(q);
(v) char *p = "Is this Easy?";
char c;
c = ++ *p++;
printf("%c", c);
cout<<"\n"<<p;
(vi) void Execute(int &B, int C = 100)
int Temp = B+C;
B += Temp;
if (C == 100)
cout<<Temp<<B<<C<<endl;
void main()
int M = 90, N = 10;
Execute(M);
cout<<M<<N<<endl;
Execute(M, N);
cout<<M<<N<<endl;
(vii) int a = 3;
void demo(int x, int y, int &z)
a += x+y;
z = a+y;
y += x;
cout<<x<<y<<z<<endl;
void main()
int a = 2, b = 5;
demo(::a,a,b);
Assignment/XII/083/Final Revision/YK
10 ( © Yogesh Kumar)
cout<<::a<<a<<b<<endl;
demo(::a,a,b);
(viii) char * N1 = "What a PRofiT!";
for (int i = 0; i < strlen(N1); i++)
if (islower(N1[i]))
N1[i] = toupper(N1[i]);
else if ( isupper(N1[i]) )
if (i %2 != 0)
N1[i] = tolower(N1[i-1]);
else N1[i]--;
cout<<N1<<endl;
(ix) long NUM = 1234543;
int F = 0, S = 0;
do
int Rem = NUM%10;
if(Rem % 2 == 0)
F += Rem;
else S -= Rem;
NUM /= 10;
while (NUM > 0);
cout<<F-S;
(x) class state
char*state_name;
int size;
public:
state() size=0; state_name = new char[size+1];
state (char *s)
size = strlen(s);
state_name = new char[size+1];
strcpy(state_name,s);
void display() cout<<state_name<<endl;
void replace (state &a, state &b)
size = a.size + b.size;
delete state_name;
state_name = new char[size+1];
strcpy(state_name, b.state_name);
strcat(state_name, a.state_name);
;
void main()
char *temp = "Delhi";
state state1(temp), state2("Nagpur"), state3("Mumbai"), S1, S2;
S1.replace(state1, state2);
S2.replace(S1, state3);
S1.display(); S2.display();
Assignment/XII/083/Final Revision/YK
11 ( © Yogesh Kumar)
(xi) #include <iostream.h>
void ChangeArray(int Number, int ARR[], int Size)
for (int L = 0; L<Size; L++)
if (L<Number)
ARR[L] += L;
else ARR[L] *= L;
void Show(int ARR[], int Size)
for (int L=0; L<Size;L++)
(L%2!=0)?cout<<ARR[L]<<"#":cout<<ARR[L]<<endl;
void main()
int Array[] = 30, 20, 40, 10, 60, 50;
ChangeArray(3, Array, 6);
Show(Array, 6);
(CBSE 2011)
(xii) #include <iostream.h>
void main()
int Track[] = 10, 20, 30, 40, *Striker;
Striker = Track;
Track[1]+=30;
cout<<"Striker->"<<*Striker<<endl;
*Striker -= 10;
Striker++;
cout<<"Next@"<<*Striker<<endl;
Striker+=2;
cout<<"Last@"<<*Striker<<endl;
cout<<"Reset To"<<Track[0]<<endl;
(CBSE 2011)
(xiii) #include <iostream.h>
class TRAIN
int Tno, TripNo, PersonCount;
public:
TRAIN(int Tmno=1)Tno=Tmno;TripNo=0;PersonCount=0;
void Trip(int TC=100)TripNo++;PersonCount+=TC;
void Show()cout<<Tno<<":"<<TripNo<<":"<<PersonCount<<endl;
;
void main()
TRAIN T(10), N;
N.Trip();
T.Show();
T.Trip(70);
N.Trip(40);
N.Show();
T.Show();
(CBSE 2012)
Assignment/XII/083/Final Revision/YK
12 ( © Yogesh Kumar)
(xiv) #include<iostream.h>
#include<ctype.h>
typedef char Txt80 [80];
void main()
char *PText;
Txt80 Txt = "Ur2GReAt";
int N=6;
PText=Txt;
while (N>=3)
Txt[N]=(isupper(Txt[N]?tolower(Txt[N]:toupper(Txt[N]));
cout<<PText<<endl;
N--;
PText++;
(CBSE 2012)
(xv) #include <iostream.h>
void main()
char *String = "SHAKTI";
int *Point, Value[] = 10, 15, 70, 19;
Point = Value;
cout<<*Point<<String<<endl;
String++;
Point++;
cout<<*Point<<String<<endl;
(CBSE 2013)
(xvi) #include <iostream.h>
class Aroundus
int Place, Humidity, Temp;
public:
Aroundus(int P=2) Place=P; Humidity=60; Temp=20;
void Hot(int T) Temp += T;
void Humid(int H) Humidity += H;
void JustSee()
cout<<Place<<":"<<Temp<<"&"<<Humidity<<"%"<<endl;
;
void main()
Aroundus A, B(5);
A.Hot(10);
A.JustSee();
B.Humid(15);
B.Hot(2);
B.JustSee();
A.Humid(5);
A.JustSee();
(CBSE 2013)
Assignment/XII/083/Final Revision/YK
13 ( © Yogesh Kumar)
(xvii) #include <iostream.h>
void main()
char *String = "SARGAM";
int *Ptr, A[] = 1, 5, 7, 9;
Ptr = A;
cout<<*Ptr<<String<<endl;
String++;
Ptr+=3;
cout<<*Ptr<<String<<endl;
getch();
(CBSE 2014)
(xviii) #include <iostream.h>
class Player
int Score, Level;
char Game;
public:
Player(char GGame='A')
Score=0; Level=1; Game=GGame;
void Start(int SC);
void Next();
void Disp()
cout<<Game<<"@"<<Level<<endl;
cout<<Score<<endl;
;
void main()
Player P, Q('B');
P.Disp();
Q.Start(75);
Q.Next();
P.Start(120);
Q.Disp();
P.Disp();
void Player::Next()
Game = (Game == 'A')?'B':'A';
void Player::Start(int SC)
Score += SC;
if (Score>=100)
Level=3;
else if (Score>=50)
Level=2;
else
Level=1;
(CBSE 2014)
Assignment/XII/083/Final Revision/YK
14 ( © Yogesh Kumar)
(xix) void Position(int &C1,int C2=3)
C1+=2;
C2+=Y;
void main()
int P1=20, P2=4;
Position(P1);
cout<<P1<<”,”<<P2<<end1;
Position(P2,P1);
cout<<P1<<”,”<<P2<<end1;
(CBSE 2015)
(xx) class Calc
char Grade;
int Bonus;
public:
Calc() Grade=’E’;Bonus=0;
void Down(int G)
Grade–=G;
Void Up(int G)
Grade+=G;
Bonus++;
void Show()
cout<<Grade<<”#”<<Bonus<<end1;
;
void main()
Calc c;
C.Down(2);
C.Show();
C.Up(7);
C.Show();
C.Down(2);
C.Show();
(CBSE-Delhi 2015)
(xxi) void Location(int &X,int Y=4)
Y+=2;
X+=Y;
void main()
int PX=l0,PY=2;
Location(PY) ;
cout<<PX<<" , "<<PY<<endl ;
Location(PX,PY);
cout<<PX<<" , "<<PY<<endl ;
Assignment/XII/083/Final Revision/YK
15 ( © Yogesh Kumar)
(CBSE-Outside Delhi 2015)
(xxii) class Eval
char Level;
int Point;
public:
Eval() Level='E';Point=0;
void Sink(int L)
Level= L;
void Float(int L)
Level += L;
Point++;
void Show()
cout<<Level<<"#"<<Point<<endl;
;
void main()
Eval E;
E.Sink(3);
E.Show();
E.Float(7);
E.Show();
E.Sink(2);
E.Show();
(CBSE-Outside Delhi 2015)
(b) Choose the correct option:
(i) Go through the C++ code shown below, and find out the possible output or outputs from the
suggested output options (i) to (iv). Also, write the least value and the highest value, which can
be assigned to the variable Guess. (CBSE 2011)
#include<iostream.h>
#include<stdlib.h>
void main()
randomize();
int Guess, High = 4;
Guess = random(High)+50;
for (int C = Guess; C<=55; C++)
cout<<C<<"#";
Options:
(i)50#51#52#53#54#55# (ii)52#53#54#55 (iii)53#54# (iv)51#52#53#54#55
(ii) Observe the following program and find out, which output(s) out of (i) to (iv) will not be expected
from the program? What will be the minimum and the maximum value assigned to the variable
Chance? (CBSE 2012)
#include<iostream.h>
#include<stdlib.h>
void main()
randomize();
Assignment/XII/083/Final Revision/YK
16 ( © Yogesh Kumar)
int Game[]=10,16, P;
int Turn=random(2)+5;
for (int T=0; T<2; T++)
P=random(2);
cout<<Game[P]+Turn<<"#";
Options:
(i) 15#22# (ii) 22#16# (iii) 16#21# (iv) 21#22#
(iii) Based on the following C++ code, find out the expected correct output(s) from the options (i) to
(iv). Also find the minimum and the maximum value that can be assigned to the variable Trick
used in the code at the time when the value of Count is 3. (CBSE 2013)
#include<iostream.h>
#include<stdlib.h>
void main()
randomize();
char Status[][10] = "EXCEL", "GOOD", "OK";
int Turn=10, Trick;
for (int Count=1; Count<4; Count++)
Trick = random(Count);
cout<<Turn-Trick<<Status[Trick]<<"#";
Options:
(i) 10EXCEL#10EXCEL#8OK# (ii) 10EXCEL#8OK#9GOOD#
(iii) 10EXCEL#9GOOD#10EXCEL# (iv) 10EXCEL#10GOOD#8OK#
(iv) Read the following C++ code carefully and find out, which out of the given options (i) to (iv) are
expected correct output(s) of it. Also, write maximum and the minimum value that can be
assigned to the variable Start used in the code: (CBSE 2014)
#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
void main()
int Guess[4]=200,150,20,250;
int Start=random(2)+2;
for (int C=Start;C<4;C++)
cout<<Guess[C]<<"#";
getch();
Options:
(i) 200#150# (ii) 150#20# (iii) 150#20#250# (iv) 20#250#
(v) Study the following program and select the possible output(s) from the options (i) to (iv) following it. Also, write the maximum and the minimum values that can be assigned to the variable NUM. Note :
– Assume all required header files are already being included in the program.
– random(n) function generates an integer between 0 and n – 1. (CBSE-Delhi 2015)
void main()
Assignment/XII/083/Final Revision/YK
17 ( © Yogesh Kumar)
randomize(); int
NUM;
NUM=random(3)+2;
char TEXT[]=”ABCDEFGHIJK”;
for (int I=1;I<=NUM; I++)
for(int J=NUM; J<=7;J++)
cout<<TEXT[J];
cout<<end1;
(i) FGHI (ii) BCDEFGH (iii) EFGH (iv) CDEFGH
FGHI BCDEFGH EFGH CDEFGH
FGHI EFGH
FGHI EFGH
(vi) Study the following program and select the possible output(s) from the option (i) to (iv)
following it. Also, write the maximum and the minimum values that can be assigned to the
variable VAL. (CBSE-Outside Delhi 2015)
Note: ‐Assume all required header files are already being included in the program. ‐random(n) function generates an integer between 0 and n‐1. void main()
randomize();
int VAL;
VAL=random(3)+2;
char GUESS[]="ABCDEFGHIJK";
for (int I=l;I<=VAL;I++)
for(int J=VAL;J<=7;J++)
cout«GUESS[J];
cout«endl;
(i) (ii) (iii) (iv)
BCDEFGH CDEFGH EFGH FGHI
BCDEFGH CDEFGH EFGH FGHI
EFGH FGHI
EFGH FGHI
(c) Write the output of the following C++ code. Also, write the name of the feature of object oriented
Programming used in the following program jointly illustrated by the functions [I] to [IV]. (CBSE 2011)
#include<iostream.h>
void Print() //Function [I]
for (int K=1; K<=60; K++) cout<<"-";
cout<<endl;
void Print(int N) //Function [II]
for (int K=1; K<=N; L++) cout<<"*";
cout<<endl;
Assignment/XII/083/Final Revision/YK
18 ( © Yogesh Kumar)
void Print(int A, int B) //Function [III]
for (int K=1; K<=B; K++) cout<<A*K;
cout<<endl;
void Print(char T, int N) //Function [IV]
for (int K=1; K<=N; K++) cout<<T;
cout<<endl;
void main()
int U=9, V=4, W=3;
char C = '@';
Print(C, V);
Print(U, W);
5. Questions based on given class (i) Answer the questions (a) and (b) after going through the following class: (CBSE 2012)
class Tour
int LocationCode; char Location[20]; float Charges;
public:
Tour() //Function 1
LocationCode=1; strcpy(Location,"PURI"); Charges=1200;
void TourPlan(float C) //Function 2
cout<<PlaceCode<<":"<<Place<<":"<<Charges<<endl;
Charges += 100;
Tour (int LC, char L[], float C) //Function 3
LocationCode=LC; strcpy(Location, L); Charges = C;
~Tour() //Function 4
cout<<"Tour Plan cancelled";
;
(a) In Object Oriented Programming, what are Function 1 and Function 3 combined together referred
as?
(b) In Object oriented Programming, which concept is illustrated by Function 4? When is this function
called/invoked?
(ii) Answer the questions (a) and (b) after going through the following class: (CBSE 2013)
class Motor
int MotorNo, Track;
public:
Motor(); //Function 1
Assignment/XII/083/Final Revision/YK
19 ( © Yogesh Kumar)
Motor(int MN); //Function 2
Motor(Motor &m); //Function 3
void Allocate(); //Function 4
void Move(); //Function 5
;
void main()
Motor M;
.
.
(a) Out of the following, which of the options is correct for calling Function 2?
Option 1 – Motor N(M);
Option 2 – Motor P(10);
(b) Name the feature of Object Oriented Programming, which is illustrated by Function 1, Function 2
and Function 3 combined together.
(iii) Answer the questions (a) and (b) after going through the following class: (CBSE 2014)
class Health
int PId, DId;
public:
Health(int PPId); //Function 1
Health(); //Function 2
Health(Health &H); //Function 3
void Entry(); //Function 4
void Display(); //Function 5
;
void main()
Health H(20); //Statement 1
(a) Which of the function out of Function 1, 2, 3, 4, or 5 will get executed when the statement 1 is
executed in the above code?
(b) Write a statement to declare a new object G with reference to already existing object H using
Function 3.
(iv) Observe the following C++ code and answer the questions (i) and (ii): (CBSE-Delhi 2015)
class Traveller
long PNR;
char TName[20];
public :
Traveller() //Function 1
cout<<”Ready”<<end1;
void Book(long P,char N[]) //Function 2
PNR = P; strcpy(TName, N);
Assignment/XII/083/Final Revision/YK
20 ( © Yogesh Kumar)
void Print() //Function 3
cout<<PNR << TName <<end1;
~Traveller() //Function 4
cout<<”Booking cancelled!”<<end1;
;
(i) Fill in the blank statements in Line 1 and Line 2 to execute Function 2 and Function 3 respectively in the following code: void main()
Traveller T;
_________ //Line 1
_________ //Line 2
//Stops here
(ii) Which function will be executed at //Stops here ? What is this function referred as?
(v) Observe the following C++ code and answer the questions (i) and (ii) : (CBSE-Outside Delhi 2015)
class Passenger
long PNR;
char Name [20] ;
public:
Passenger() //Function 1
cout<<"Ready"<<endl;
void Book(long P,char N[]) //Function 2
PNR = P; strcpy(Name, N);
void Print() //Function 3
cout«PNR << Name <<endl;
~Passenger() //Function 4
cout<<"Booking cancelled!"<<endl;
;
(i) Fill in the blank statements in Line 1 and Line 2 to execute Function 2 and Function 3 respectively in the following code:
void main()
Passenger P;
___________ //Line 1
___________ //Line 2
//Ends here
(ii) Which function will be executed at //Ends here? What is this function referred as?
6. Define classes (i) Define a class Candidate with the following specifications: (CBSE 2011)
Private members:
A data member RNo (Registration Number) of type long
A data member Name of type string
A data member Score of type float
A data member Remarks of type string
A member function AssignRem() to assign remarks as per the Score obtained by a candidate.
Score range and the respective Remarks are shown as follows:
Score Remarks
Assignment/XII/083/Final Revision/YK
21 ( © Yogesh Kumar)
>=50 Selected
Less than 50 Not selected
Public members:
A function ENTER() to allow the user to enter values for RNo, name, Score & call function
AssignRem() to assign the Remarks.
A function DISPLAY() to allow the user to view the contents of all the data members.
(ii) Define a class SUPPLY with the following specifications: (CBSE 2012)
Private members:
Code of type int
FoodName of type string
Sticker of type string
FoodType of type string
A member function GetType() to assign the following values for FoodType as per the given
Sticker:
Sticker FoodType
GREEN Vegetarian
YELLOW Contains Egg
RED Non-Vegetarian
Public members:
A function FoodIn() to allow the user to enter values for Code, FoodName, Sticker and call
function GetType() to assign respective FoodType.
A function FoodOut() to allow the user to view the content of all the data members.
(iii) Define a class Tourist with the following specifications: (CBSE 2013)
Data members:
Carno – To store Car No
Origin – To store Place name
Destination – To store Place name
Type – To store Car type such as ‘E’ for economy
Distance – To store the distance in Km
Charge – To store the Car Fare
Mamber Functions:
A constructor to initialize Type as ‘E’ and Fare as 250
A function CalcCharge() to calculate fare as per the following criteria:
Type Charge
‘E’ 16*Distance
‘A’ 22*Distance
‘L’ 30*Distance
A function ENTER() to allow the user to enter values for CarNo, Origin, Destination,
Type, and Distance. Also, this function should call CalcCharge() to calculate Fare.
A function Show() to display the content of all the data members on screen.
(iv) Define a class CABS in C++ with the following specifications: (CBSE 2014)
Assignment/XII/083/Final Revision/YK
22 ( © Yogesh Kumar)
Data members:
CNo – To store Cab No.
Type – To store character ‘A’, ‘B’, or ‘C’ as City Type
PKM – To store per Kilo Meter charges
Dis – To store distance travelled (in KM)
Mamber Functions:
A constructor function to initialize Type as ‘A’ and CNo as ‘1111’
A function Charges() to assign PKM as per the following table:
Type PKM
‘A’ 25
‘B’ 20
‘C’ 15
A function Register() to allow the administrator to enter values for CNo, and Type.
Also, this function should call Charges() to assign PKM charges.
A function ShowCab() to allow the user to enter the value of Distance and display CNo,
Type, PKM, PKM*Distance (as Amount) on screen.
(v) Define a class TravelPlan in C++ with the following descriptions:
Private members:
PlanCode of type long
Place of type character array (string)
No_of_Travellers of type integer
No_of_Buses of type integer
Public Members:
1. A constructor to assign initial values of PlanCode as 1001, Place as “Agra”,
No_of_Travellers as 5, No_of_buses as 1.
2. A function NewPlan() which allows the user to enter PlanCode, Place, and
No_of_Travellers. Also assign the value to No_of_Buses as per the following conditions:
No_of_travellers No_of_Buses
Less than 20 1
20-39 2
40 or more 3
(vi) Declare a class TEST with the following descriptions:
Private members:
TestCode of type integer
Description of type string
NoCandidate of type integer
CenterReqd (No. of centers required) of type integer
A member function CALCNTR() to calculate and return the no. of centers as
(NoCandidate/100+1)
Public members:
A function SCHEDULE() to allow user to enter values for TestCode, Description, and
NoCandidate and call function CALCNTR() to calculate the number of centres.
A function DISPTEST() to allow the user to view the contents of all the data members.
Assignment/XII/083/Final Revision/YK
23 ( © Yogesh Kumar)
(vii) Declare a class FLIGHT with the following descriptions:
Private members:
A data member FlightNumber 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 criteria:
Distance Fuel
<=1000 500
>= 1000 and <= 2000 1100
> 2000 2200
Public members:
A function FEEDINFO() to allow user to enter values for Flight Number, Destination,
Distance and call function CALFUEL() to calculate the quantity of Fuel.
A function SHOWINFO() to allow the user to view the contents of all the data members.
(viii) Write the definition of a class PIC in C++ with following description: (CBSE-Delhi 2015)
Private Members – Pno //Data member for Picture Number (an integer) – Category //Data member for Picture Category (a string) – Location //Data member for Exhibition Location (a string) – FixLocation //A member function to assign
//Exhibition Location as per category //as shown in the following table
Category Location
Classic Amina
Modern Jim Plaq
Antique Ustad Khan
Public Members – Enter() //A function to allow user to enter values
//Pno, category and call FixLocation() function – SeeAll() //A function to display all the data members
(ix) Write the definition of a class Photo in C++ with following description: (CBSE-Outside Delhi 2015)
Private Members
Pno //Data member for Photo Number
(an integer)
Category //Data member for Photo Category
(a string)
Exhibit //Data member for Exhibition Gallery
(a string)
FixExhibit //A member function to assign
//Exhibition Gallery as per Category
//as shown in the following table
Category Exhibit
Antique Zaveri
Modern Johnsen
Classic Terenida
Public Members
Assignment/XII/083/Final Revision/YK
24 ( © Yogesh Kumar)
Register() //A function to allow user to enter
//values
//Pno,Category and call FixExhibit()
//function
ViewAll() //A function to display all the data
//members
7. Inheritance (i) Answer the questions (a) to (d) based on the following:
class CUSTOMER
int Cust_no;
char Cust_Name[20];
protected:
void Register();
public:
CUSTOMER();
void Status();
;
class SALESMAN
int Salesman_no;
char Salesman_Name[20];
protected:
float Salary;
public:
SALESMAN();
void Enter();
void Show();
;
class SHOP : private CUSTOMER , public SALESMAN
char Voucher_No[10];
char Sales_Date[8];
public:
SHOP();
void Sales_Entry();
void Sales_Detail();
;
a. Write the names of data members which are accessible from objects belonging to class
CUSTOMER.
b. Write the names of all the member functions which are accessible from objects belonging to
class SALESMAN.
c. Write the names of all the members which are accessible from member functions of class
SHOP.
d. How many bytes will be required by an object belonging to class SHOP?
(ii) Consider the following class declaration and answer the questions that follow:
class Mydata
protected:
int data;
public:
Assignment/XII/083/Final Revision/YK
25 ( © Yogesh Kumar)
void get_mydata(int);
void manip_data(int);
void show_data(int);
;
class mydata1 : private Mydata
protected:
int data1;
public:
void get_mydata1(int);
void show_data1(int);
;
class person : public mydata1
public:
void show_data2()
;
a. Name all the base classes and their derived classes.
b. Name data and functions inherited by class person.
c. Name the data and function members which can be accessed by the objects of class 'person'.
d. Name the class(es) in which data1 can be accessed.
(iii) Consider the following class declaration and answer the questions:
class zoo
char location[20];
protected:
int no_of_animals;
public:
void inputdata(char, int);
void outputdata();
;
class animal : protected zoo
int tail;
protected:
int legs;
public:
void readdata(int, int);
void writedata();
;
class carnivorous:private animal
int paw_size;
public:
void fetchdata(int);
void displaydata();
;
a. Name the base class and the derived class of the class animal.
b. Name the data member(s) that can be accessed from function displaydata().
c. Name the data member(s) that can be accessed by an object of carnivorous class.
d. Is the member function outputdata() accessible to the objects of animal class?
(iv) Find the output of the following program:
#include <iostream.h>
#include <conio.h>
Assignment/XII/083/Final Revision/YK
26 ( © Yogesh Kumar)
class base
private:
int x;
float y;
public:
base()
cout<<"\nbase CC";
void show()
cout<<”\n I am base”;
~base()
cout<<"\nbase DC";
;
class der1 : public base
private:
int x;
float y;
base ob;
public:
void show()
cout<<”\n I am derived1”;
der1()
cout<<"\nder1 CC";
~der1()
cout<<"\nder1 DC";
;
class der2 : public der1
private:
int x;
float y;
der1 od1;
public:
void show()
cout<<”\n I am derived2”;
der2()
cout<<"\nder2 CC";
~der2()
cout<<"\nder2 DC";
;
void main()
der2 d2;
d2.show();
d2.der1::show();
d2.base::show();
(v) Answer the questions (a) to (d) based on the following: (CBSE 2011)
class Student
Assignment/XII/083/Final Revision/YK
27 ( © Yogesh Kumar)
int RNo;
char name[20];
float marks;
protected:
void Result();
public:
Student();
void Register(); void Display();
;
class Faculty
long FCode;
char FName[20];
protected:
float pay;
public:
Faculty();
void Enter();
void show();
;
class Course:public Student, private Faculty
long CCode[10]; char courseName[50];
char StartDate[8], EndDate[8];
public:
Course();
void Commence();
void CDetail();
;
a. Which type of inheritance is illustrated in the above C++ code?
b. Write the names of all the data member(s), which is/are accessible from member function
Commence of class Course.
c. Write the names of member functions, which are accessible from objects of class Course.
d. Write the names of all the members, which are accessible from objects of class Faculty.
(vi) Answer the questions (a) to (d) based on the following: (CBSE 2012)
class ORGANIZATION
char Address[20];
double Budget, Income;
protected:
void Compute();
public:
ORGANIZATION();
void Get();
void show();
;
class WORKAREA: public ORGANIZATION
char Address[20];
int Staff;
protected:
Assignment/XII/083/Final Revision/YK
28 ( © Yogesh Kumar)
double Pay;
void Calculate();
public:
WORKAREA();
void Enter();
void Display();
;
class SHOWROOM:private ORGANIZATION
char Address[20];
float Area; double Sale;
public:
SHOWROOM();
void Enter();
void Show();
;
a. Name the type of inheritance is illustrated in the above C++ code?
b. Write the names of data members, which are accessible from member functions of class
SHOWROOM.
c. Write the names of all the member functions, which are accessible from objects belonging to class
WORKAREA.
d. Write the names of all the members, which are accessible from objects of class SHOWROOM.
(vii) Answer the questions (a) to (d) based on the following: (CBSE 2013)
class Student
int Class, Rno;
char Section;
protected:
char SName[20];
public:
Student();
void Stentry();
void Stdisplay();
;
class Score: private Student
float Marks[5];
protected:
char Grade[5];
public:
Score();
void Sentry();
void Sdisplay();
;
class Report:public Score
float Total, Avg;
public:
char OverallGrade, Remarks[20];
Report();
void REvaluate();
Assignment/XII/083/Final Revision/YK
29 ( © Yogesh Kumar)
void RPrint();
;
a. Which type of inheritance is shown in the above example?
b. Write the names of those data members, which can be directly accessed from the objects of class
Report.
c. Write the names of those member functions, which can be directly accessed from the objects of
class Report.
d. Write the names of those data members, which can be directly accessed from the Sentry()
function of class Score.
(viii) Answer the questions (a) to (d) based on the following: (CBSE 2014)
class Campus
long Id;
char City[20];
protected:
char Country[20];
public:
Campus();
void Register();
void Display();
;
class Dept: private Campus
long DCode[10];
char HOD[20];
protected:
double Budget;
public:
Dept();
void Enter();
void Show();
;
class Applicant:public Dept
long RegNo;
char Name[20];
public:
Applicant();
void Enrol();
void View();
;
a. Which type of inheritance is shown in the above example?
b. Write the names of those member functions, which are directly accessed from the objects of class
Applicant.
c. Write the names of those data members, which can be directly accessible from the member
functions of class Applicant.
d. Is it possible to directly call the function Display() of class University from an object of class Dept?
(Answer as Yes or No).
(ix) Answer the questions (i) to (iv) based on the following: (CBSE-Delhi 2015)
class Exterior
Assignment/XII/083/Final Revision/YK
30 ( © Yogesh Kumar)
int OrderId;
char Address[20];
protected:
float Advance;
public:
Exterior();
void Book(); void View();
;
class Paint:public Exterior
int WallArea,ColorCode;
protected:
char Type;
public:
Paint();
void PBook();
void PView();
;
class Bill : public Paint
float Charges;
void Calculate();
public :
Bill();
void Billing();
void Print();
;
(i) Which type of Inheritance out of the following is illustrated in the above example? – Single Level Inheritance – Multi Level Inheritance – Multiple Inheritance
(ii) Write the names of all the data members, which are directly accessible from the member functions of class Paint.
(iii) Write the names of all the member functions, which are directly accessible from an object of class Bill.
(iv) What will be the order of execution of the constructors, when an object of class Bill is declared?
(x) Answer the questions (i) to (iv) based on the following: (CBSE-Outside Delhi 2015)
class Interior
int OrderId;
char Address[20];
protected:
float Advance;
public:
Interior();
void Book(); void View();
;
class Painting:public Interior
int WallArea,ColorCode;
protected:
char Type;
public:
Painting();
void PBook();
void PView();
;
class Billing:public Painting
Assignment/XII/083/Final Revision/YK
31 ( © Yogesh Kumar)
float Charges;
void Calculate();
public:
Billing();
void Bill();
void BillPrint();
;
(i) Which type of Inheritance out of the following is illustrated in the above example?
‐Single Level Inheritance ‐Multi Level Inheritance ‐Multiple Inheritance
(ii) Write the names of all the data members, which are directly accessible from the member functions of class Painting.
(iii) Write the names of all the member functions, which are directly accessible from an object of class Billing.
(iv) What will be the order of execution of the constructors, when an object of class Billing is declared?
8. Functions on 1D Arrays (i) Write a function in C++ which accepts an integer array and its size as arguments/parameters and
exchanges the values of first half side elements with the second half side elements of the array.
Example:
If an array of eight elements has initial contents as
2,4,1,6,7,9,23,10
The function should rearrange the array as
7,9,23,10,2,4,1,6
(ii) Define a function Reversearray(int[], int) that would accept a one dimensional integer array NUMBERS
and its size N. The function should reverse the contents of the array without using any second array.
Note: Use the concept of swapping elements (Example: If the array initially contains 2, 15, 3, 14, 7, 9,
19, 6, 1, 10, then after reversal the array should contain 10, 1, 6, 19, 9, 7, 14, 3, 15, 2)
(iii) Define a function SwapArray(int[], int), that would accept a one dimensional integer array NUMBERS
and its size N. The function should rearrange the array in such a way that the values of alternate
locations of the array are exchanged (Assume the size of the array to be even)
Example:
If the array initially contains 2, 5, 9, 14, 17, 8, 19, 16
Then after rearrangement the array should contain 5, 2, 14, 9, 8, 17, 16, 19
(iv) Write a function in C++ to merge the contents of two sorted arrays A and B into a third array C.
Assuming array A is sorted in ascending order, B is sorted in descending order, the resultant array is
required to be in ascending order.
(v) Write a function in C++ to combine the contents of two equi-sized arrays A and B by computing their
corresponding elements with formula 2*A[i]+3*B[i]; where value I varies from 0 to N-1 and transfer the
resultant content in the third same sized array namely C.
(vi) Write a function reassign() in C++, which accepts an array of integers and its size as parameters ad
divide all those elements by 5 which are divisible by 5 and multiply the other array elements by 2.
(vii) Write a function get1() in C++ to transfer the content of 2 arrays first[] and second[] to array ALL[].
The even places in ALL[] should be filled from array first[] and odd places of ALL[] will be filled from
array second[].
Example:
If first[] is 1,2,3,4,5,6 and second[] is 10, 20, 30, 40
The resultant ALL[] is: 10, 1,20, 2, 30, 3, 40, 4, 5, 6 (CBSE 2011)
(viii) Write a function in C++, which accepts an array of integers and its size as parameters and replaces
elements having even values with its half and elements having odd values with twice its value.
Assignment/XII/083/Final Revision/YK
32 ( © Yogesh Kumar)
Example.
if array has : 3, 4, 5, 16, 9, then output : 6, 2, 10, 8, 18
(ix) Write code for a function void Convert(int t[], int Num) in C++, which re-positions all the
elements of the array by shifting each of them one to one position before and by shifting the first
element to the last position. (CBSE 2013)
For example: If the content of the array is
0 1 2 3 4
22 25 70 32 12
The changed content will be:
0 1 2 3 4
25 70 32 12 22
(x) Write a function SWAP2CHANGE(int P[], int N) in C++ to modify the content of the array in such
a way that the elements, which are multiples of 10 swap with the value present in the very next
position in the array. (CBSE 2012)
For example:
If the content of array P is: 91, 50, 54, 22, 30, 54
Then content of array P should become: 91, 54, 50, 22, 54, 30
(xi) Write code for a function void OddEven(int s[], int N) in C++, to add 5 in all the odd values
and 10 in all the even values of the array S. (CBSE 2014)
For example: If the original content of the array S is
S[0] S[1] S[2] S[3] S[4]
50 11 19 24 18
The modified content will be:
S[0] S[1] S[2] S[3] S[4]
60 16 24 34 28
(xii) Write the definition of a function Alter(int A[], int N) in C++, which should change all the multiples of 5
in the array to 5 and rest of the elements as 0. For example, if an array of 10 integers is as follows:
(CBSE-Delhi 2015)
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9]
55 43 20 16 39 90 83 40 48 25
After executing the function, the array content should be changed as follows:
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9]
5 0 5 0 0 5 0 5 0 5
(xiii) Write the definition of a function Change(int P[], int N) in C++, which should change all the multiples
of 10 in the array to 10 and rest of the elements as 1. For example, if an array of 10 integers is as
follows: (CBSE-Outside Delhi 2015)
After executing the function, the array content should be changed as follows:
Assignment/XII/083/Final Revision/YK
33 ( © Yogesh Kumar)
9. Functions on 2D Arrays (i) Write a function in C++ to find sum of rows from a two-dimensional array.
(ii) Write a function in C++ to find the sum of both left and right diagonal elements from a two-dimensional
array (matrix).
(iii) Write a function in C++ to find and display the sum of each row and each column of a two-dimensional
array of type float. Use the array and its size as parameters with float as its return type.
(iv) Write a function in C++ to print the sum of all the values which are either divisible by 3 or are divisible by
5 present in a two dimensional array passed as the argument to the function.
(v) Write a function in C++ which accepts an integer array and its size as arguments/parameters and assigns
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, 3
The resultant 2-D array is: The resultant 2-D array:
1 2 3 4 5 6 1 2 3
1 2 3 4 5 0 1 2 0
1 2 3 4 0 0 1 0 0
1 2 3 0 0 0
1 2 0 0 0 0
1 0 0 0 0 0
(vi) Write a function int altersum(int b[][5],int n, int m) in C++ to find and return the sum of elements from
all alternate elements of a 2D array starting from b[0][0]. Example: If the 2d array contains
b[0][0]
4
b[0][1]
5
b[0][2]
1
b[1][0]
2
b[1][1]
8
b[1][2]
7
b[2][0]
9
b[2][1]
6
b[2][2]
3
The function should add b[0][0], b[0][2], b[1][1], b[2][0], b[2][2]
(vii) Write a function in C++ to print the product of each row of a 2D array of integers passed as argument to
the function. Example:
if the 2d array contains
20 40 10
40 50 30
60 30 20
40 20 30
Then the output should appear as:
product of row1=8000
product of row2=60000
product of row3=36000
product of row4=24000
Assignment/XII/083/Final Revision/YK
34 ( © Yogesh Kumar)
(viii) Write a function in C++ which accepts a 2D array of integers and its size of arguments and display the
elements of the middle row and middle column. (Assuming that it is a square matrix). Example:
if the 2d array contains
3 5 4
7 6 9
2 1 8
Then the output should appear as:
Middle row: 7 6 9
Midle column: 5 6 1
(ix) Write a function in C++ which accepts a 2D array of integers and its size of arguments and swaps the
elements of the first column with the last column. Example:
if the 2d array contains
3 5 4
7 6 9
2 1 8
Then the output should appear as:
4 5 3
9 6 7
8 1 2
(x) Write a function in C++ which accepts a 2D array of integers and its size of arguments and swaps the
elements of the first row with the last row. Example: if the 2d array contains
3 5 4
7 6 9
2 1 8
Then the output should appear as:
2 1 8
7 6 9
3 5 4
(xi) Write a COLSUM() function in C++ to find the sum of each column of a NxM matrix. (CBSE 2011)
(xii) Write a function SKIPEACH(int H[][3], int C, int R) in C++ to display all alternate elements from two
dimensional array H (Starting from H[0][0]). (CBSE 2012)
For example: if the array is containing
12 45 67
33 90 76
21 43 59
Then the output will be: 12 67 90 21 59
(xiii) Write a user defined function DisTen(int L[][4], int R, int C) in c++ to find and display all the numbers,
which are not divisible by 10. (CBSE 2013)
For example: if the array contents are:
20 17 30
12 19 10
The output should be: 17 12 19
(xiv) Write a user defined function SumLast3(int A[][4], int N, int M) in c++ to find and display the sum of all
the values , which are ending with 3 (i.e., units place is 3). (CBSE 2014)
For example: if the array content is:
33 13 92
99 3 12
The output should be: 49
Assignment/XII/083/Final Revision/YK
35 ( © Yogesh Kumar)
(xv) Write a function REVCOL (int P[] [5], int N, int M) in C++ to display the content of a two dimensional array, with each column content in reverse order. Note : Array may contain any number of rows. For example, if the content of array is as follows: (CBSE 2015)
15 12 56 45 51
13 91 92 87 63
11 23 61 46 81
The function should display output as:
11 23 61 46 81 13 91 92 87 63 15 12 56 45 51
(xvi) Write a function REVROW(int P[][5],int N, int M) in C++ to display the content of a two dimensional array, with each row content in reverse order. (CBSE-Outside Delhi 2015) For example, if the content of array is as follows:
The function should display output as: 51 45 56 12 15 63 87 92 91 13 81 46 61 23 81
10. Address Calculation (i) 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 the array is stored
(i) Row wise, (ii) Column wise
(ii) An array S[40][30] is stored in the memory along the row with each of the elements occupying 2 bytes.
Find out the location for the element S[15][5], if an element S[20][10] is stored at the memory
location 5500.
(iii) An array Arr[35][15] is stored in the memory along the row with each of the elements occupying 4
bytes. Find out the base address and the address of an element Arr[20][5], if the location Arr[2][2] is
stored at the address 3000.
(iv) An array P[20][30] is stored in the memory along the column with each of the elements occupying 4
bytes. Find out the memory location for the element P[5][15], if an element P[2][20] is stored at the
memory location 5000.
(v) An array P[-2..5][3.7] is stored in the memory along the column with each of the elements occupying 4
bytes. Find out the memory location for the element P[2][3], if first element is stored at the memory
location 100.
(vi) An array P[20][50] is stored in the memory along the column with each of its element occupying 4
bytes, find out the location of P[5][10], if P[0][0] is stored at 5200. (CBSE 2011)
(vii) An array S[10][30] is stored in the memory along the column with each of its element occupying 2
bytes. Find out the memory location of S[5][10], if the element S[2][15] is stored at location 8200.
(CBSE 2012)
(viii) An array P[15][10] is stored along the column in memory with each element requiring 4 bytes of
storage. If the base address of the array P is 14000, find out the location of P[8][5].
(CBSE 2013)
(ix) An array P[25][20] is stored along the row in memory with each element requiring 2 bytes of storage. If
Assignment/XII/083/Final Revision/YK
36 ( © Yogesh Kumar)
the base address of the array T is 42000, find out the location of T[10][15]. Also find the total number
of elements present in this array. (CBSE 2014)
(x) A two dimensional array P[20] [50] is stored in the memory along the row with each of its element
occupying 4 bytes, find the address of the element P[10] [30], if the element P[5] [5] is stored at the
memory location 15000. (CBSE-Delhi 2015)
(xi) A two dimensional array ARR[50][20] is stored in the memory along the row with each of its elements occupying 4 bytes. Find the address of the element ARR[30][10], if the element ARR[10] [5] is stored at the memory location 15000. (CBSE-Outside Delhi 2015)
11. Sorting
(i)
Assume an array E containing elements of structure employee is required to be arranged in
descending order of salary. Write a C++ function to arrange the same with the help of selection sort,
the array and its size is required to be passed as parameters to the function. Definition of structure
Employee is as follows:
struct Employee
int eno;
char name[25];
float salary;
;
(ii) Assume an array S containing elements of structure Student is required to be arranged in descending
order of Marks. Write a C++ function to arrange the same with the help of Bubble sort, the array and
its size is required to be passed as parameters to the function. Definition of structure Student is:
struct Student
int rno;
char name[25];
float Marks;
;
(iii) Write a function to sort an array of integers in ascending order using insertion sort. The array and its
size is required to be passed as parameters to the function.
(iv)
Considering the following key set : 42,29,74,11,65,58 use
(i) selection sort
(ii) Bubble sort
(iii) insertion sort
to sort the data in ascending order and indicate the sequences of steps required in each case.
12. Merging
(i)
Suppose A,B,C are arrays of integers of size M,N and M+N respectively. The numbers in array A appear in
ascending order while the numbers in array B appear in descending order. Write a user defined function
in C++ to produce the third array C by merging arrays A and B in ascending order. Use A,B and C as
arguments in the function.
(ii)
Given two arrays of integers A and B of sizes M and N respectively. Write a function named MIX() which
will produce a third array named C, such that the following sequence is followed:
i. All the even numbers of A from left to right are copied into C from left to right
ii. All the odd numbers of A from left to right are copied into C from right to left
iii. All the even numbers of B from left to right are copied into C from left to right
iv. All the odd numbers of B from left to right are copied into C from right to left
A, B and C are passed as arguments to MIX(). Eg.: A is 3,2,1,7,6,3 and B is 9,3,5,6,2,8,10, the
Assignment/XII/083/Final Revision/YK
37 ( © Yogesh Kumar)
resultant array C is 2,6,6,2,8,10,5,3,9,3,7,1,3
(iii)
Suppose A,B,C are arrays of integers of size M,N and M+N respectively. The numbers in arrays A and B
appear in descending order. Write a user defined function in C++ to produce the third array C by merging
arrays A and B in ascending order. If an element appears in both the arrays A and B, it should appear only
once in C. Use A,B and C as arguments in the function.
13. Stacks
(i) class stack
int data[10];
int top;
public:
stack() top = -1;
void push(int item); // to push an element into the stack
void pop(int &item); // to pop an element from the stack
void Delete(int ITEM); //to delete all elements which are equal to
ITEM
void Display();
;
Complete the class with all function definitions. Use another stack to transfer data temporarily.
(ii) Write a function in C++ to perform PUSH operation in a dynamically allocated stack considering
the following:
struct Node
int X, Y; Node * Link;
;
class STACK
Node *Top;
public:
STACK() Top = NULL;
void PUSH();
void POP();
~STACK();
;
(iii) Write functions stackpush() to insert nodes and stackpop() to delete nodes, for a linked list
implemented stack having the following structure for each node:
struct node
char name[20]; int age;
node * Link;
;
class stack
node *top;
public:
stack() top = NULL;
void stackpush();
void stackpop();
;
(iv) Write a function POPBOOK() in C++ to perform delete operation from a dynamic stack, which
contains Bno and Title. Consider the following definition of NODE while writing your C++ code.
(CBSE 2014)
struct NODE
Assignment/XII/083/Final Revision/YK
38 ( © Yogesh Kumar)
int Bno;
char Title[20];
NODE * Link;
;
(v) Write the definition of a member function Pop() in C++, to delete a book from a dynamic stack of TEXTBOOKS considering the following code is already included in the program. (CBSE-Delhi 2015)
struct TEXTBOOKS
char ISBN[20]; char TITLE[80];
TEXTBOOKS *Link;
;
class STACK
TEXTBOOKS *Top;
public:
STACK()Top=NULL;
void Push();
void Pop();
~STACK();
;
(vi) Write the definition of a member function PUSH() in C++, to add a new book in a dynamic stack of BOOKS considering the following code is already included in the program:
(CBSE-Outside Delhi 2015) struct BOOKS
char ISBN[20], TITLE[80];
BOOKS *Link;
;
class STACK
BOOKS *Top;
public:
STACK()
Top=NULL;
void PUSH();
void POP();
~STACK();
;
14. Infix to Postfix expression Obtain the postfix notation for each of the following infix notation of expression showing the contents of the
stack and postfix expression after each step of conversion:
(i) A*B+(C-D/F)
(ii) (A+B)*C+D/E-F
(iii) A+B+C-D*E/F
(iv) A*(B*C*(D/E-F))
(v) A AND B AND (C OR NOT D) AND E
(vi) X / Y + U* (V–W) (CBSE-Delhi 2015)
(vii) U * V + R/ (S - T) (CBSE-Outside Delhi 2015)
15. Evaluation of Postfix expression
(i) Evaluate: 10 20 + 25 15 - * 30 /
Assignment/XII/083/Final Revision/YK
39 ( © Yogesh Kumar)
(ii) Write the corresponding infix expression for 10, 3, *, 7, 1, -, *, 23, +
(iii) Evaluate the following postfix notation of expression, show status of the stack for each operation:
500, 20, 30, +, 10, *, +
(iv) Evaluate: 20, 30, +, 50, 40, -, *
(v) Evaluate: True, False, AND, True, True, NOT, OR, AND
(vi) Evaluate the following postfix notation of expression: 50, 60, +, 20, 10, -, * (CBSE 2011)
(vii) Evaluate the following POSTFIX notation. Show status of stack after every step of evaluation (i.e.,
after each operator): (CBSE 2012)
False, NOT, True, AND, true, False, OR, AND
(viii) Evaluate the following postfix expression. Show the status of stack after execution of each
operation: 60, 6, /, 5, 2, *, 5, -, +* (CBSE 2013)
(ix) Evaluate the following postfix expression. Show the status of stack after execution of each
operation separately: (CBSE 2014)
F, T, NOT, AND, F, OR, T, AND
16. Queues (i)
Write a function in C++ to perform DELETE operation in a dynamically allocated queue considering the
following:
struct Node
float U, V;
Node * Link;
;
class QUEUE
Node *Rear, *Front;
public:
QUEUE() Rear = NULL; Front = NULL;
void INSERT();
void DELETE();
~QUEUE();
;
(iii)
Write member functions queins() to insert nodes and quedel() to delete nodes of a linked list
implemented class queue, where each node has the following structure:
struct node
char name[20];
int age;
node * Link;
;
class queue
node *rear, *front;
public:
queue() rear = NULL; front = NULL;
void queins();
void quedel();
;
(iv)
class queue
int data[10];
int front, rear;
public:
queue() front = rear = -1;
void insertq(); // to insert an element into the queue
Assignment/XII/083/Final Revision/YK
40 ( © Yogesh Kumar)
void deleteq(); // to delete an element from the queue
void Remove(int ITEM); //to delete all elements which are equal to ITEM
;
Complete the class with all function definitions. Use another queue to transfer data temporarily.
Write a function in C++ to perform Insert operation on a dynamically allocated Queue containing
Passenger details as given in the following definition of NODE. (CBSE 2011)
struct NODE
long Pno; //Passenger Number
char PName[20]; //Passenger Name
NODE *Link;
;
Write a function in C++ to perform Insert operation on a Dynamic Queue containing DVD’s information
(represented with the help of an array of structure DVD) (CBSE 2012)
struct DVD
long No; //DVD Number
char Title[20]; //DVD Title
DVD *Link;
;
Write a function QINSERT() in C++ to perform insert operation on a Linked Queue, which contains Client
no and Client name. Consider the following definition of NODE in the code of QINSERT(). (CBSE 2013)
struct NODE
long int Cno; //Client no
char Cname[20]; //Client name
NODE * Next;
;
17. Text File Operations (i) void main()
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”? (Note that
“ “ are not the part of the string)
(ii) Write a function to count the number of blanks present in a text file named “PARA.TXT”.
(iii) Assuming that a text file named TEXT1.TXT already contains some text written into it, write a function
named vowelwords(), that reads the file TEXT1.TXT and creates a new file named TEXT2.TXT, which shall
contain only those words from the file TEXT1.TXT which don’t start with an uppercase vowel (i.e., with
‘A’, ‘E’, ‘I’, ‘O’, ‘U’). For example, if the file TEXT1.TXT contains
Carry Umbrella and Overcoat When it rains
Then the text file TEXT2.TXT shall contain
Carry When
(iv) Write a function in C++ to count the number of lines ending with a vowel from a text file “STORY.TXT’.
(v) Write a function in C++ to count and display the number of words starting with alphabet ‘A’ or ‘a’ present
in a text file “LINES.TXT”.
Example:
If the file “LINES.TXT” contains the following lines,
Assignment/XII/083/Final Revision/YK
41 ( © Yogesh Kumar)
A boy is playing there.
There is a playground.
An aeroplane is in the sky.
Are you getting it?
The function should display the output as 5.
(vi) Write a function in C++ to display the last 3 characters of a text file “STORY.TXT’.
(vii) Write a function copy() that will copy all the words starting with an uppercase from an existing file
“FAIPS.TXT” to a new file “DPS.TXT”.
(viii) Write a function show (int n) that will display the nth character from the existing file “MIRA.TXT”. If the
total characters present are less than n, then it should display “invalid n”.
(ix) Write a function in C++ that counts the number of “Me” or “My” words present in a text file “DIARY.TXT”.
If the “DIARY.TXT” contents are as follows:
My first book was Me and My
Family. It gave me chance to be
Known to the world.
The output of the function should be:
Count of Me/My in file: 4 (CBSE 2011)
(x) Write a function in C++ to read the contents of a text file “Places.Txt” and display all those lines on
screen which are either starting with ‘P’ or with ‘S’. (CBSE 2013)
(xi) Write a function CountHisHer() in C++ which reads the contents of a text file “Equality.txt” which counts
the words His and Her (not case sensitive) present in the file.
For, example, if the file contains:
Pankaj has gone to his friend’s house. His frien’s name is Ravya. Her
house is 12KM from here.
The function should display the output:
Count of His: 2
Count of Her: 1 (CBSE 2012)
(xii) Write a function EUCount() in C++, which should read each character of a text file IMP.TXT, should count
and display the occurance of alphabets E and U (including small cases e and u too).
Example:
If the file content is as follows:
Updated information
Is simplified by official websites.
The EUCount() function should display the output as:
E:4
U:1 (CBSE 2014)
(xiii) Write function definition for SUCCESS( ) in C++ to read the content of a text file STORY.TXT, count the presence of word STORY and display the number of occurrence of this word. Note : – The word STORY should be an independent word – Ignore type cases (i.e. lower/upper case) Example : If the content of the file STORY.TXT is as follows :
The function SUCCESS( ) should display the following :
Success shows others that we can do it. It is
possible to achieve success with hard work. Lot of
money does not mean SUCCESS.
3
Assignment/XII/083/Final Revision/YK
42 ( © Yogesh Kumar)
(CBSE- Delhi 2015)
(xiv) Write function definition for TOWER() in C++ to read the content of a text file WRITEUP.TXT, count the presence of word TOWER and display the number of occurrences of this word. Note : ‐ The word TOWER should be an independent word ‐ Ignore type cases (i.e. lower/upper case) Example: If the content of the file WRITEUP.TXT is as follows:
The function TOWER () should display the following:
(CBSE-Outside Delhi 2015)
18. Binary File Operations (i) Following is the structure of each record in a data file named ”PRODUCT.DAT”.
struct product
char product_code[10];
char product_description[10];
int stock;
;
Write a function in C++ to update the file with a new value of stock. The stock and the
product_code, whose stock is to be updated, are read during the execution of the program.
(ii) Given a binary file “STUDENT.DAT”, containing records of the following class Student type:
class student
char S_admno[10]; //Admission no. of student
char S_Name[20]; //Name of student
int Percentage; //Marks percentage of student
public:
void EnterData()
gets(S_admno); gets(S_Name); cin>>Percentage;
void DisplayData()
cout<<setw(12)<<S_admno;
cout<<setw(32)<<S_Name;
cout<<setw(3)<<Percentage<<endl;
int ReturnPercentage() return Percentage;
;
Write a function in C++ that would read contents of the file “STUDENT.DAT” and display the details
of those students whose percentage is above 75.
(iii) Assuming the class Vehicle as follows:
class vehicle
char vehicletype[10];
int no_of_wheels;
public:
Tower of hanoi is an interesting problem.
Mobile phone tower is away from here. Views
from EIFFEL TOWER are amazing.
3
Assignment/XII/083/Final Revision/YK
43 ( © Yogesh Kumar)
void getdetails()
gets(vehicletype);
cin>>no_of_wheels;
void showdetails()
cout<<"Vehicle Type: "<<vehicletype;
cout<<"Number of wheels="<<no_of_wheels;
;
Write a function showfile() to read all the records present in an already existing binary file
SPEED.DAT and display them on the screen, also count the number of records present in the file.
(iv) 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 BookNo;
char Book_name[20];
public:
// function to enter book details
void enterdetails();
//function to display Book details
void showdetails();
//function to return Book_no
int Rbook_no() return Book_no;
;
(v) Observe the program segment given below carefully, and fill the blanks marked as Statement 1 and
Statement 2 using seekg(), seekp(), tellg(), and tellp() functions for performing the required task:
(CBSE 2011)
#include <fstream.h>
class PRODUCT
int Pno; char Pname[20]; int Qty;
public:
.
.
Void ModifyQty(); //Function is to modify quantity of a PRODUCT
;
void PRODUCT::ModifyQty ()
fstream File;
File.open("PRODUCT.DAT", ios::binary|ios::in|ios::out);
int MPno;
cout<<"Product No to modify quantity: "; cin>>MPno;
while (File.read((char*)this, sizeof(PRODUCT)))
if (MPno == Pno)
cout<<"Present Quantity:"<<Qty<<endl;
cout<<"Changed Quantity: "; cin>>Qty;
int Position=_________ ; // Statement 1
____________________; //Statement 2
File.write((char*)this, sizeof(PRODUCT)); //Rewrite
record
Assignment/XII/083/Final Revision/YK
44 ( © Yogesh Kumar)
File.close();
(vi) Fill in the blanks marked as Statement 1 and Statement 2, in the program segment given below with
appropriate functions for the required task. (CBSE 2013)
class Customer
long int Cno; // Customer Number
char CName[20]; //Customer Name
char Email[30]; //Email of customer
public:
void Allocate(); //Function to allocate a member
void Show(); //Function to show customer data
void ModifyEmail() //Function to modify Email
cout<<”Enter Modified Email: “;
Gets(Email);
Long int GetCno() return Cno;
;
void ChangeData()
fstream File;
File.open("CUST.DAT", ios::binary|ios::in|ios::out);
int Change = 0, Location;
long int ChangeCno;
cout<<"Cno – whose email required to be modified: ";
cin>>ChangeCno;
Customer CU;
while (!Modify && File.read((char*)&CU, sizeof(CU)))
if (CU.GetCno()==ChangeCno)
Location=File.tellg()-sizeof(CU);
//Statement 1: To place file pointer to the required
position
_________;
//Statement 2: To write the object CU on to the binary
file.
_________;
Change++;
if (Change)
cout<<"Email Modified"<<endl;
else
cout<<"Customer not found"<<endl;
File.close();
(vii) Observe the program segment given below carefully, and answer the questions that follow:
(CBSE 2012)
class Inventory
int Ano, Qty; char Article[20];
public:
void input() cin>>Ano; gets(Article); cin>>Qty;
Assignment/XII/083/Final Revision/YK
45 ( © Yogesh Kumar)
void issue(int Q) Qty += Q;
void Procure(int Q) Qty -= Q;
int GetAno() return Ano;
;
void ProcureArticle (int TAno, int TQty)
fstream File;
File.open("STOCK.DAT", ios::binary|ios::in|ios::out);
Inventory I;
int found = 0;
while (Found==0 && File.read((char*)&I, sizeof(I)))
if (TAno==S.GetAno()))
I.Procure(TQty);
_________ // Statement 1
_________ // Statement 2
Found++;
if (Found == 1)
cout<<"Procurement Updated"<<endl;
else
cout<<"Wrong Article No"<<endl;
File.close();
(i) Write statement 1 to position the file pointer to the appropriate place, so that the data
updation is done for the required Article.
(ii) Write statement 2 to perform the write operation so that the updation is done in the binary
file.
(viii) Fill in the blanks marked as Statement 1 and Statement 2, in the program segment given below with
appropriate functions for the required task. (CBSE 2014)
class Medical
int Rno; // Representative Code
char Name[20]; // Representative Name
char Mobile[12]; // Representative Mobile
public:
void Input(); //Function to enter all details
void Show(); //Function to display all details
void ChangeMobile() //Function to change Mobile
cout<<”Changed Mobile: “; Gets(Mobile);
int RRno() return RNo;
;
void RepUpdate()
fstream F;
F.open("REP.DAT", ios::binary|ios::in|ios::out);
int Change = 0, URno;
cout<<"Rno (Rep No – to update Mobile):";
cin>>URno;
Medical M;
while (!Change && F.read((char*)&M, sizeof(M)))
Assignment/XII/083/Final Revision/YK
46 ( © Yogesh Kumar)
if (M.RRno() == URno)
//Statement 1: To call the function to change Mobile No.
_________;
//Statement 2: To reposition file pointer to re-write the
//updated object back in the file.
_________;
F.write((char*)&M, sizeof(M0);
Change++;++;
if (Change)
cout<<"Mobile changed for Rep "<<URno<<endl;
else
cout<<"Rep not in the Medical"<<endl;
File.close();
(ix) Observe the program segment given below carefully, and answer the questions that follow:
class Book
int Book_no;
char Book_name[20];
public:
// function to enter book details
void enterdetails();
//function to display Book details
void showdetails();
//function to return Book_no
int Rbook_no() return Book_no;
;
void modify (Book NEW)
fstream File;
File.open("Book.dat", ios::binary|ios::in|ios::out);
Book OB;
int recordsread = 0, found = 0;
while (!Found && File.read((char*)&OB, sizeof(OB)))
recordsread++;
if (NEW.RBook_no() == OB.RBook_no())
_________ // Missing Statement
File.write((char*)&NEW, sizeof(NEW));
Found = 1;
else
File.write((char*)&OB, sizeof(OB));
if (_______) //Missing Expression
cout<<"Record for modification does not exist";
File.close();
Assignment/XII/083/Final Revision/YK
47 ( © Yogesh Kumar)
If the function Modify() is supposed to modify a record in the file BOOK.DAT with the values of Book
NEW passed to its argument, write the appropriate statement for missing statement using seekp()
or seekg(), whichever needed, in the above code that would write the modified record at its proper
place. Also write the Missing Expression.
(x) Assuming the class VINTAGE as declared below, write a function in C++ to read the objects of
VINTAGE from binary file VINTAGE.DAT and display those vintage vehicles, which are priced
between 200000 and 2500000.
class VINTAGE
int VNO; Vehicle Number
char VDesc[10];
float price;
public:
void GET() cin>>VNO; gets(VDesc); cin>>price;
void VIEW()
cout<<VNO<<endl;
cout<<VDesc<<endl;
cout<<price<<endl;
float ReturnPrice() return price;
; (CBSE 2012)
(xi) Write a function in C++ to search for a laptop from a binary file “LAPTOP.DAT” containing the
objects of the class LAPTOP (as defined below). The user should enter the model number and the
function should display the details of the laptop.
class LAPTOP
long ModelNo;
float RAM, HDD;
char Details[120];
public:
void StockEnter() cin>>ModelNo>>RAM>>HDD; gets(Details);
void StockDisplay() cout<<ModelNo<<RAM<<HDD<<Details<<endl;
long ReturnModelNo() return ModelNo;
; (CBSE 2011)
(xii) Write a function in C++ to search for the details (Number and Calls) of those mobile phones which
have more than 1000 calls from a binary file “mobile.dat”. Assuming that this binary file contains
records/objects of class Mobile, which is defined below:
class Mobile
char Number[10]; int calls;
public:
void Enter() gets(Number); cin>>calls;
void Billing() cout<<Number<<'#'<<calls<<endl;
int GetCalls() return calls;
; (CBSE 2013)
(xiii) Assuming the class GAMES as declared below, write a function in C++ to read the objects of GAMES
from binary file GAMES.DAT and display the details of those games, which are meant for children of
AgeRange “8 to 13”.
class GAMES
int GameCode;
char GameName[10];
char AgeRange;
public:
Assignment/XII/083/Final Revision/YK
48 ( © Yogesh Kumar)
void Enter()
cin>>GameCode;
gets(GameName);
gets(AgeRange);
void Display()
cout<<GameCode<<":"<<GameName<<endl;
cout<<AgeRange<<endl;
char *AgeR() return AgeRange;
; (CBSE 2014)
(xiv) Write a definition for function Economic ( ) in C++ to read each record of a binary file ITEMS.DAT, find and display those items, which costs less than 2500. Assume that the file ITEMS.DAT is created
with the help of objects of class ITEMS, which is defined below: (CBSE-Delhi 2015) class ITEMS
int ID;char GIFT[20]; float Cost;
public :
void Get()
cin>>CODE;gets(GIFT);cin>>Cost;
void See()
cout<<ID<<”:”<<GIFT<<”:”<<Cost<<end1;
float GetCost()return Cost;.
;
(xv) Find the output of the following C++ code considering that the binary file CLIENTS.DAT exists on the
hard disk with records of 100 members. (CBSE-Delhi 2015) class CLIENTS
int Cno;char Name[20];
public :
void In(); void Out();
;
void main()
fstream CF;
CF.open(“CLIENTS.DAT”,ios::binary|ios::in);
CLIENTS C;
CF.read((char*) &C, sizeof(C));
CF.read((char*) &C, sizeof(C));
CF.read((char*) &C, sizeof(C));
int POS=CF.tellg()/sizeof(C);
cout<<”PRESENT RECORD:”<<POS<<end1;
CF.close();
(xvi) Write a definition for function COSTLY() in C++ to read each record of a binary file GIFTS.DAT, find and display those items, which are priced more that 2000. Assume that the file GIFTS.DAT is created with the help of objects of class GIFTS, which is defined below: (CBSE-Outside Delhi 2015)
class GIFTS
Assignment/XII/083/Final Revision/YK
49 ( © Yogesh Kumar)
int CODE;char ITEM[20]; float PRICE;
public:
void Procure()
cin>>CODE; gets(ITEM);cin>>PRICE;
void View()
cout<<CODE<<":"<<ITEM<<":"<<PRICE<<endl;
float GetPrice() return PRICE;
;
(xvii) Find the output of the following C++ code considering that the binary file MEMBER.DAT exists on the hard disk with records of 100 members: (CBSE-Outside Delhi 2015)
class MEMBER
int Mno; char Name[20];
public:
void In();void Out();
;
void main()
fstream MF;
MF.open("MEMBER.DAT”,ios::binary|ios::in);
MEMBER M;
MF.read((char*)&M,sizeof(M));
MF.read((char*)&M,sizeof(M));
MF.read((char*)&M,sizeof(M));
int POSITION=MF.tellg()/sizeof(M);
cout<<"PRESENT RECORD:"<<POSITION<<endl;
MF.close();
19. RDBMS – Descriptive Questions (i) What do you understand by Union & Cartesian Product operations in relational algebra? (CBSE 2011)
(ii) Give a suitable example of a table with sample data and illustrate Primary and Candidate keys in it.
(CBSE 2012)
(iii) What is the difference between degree and cardinality of a table? What is the degree and cardinality of
the following table: (CBSE 2013)
ENo Name Salary
101 John Fedrick 45000
103 Raya Mazumdar 50600
(iv) Explain the concept of Union between two tables, with the help of an appropriate example.
(CBSE 2014)
(v) Give a suitable example of a table with sample data and illustrate Primary and Alternate keys in it.
(vi) Observe the following table carefully and write the names of the most appropriate columns, which can be considered as (i) candidate keys and (ii) primary key. (CBSE-Delhi 2015)
Id Product Qty Price Transaction Date
101 Plastic Folder 12" 100 3400 2014-12-14
104 Pen Stand Standard 200 4500 2015-01-31
105 Stapler Medium 250 1200 2015-02-28
109 Punching Machine Big 200 1400 2015-03-12
103 Stapler Mini 100 1500 2015-02-02
(vii) Observe the following table carefully and write the names of the most appropriate columns, which can be considered as (i) candidate keys and (ii) primary key. (CBSE-Outside Delhi 2015)
Assignment/XII/083/Final Revision/YK
50 ( © Yogesh Kumar)
Code Item Qty Price Transaction Date
1001 Plastic Folder 14” 100 3400 2014‐12‐14
1004 Pen Stand Standard 200 4500 2015‐01‐31
1005 Stapler Mini 250 1200 2015‐02‐28
1009 Punching Machine Small 200 1400 2015‐03‐12
1003 Stapler Big 100 1500 2015‐02‐02
20. SQL – Writing queries and finding outputs (i) Write SQL commands for the following queries based on the relation Teacher given below:
Table : Teacher
No Name Age Department Date_of_join Salary Sex
1 Jugal 34 Computer 10/01/97 12000 M
2 Sharmila 31 History 24/03/98 20000 F
3 Sandeep 32 Maths 12/12/96 30000 M
4 Sangeeta 35 History 01/07/99 40000 F
5 Rakesh 42 Maths 05/09/97 25000 M
6 Shyam 50 History 27/06/98 30000 M
7 Shiv Om 44 Computer 25/02/97 21000 M
8 Shalakha 33 Maths 31/07/97 20000 F
a) To show all information about the teacher of History department.
b) To list the names of female teachers who are in Maths department.
c) To list the names of all teachers with their date of joining in ascending order.
d) To display teacher’s name, salary, age for male teachers only.
e) To count the number of teachers with Age>23.
(ii)
Given the following relation: STUDENT
No. Name Age Department Dateofadm Fee Sex
1 Pankaj 24 Computer 10/01/97 120 M
2 Shalini 21 History 24/03/98 200 F
3 Sanjay 22 Hindi 12/12/96 300 M
4 Sudha 25 History 01/07/99 400 F
5 Rakesh 22 Hindi 05/09/97 250 M
6 Shakeel 30 History 27/06/98 300 M
7 Surya 34 Computer 25/02/97 210 M
8 Shikha 23 Hindi 31/07/97 200 F
Write SQL commands for the following queries
a) To show all information about the students of History department.
b) To list the names of female students who are in Hindi department.
c) To list the names of all students with their date of admission in ascending order.
d) To display student’s name, fee, age for male students only.
e) To count the number of students with Age>23.
Assignment/XII/083/Final Revision/YK
51 ( © Yogesh Kumar)
(iii)
Write SQL commands for the following queries on the basis of Club relation given below:
Table : Club
Coach-ID CoachName Age Sports date_of_app Pay Sex
1 Kukreja 35 Karate 27/03/1996 1000 M
2 Ravina 34 Karate 20/01/1998 1200 F
3 Karan 34 Squash 19/02/1998 2000 M
4 Tarun 33 Basketball 01/01/1998 1500 M
5 Zubin 36 Swimming 12/01/1998 750 M
6 Ketaki 36 Swimming 24/02/1998 800 F
7 Ankita 39 Squash 20/02/1998 2200 F
8 Zareen 37 Karate 22/02/1998 1100 F
9 Kush 41 Swimming 13/01/1998 900 M
10 Shailya 37 Basketball 19/02/1998 1700 M
a) To show all information about the swimming coaches in the club.
b) To list the names of all coaches with their date of appointment (date_of_app) in descending order.
c) To display a report showing coach name, pay, age, and bonus (15% of pay) for all coaches.
d) To insert a new row in the Club table with ANY relevant data:
e) Give the output of the following SQL statements:
i. Select COUNT(Distinct Sports) from Club;
ii. Select Min(Age) from Club where SEX = “F”;
(iv)
Write SQL commands for (a) to (f) and write the outputs for (g) on the basis of tables FURNITURE and
ARRIVALS
FURNITURE
NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 White lotus Double Bed 23/02/02 30000 25
2 Pink feather Baby cot 20/01/02 7000 20
3 Dolphin Baby cot 19/02/02 9500 20
4 Decent Office Table 01/01/02 25000 30
5 Comfort zone Double Bed 12/01/02 25000 25
6 Donald Baby cot 24/02/02 6500 15
7 Royal Finish Office Table 20/02/02 18000 30
8 Royal tiger Sofa 22/02/02 31000 30
9 Econo sitting Sofa 13/12/01 9500 25
10 Eating Paradise Dining Table 19/02/02 11500 25
ARRIVALS
NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 Wood Comfort Double Bed 23/03/03 25000 25
2 Old Fox Sofa 20/02/03 17000 20
3 Micky Baby cot 21/02/03 7500 15
a) To show all information about the Baby cots from the FURNITURE table.
b) To list the ITEMNAME which are priced at more than 15000 from the FURNITURE table.
c) To list ITEMNAME and TYPE of those items, in which date of stock is before 22/01/02 from the
FURNITURE table in descending of ITEMNAME.
d) To display ITEMNAME and DATEOFSTOCK of those items, in which the discount percentage is more
than 25 from FURNITURE table.
e) To count the number of items, whose TYPE is "Sofa" from FURNITURE table.
Assignment/XII/083/Final Revision/YK
52 ( © Yogesh Kumar)
f) To insert a new row in the ARRIVALS table with the following data:
14,“Valvet touch”, "Double bed", 25/03/03, 25000,30
g) Give the output of following SQL stateme
Note: Outputs of the above mentioned queries should be based on original data given in both the
tables i.e., without considering the insertion done in (f) part of this question.
(i) Select COUNT(distinct TYPE) from FURNITURE;
(ii) Select MAX(DISCOUNT) from FURNITURE,ARRIVALS;
(iii) Select AVG(DISCOUNT) from FURNITURE where TYPE="Baby cot";
(iv) Select SUM(Price) from FURNITURE where DATEOFSTOCK<12/02/02;
(v)
Consider the following tables GAMES and PLAYER. Write SQL commands for the statements (a) to (d) and
give outputs for SQL queries (E1) to (E4)
GAMES
GCode GameName Number PrizeMoney ScheduleDate
101 Carom Board 2 5000 23-Jan-2004
102 Badminton 2 12000 12-Dec-2003
103 Table Tennis 4 8000 14-Feb-2004
105 Chess 2 9000 01-Jan-2004
108 Lawn Tennis 4 25000 19-Mar-2004
PLAYER
PCode Name Gcode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
(a) To display the name of all Games with their Gcodes
(b) To display details of those games which are having PrizeMoney more than 7000.
(c) To display the content of the GAMES table in ascending order of ScheduleDate.
(d) To display sum of PrizeMoney for each of the Number of participation groupings (as shown in column
Number)
(e1) SELECT COUNT(DISTINCT Number) FROM GAMES;
(e2) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;
(e3) SELECT SUM(PrizeMoney) FROM GAMES;
(e4) SELECT DISTINCT Gcode FROM PLAYER;
(vi) Consider the following tables WORKER and PAYLEVEL and answer (a) and (b) parts of this question:
(CBSE 2011)
WORKER
ECODE NAME DESIG PLEVEL DOJ DOB
11 Radhey Shyam Supervisor P001 13-Sep-2004 23-Aug-1981
12 Chander Nath Operator P003 22-Feb-2010 12-Jul-1987
13 Fizza Operator P003 14-June-2009 14-Oct-1983
15 Ameen Ahmed Mechanic P002 21-Aug-2006 13-Mar-1984
18 Sanya Clerk P002 19-Dec-2005 09-June-1983
PAYLEVEL
PAYLEVEL PAY ALLOWANCE
P001 26000 12000
P002 22000 10000
Assignment/XII/083/Final Revision/YK
53 ( © Yogesh Kumar)
P003 12000 6000
(a) Write SQL commands for the following statements:
(i) To display the details of all WORKERs in descending order of DOB.
(ii) To display NAME and DESIG of those WORKERs whose PLEVEL is either P001 or P002.
(iii) To display the content of all the WORKERs table, whose DOB is in between ’19-JAN-1984’ and ’18-
JAN-1987’.
(iv) To add a new row with the following:
19, ‘Daya kishore’, ‘Operator’, ‘P003’, ’19-Jun-2008’, ’11-Jul-1984’
(b) Give the output of the following SQL queries:
(i) SELECT COUNT(PLEVEL), PLEVEL FROM WORKER GROUP BY PLEVEL;
(ii) SELECT MAX(DOB), MIN(DOJ) FROM WORKER;
(iii) SELECT Name, Pay FROM WORKER W, PAYLEVEL P WHERE W.PLEVEL=P.PLEVEL AND W.ECODE<13;
(iv) SELECT PLEVEL, PAY+ALLOWANCE FROM PAYLEVEL WHERE PLEVEL=’P003’;
(vii) Consider the following tables CABHUB and CUSTOMER and answer (a) and (b) parts of this question:
(CBSE 2012)
CABHUB
Vcode VehicleName Make Color Capacity Charges
100 Innova Toyota WHITE 7 15
102 SX4 Suzuki BLUE 4 14
104 C Class Mercedes RED 4 35
105 A-Star Suzuki WHITE 3 14
108 Indigo Tata SILVER 3 12
CUSTOMER
CCode CName VCode
1 Hemant Sahu 101
2 Raj Lal 108
3 Feroza Shah 105
4 Ketan Dhal 104
(a) Write SQL commands for the following statements:
1) To display the names of all white colored vehicles
2) To display name of vehicle, make and capacity of vehicles in ascending order of their sitting
capacity
3) To display the highest charges at which a vehicle can be hired from CABHUB.
4) To display the customer name and the corresponding name of the vehicle hired by them.
(b) Give the output of the following SQL queries:
1) SELECT COUNT(DISTINCT Make) FROM CABHUB;
2) SELECT MAX(Charges), MIN(Charges) FROM CABHUB;
3) SELECT COUNT(*), Make FROM CABHUB;
4) SELECT VehicleName FROM CABHUB WHERE Capacity = 4;
(viii) Write SQL queries for (a) to (f) and write the outputs for the SQL queries mentioned shown in (g1) to (g4)
parts on the basis of tables ITEMS and TRADERS: (CBSE 2013)
ITEMS
CODE INAME QTY PRICE COMPANY TCODE
1001 DIGITAL PAD 12i 120 11000 XENITA T01
1006 LED SCREEN 40 70 38000 SANTORA T02
Assignment/XII/083/Final Revision/YK
54 ( © Yogesh Kumar)
1004 CAR GPS SYSTEM 50 21500 GEOKNOW T01
1003 DIGITAL CAMERA 12X 160 8000 DIGICLICK T02
1005 PEN DRIVE 32GB 600 1200 STOREHOME T03
TRADERS
TCode TName CITY
T01 ELECTRONIC SALES MUMBAI
T03 BUSY STORE CORP DELHI
T02 DISP HOUSE INC CHENNAI
a) To display the details of all the items in the ascending order of item names (i.e. INAME).
b) To display item name and price of all those items, whose price is in range of 10000 and 22000
(both values inclusive).
c) To display the number of items, which are traded by each trader. The expected output of this
query should be:
T01 2
T02 2
T03 1
d) To display the price, item name and quantity (i.e. qty) of those items which have quantity more
than 150.
e) To display the names of those traders, who are either from DELHI or from MUMBAI.
f) To display the names of the companies and the names of the items in descending order of
company names.
g1) SELECT MAX(PRICE), MIN(PRICE) FROM ITEMS;
g2) SELECT PRICE*QTY AMOUNT FROM ITEMS WHERE CODE-1004;
g3) SELECT DISTINCT TCODE FROM ITEMS;
g4) SELECT INAME, TNAME FROM ITEMS I, TRADERS T WHERE I.TCODE=T.TCODE AND QTY<100;
(ix) Answer the (a) and (b) on the basis of the following tables STORE and ITEM: (CBSE 2014)
STORE
SNo SName AREA
S01 ABC Computronics GK II
S02 All Infotech Media CP
S03 Tech Shoppe Nehru Place
S05 Hitech Tech Store SP
ITEM
INo IName Price SNo
T01 Mother Board 12000 S01
T02 Hard Disk 5000 S01
T03 Keyboard 500 S02
T04 Mouse 300 S01
T05 Mother Board 13000 S02
T06 Key Board 400 S03
T07 LCD 6000 S04
T08 LCD 5500 S05
T09 Mouse 350 S05
T10 Hard disk 4500 S03
(a) Write the SQL queries (1 to 4):
1) To display IName and Price of all the items in the ascending order of their Price.
2) To display the SNo and SName o all stores located in CP.
Assignment/XII/083/Final Revision/YK
55 ( © Yogesh Kumar)
3) To display the minimum and maximum price of each IName from the table Item.
4) To display the IName, price of all items and their respective SName where they are available.
(b) Write the output of the following SQL commands (1 to 4):
1) SELECT DISTINCT INAME FROM ITEM WHERE PRICE >= 5000;
2) SELECT AREA, COUNT(*) FROM STORE GROUP BY AREA;
3) SELECT COUNT(DISTINCT AREA) FROM STORE;
4) SELECT INAME, PRICE*0.05 DISCOUNT FROM ITEM WHERE SNO IN (‘S02’, ‘S03’);
(x) Consider the following DEPT and WORKER tables. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii): (CBSE-Delhi 2015) Table: DEPT
Table: WORKER
WNO NAME DOJ DOB GENDER DCODE
1001 George K 2013-09-02 1991-09-01 MALE D01
1002 Ryma Sen 2012-12-11 1990-12-15 FEMALE D03
1003 Mohitesh 2013-02-03 1987-09-04 MALE D05
1007 Anil Jha 2014-01-17 1984-10-19 MALE D04
1004 Manila Sahai 2012-12-09 1986-11-14 FEMALE D01
1005 R SAHAY 2013-11-18 1987-03-31 MALE D02
1006 Jaya Priya 2014-06-09 1985-06-23 FEMALE D05
Note: DOJ refers to date of joining and DOB refers to date of Birth of workers.
(i) To display Wno, Name, Gender from the table WORKER in descending order of Wno. (ii) To display the Name of all the FEMALE workers from the table WORKER. (iii) To display the Wno and Name of those workers from the table WORKER who are born between
‘1987-01-01’ and ‘1991-12-01’. (iv) To count and display MALE workers who have joined after ‘1986-01-01’. (v) SELECT COUNT(*), DCODE FROM WORKER GROUP BY DCODE HAVING COUNT(*)>1;
(vi) SELECT DISTINCT DEPARTMENT FROM DEPT; (vii) SELECT NAME, DEPARTMENT, CITY FROM WORKER W,DEPT D WHERE
W.DCODE=D.DCODE AND WNO<1003;
(viii) SELECT MAX(DOJ), MIN(DOB) FROM WORKER;
DCODE DEPARTMENT CITY
D01 MEDIA DELHI
D02 MARKETING DELHI
D03 INFRASTRUCTURE MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI
(xi) Consider the following DEPT and EMPLOYEE tables. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii). (CBSE-Outside Delhi 2015) Table: DEPT
DCODE DEPARTMENT LOCATION
D01 INFRASTRUCTURE DELHI
D02 MARKETING DELHI
D03 MEDIA MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI
Table: EMPLOYEE
Assignment/XII/083/Final Revision/YK
56 ( © Yogesh Kumar)
ENO NAME DOJ DOB GENDER DCODE
1001 George K 20130902 19910901 MALE D01
1002 Ryma Sen 20121211 19901215 FEMALE D03
1003 Mohitesh 20130203 19870904 MALE D05
1007 Anil Jha 20140117 19841019 MALE D04
1004 Manila Sahai 20121209 19861114 FEMALE D01
1005 R SAHAY 20131118 19870331 MALE D02
1006 Jaya Priya 20140609 19850623 FEMALE D05
Note: DOJ refers to date of joining and DOB refers to date of Birth of employees.
(i) To display Eno, Name, Gender from the table EMPLOYEE in ascending order of Eno. (ii) To display the Name of all the MALE employees from the table EMPLOYEE. (iii) To display the Eno and Name of those employees from the table EMPLOYEE who are born between
'1987‐01‐01' and '1991‐12‐01'. (iv) To count and display FEMALE employees who have joined after '1986‐01‐01'.
(v) SELECT COUNT(*),DCODE FROM EMPLOYEE
GROUP BY DCODE HAVING COUNT(*)>1;
(vi) SELECT DISTINCT DEPARTMENT FROM DEPT;
(vii) SELECT NAME, DEPARTMENT FROM EMPLOYEE E, DEPT
D WHERE E.DCODE=D.DCODE AND EN0<1003;
(viii) SELECT MAX(DOJ), MIN(DOB) FROM EMPLOYEE;
21. Postulates and theorems of Boolean algebra i) State Absorption Laws. Verify one of the Absorption Laws using a truth table.
ii) State and prove De Morgan’s theorem algebraically.
iii) State and prove idempotance law.
iv) State Duality Principle.
v) Name the law shown below and verify it using a truthtable: (CBSE 2014)
A+B.C = (A+B).(A+C)
22. Proving/Verifying the identities of Boolean algebra i) Verify the following using Truth Table. (CBSE 2011)
U.(U’+V)=(U+V)
ii) Verify the following using Truth Table: (CBSE 2012)
a. X+0 = X
b. X+X’=1
iii) Verify the following using Boolean Laws: (CBSE 2013)
A+C = A+A’.C+B.C
iv) Verify the following using Boolean Laws: (CBSE-Delhi 2015)
X + Y' = X.Y+X.Y'+X'.Y' v) Verify the following using Boolean Laws: (CBSE-OutsideDelhi 2015)
U’+ V= U’V’+U’.V +U.V
23. K-Map Reduce the following Boolean expressions with the help of Karnaugh Map.
(i) F(U,V,W,Z)=Π(0,1,2,4,5,6,8,10)
(ii) F(U,V,W,Z)=Π(0,1,2,4,5,6,8,12)
(iii) F(w,x,y,z) = Π (2,3,6,10,11,14)
(iv) F(x,y,z) = Σ(2,3,6,7)
(v) F(A, B, C, D) = ∑ (1, 2, 3, 4, 5, 7, 9, 11, 12, 13, 14, 15)
Assignment/XII/083/Final Revision/YK
57 ( © Yogesh Kumar)
(vi) F(A, B, C) = ∑ (1, 2, 3, 4, 5)
(vii) F(U,V,W,Z)= ∑ (0,1,2,4,5,6,8,12) (CBSE 2011)
(viii) F(P, Q, R, S) = ∑ (1, 2, 3, 4, 5, 6, 7, 8, 10) (CBSE 2012)
(ix) F(P, Q, R, S) = ∑ (0, 1, 2, 3, 5, 7, 8, 9, 10, 14, 15) (CBSE 2013)
(x) F(A, B, C, D) = ∑ (1, 4, 5, 9, 11, 12, 13, 15) (CBSE 2014)
(xi) F(X, Y, Z, W) = ∑(0,1,6,8,9,10,11,12,15) (CBSE-Delhi 2015) (xii) F(X,Y,Z,W) = Σ(0,1,4,5,6,7,8,9,11,15) (CBSE-Outside Delhi 2015)
24. Logic diagrams (i) Draw the NAND implementation of the following Boolean expression:
F(x, y, z)=x’.y + x.(y’+z’).
(ii) Represent the Boolean expression X.Y'+Z with the help of NOR gates only.
(iii) Represent the Boolean expression (x+y)(y+z)(x+z) with the help of NOR gates only.
(iv) Represent the Boolean expression x(y'+z) with the help of basic gates only.
(v) Write the equivalent Boolean expression for the following Logic circuits:
a.
(CBSE 2011)
b.
(CBSE 2012)
c.
(CBSE 2013)
d.
(CBSE 2014)
(vi) Draw the Logic Circuit for the following Boolean Expression: (CBSE-Delhi 2015)
(U + V').W' + Z (vii) Draw the Logic Circuit for the following Boolean Expression: (CBSE-Outside Delhi 2015)
(X’+Y).Z+W’
25. Finding expression from given Truth Table
Assignment/XII/083/Final Revision/YK
58 ( © Yogesh Kumar)
(i) Write the SOP and POS form of a Boolean function G, which is represented as a truth table as follows:
P Q R G
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 0
(ii) Write the POS form of a Boolean function F, which is represented in a Truth Table as follows:
(CBSE 2011)
A B C F
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
(iii) Write the POS form of a Boolean function G, which is represented in a Truth Table as follows:
(CBSE 2012)
A B C G
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
(iv) Write the Product of Sum form of the Boolean function G(U,V,W) for the following Truth Table
representation of F: (CBSE 2013)
U V W G
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
Assignment/XII/083/Final Revision/YK
59 ( © Yogesh Kumar)
1 1 0 0
1 1 1 1
(v) Write the Sum of Product form of the function F(P,Q,R) for the following Truth Table representation of
F:
(CBSE 2014)
P Q R F
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
(vi) Derive a Canonical SOP expression for a Boolean function F, represented by the following truth table:
(CBSE-Delhi 2015)
A B C F(A,B,C)
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
(vii) Derive a Canonical POS expression for a Boolean function F, represented by the following truth table:
(CBSE-Outside Delhi 2015)
P Q R F(P,Q,R)
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
26. Communication Technologies – Descriptive questions (i) Differentiate between packet switching and message switching technique in network communication.
(CBSE 2011)
(ii) Differentiate between Bus and Star topology of networks. (CBSE 2011)
(iii) What is VoIP? (CBSE 2011)
(iv) Out of the following, identify client side script(s) and server side script(s): (CBSE 2011)
(a) ASP (b) JavaScript (c) VBScript (d) JSP
(v) Which of the following will come under cybercrime: (CBSE 2011)
a. Theft of a brand new sealed pack Laptop
b. Access to a Bank account for getting unauthorized Money Transaction
c. Modification of a company data with unauthorized access.
Assignment/XII/083/Final Revision/YK
60 ( © Yogesh Kumar)
d. Photocopying a printed report
(vi) What, out of the following, will you use to have an audio-visual chat with an expert sitting in a faraway
place to fix-up a technical issue? (CBSE 2012)
Email, VoIP, FTP
(vii) Name one client side scripting language and one server side scripting language. (CBSE 2012)
(viii) Which, out of the following, does not come under Cyber Crime? (CBSE 2012)
a. Stealing a mouse from someone’s computer.
b. Operating someone’s Internet account, without his knowledge.
c. Entering in someone’s computer remotely and copying data, without seeking his permission.
(ix) Write one advantage of Star Topology of network? Also, illustrate how 5 computers can be connected
with each other using Star topology of network. (CBSE 2012)
(x) Give one suitable example of each – URL and Domain Name. (CBSE 2012)
(xi) What is the difference between domain name and IP address? (CBSE 2013)
(xii) Write two advantages of using an optical fiber cable over an Ethernet cable to connect two service
stations, which are 190m away from each other. (CBSE 2013)
(xiii) Which of the following crime(s) is/are covered under cybercrime? (CBSE 2013)
a. Stealing brand new hard disk from a shop
b. Getting into unknown person’s social networking account and start messaging on his behalf.
c. Copying some important data from a computer without taking permission from the owner of
the data.
(xiv) Write one characteristic each for 2G and 3G Mobile technologies. (CBSE 2014)
(xv) What is the difference between video conferencing and chat? (CBSE 2014)
(xvi) Expand the following: GPRS, CDMA (CBSE 2014)
(xvii) Which type of network (out of LAN, PAN, MAN) is formed when you connect two mobiles using
Bluetooth to transfer a picture file? (CBSE 2014)
(xviii) Write any two important characteristics of Cloud Computing. (CBSE 2014)
(xix) Illustrate the layout for connecting 5 computers in a Bus and a Star topology of Networks. (CBSE-Delhi, Outside Delhi 2015)
(xx) What is a spam mail? (CBSE 2015) (xxi) Differentiate between ftp and http. (CBSE 2015) (xxii) Out of the following, which is the fastest (i) wired and (ii) wireless medium of communication?
Infrared, Coaxial Cable, Ethernet Cable, Microwave, Optical Fiber (CBSE-Delhi, Outside Delhi 2015)
(xxiii) What is Worm? How is it removed? (CBSE 2015) (xxiv) Out of the following, which all comes under cyber crime? (CBSE 2015)
(i) Stealing away a brand new computer from a showroom. (ii) Getting in someone’s social networking account without his consent and posting pictures on
his behalf to harass him. (iii) Secretly copying files from server of a call center and selling it to the other organization. (iv) Viewing sites on a internet browser.
(xxv) What kind of data gets stored in cookies and how is it useful? (CBSE-Outside Delhi 2015) (xxvi) Differentiate between packet switching over message switching? (CBSE-Outside Delhi 2015) (xxvii) What is Trojan Horse? (CBSE-Outside Delhi 2015) (xxviii) Out of the following, which all comes under cyber crime? (CBSE-Outside Delhi 2015)
(i) Stealing away a brand new hard disk from a showroom. (ii) Getting in someone's social networking account without his consent and posting on his behalf. (iii) Secretly copying data from server of a organization and selling it to the other organization. (iv) Looking at online activities of a friend’s blog.
27. Network Setup (i) Quick Learn University is setting up its academic blocks at Prayag nagar and is planning to set up a
network. The University has 3 academic blocks and one Human Resource Center as shown in the
diagram below: (CBSE 2011)
Assignment/XII/083/Final Revision/YK
61 ( © Yogesh Kumar)
Center to Center distances between various blocks/center is as follows:
Law Block to business Block 40m
Law block to Technology Block 80m
Law Block to HR center 105m
Business Block to technology Block 30m
Business Block to HR Center 35m
Technology block to HR center 15m
Number of computers in each of the blocks/Center is as follows:
Law Block 15
Technology Block 40
HR center 115
Business Block 25
a) Suggest the most suitable place (i.e., Block/Center) to install the server of this University with a suitable
reason.
b) Suggest an ideal layout for connecting these blocks/centers for a wired connectivity.
c) Which device will you suggest to be placed/installed in each of these blocks/centers to efficiently connect
all the computers within these blocks/centers.
d) The university is planning to connect its admission office in the closest big city, which is more than 250km
from university. Which type of network out of LAN, MAN, or WAN will be formed? Justify your answer.
(ii) Granuda Consultants are setting up a secured network for their office campus at Faridabad for their
day to day office and web based activities. They are planning to have connectivity between 3 buildings
and the head office situated in Kolkata. Answer the questions (a) to (d) after going through the building
positions in the campus and other details, which are given below: (CBSE 2012)
Distances between various buildings:
Building “RAVI” to Building “JAMUNA” 120m
Building “RAVI” to Building “GANGA” 50m
Building “GANGA” to Building “JAMUNA” 65m
Faridabad Campus to Head Office 1460km
Number of computers:
Building “RAVI” 25
Building “JAMUNA” 150
Assignment/XII/083/Final Revision/YK
62 ( © Yogesh Kumar)
Building “GANGA” 51
Head Office 10
a) Suggest the most suitable place (i.e. block) to house the server of this organization. Also give a reason to
justify your suggested location.
b) Suggest a cable layout of connections between the buildings inside the campus.
c) Suggest the placement of the following devices with justification:
(i) Switch
(ii) Repeater
d) The organization is planning to provide a high speed link with its head office situated in KOLKATA using a
wired connection. Which of the following cable will be most suitable for this job?
(i) Optical Fiber
(ii) Co-axial cable
(iii) Ethernet cable
(iii) Expertia Professional Global (EPG) is an online corporate training provider company for IT related
courses. The company is setting up their new campus in Mumbai. You as a network expert have to study
the physical locations of various buildings and the number of computers to be installed. In the planning
phase, provide the best possible answers for the queries (a) to (d) raised by them. (CBSE 2013)
Building to Building distances (in Mtrs.)
FROM To Distance
Administrative Building Finance Building 60
Administrative Building Faculty Studio building 120
Finance Building Faculty Studio building 70
Number of computers in each of the blocks/Center is as follows:
Administrative Building 20
Finance Building 40
Faculty Studio building 120
a) Suggest the most appropriate building, where EPG should plan to install the server.
b) Suggest the most appropriate building to building cable layout to connect all three buildings for
efficient communication.
c) Which type of network out of the following is formed by connecting the computers of these three
buildings?
LAN, MAN, WAN
d) Which wireless channel out of the following should be opted by EPG to connect to students of all over
the world?
Infrared, Microwave, Satellite
Assignment/XII/083/Final Revision/YK
63 ( © Yogesh Kumar)
(iv) Trine Tech Corporation (TTC) is a professional consultancy company. The company is planning to set up
their new offices in India with its hub at Hyderabad. As a network adviser, you have to understand their
requirement and suggest them the best available solutions. Their queries are mentioned (a) to (d)
below.
(CBSE 2014)
Block to Block distances (in Mtrs.)
FROM To Distance
Human resource Conference 110
Human resource Finance 40
Conference Finance 80
Number of computers in each of the blocks/Center is as follows:
Human resource 25
Finance 120
Conference 90
a) What will be the most appropriate block, where TTC should plan to install the server?
b) Draw a block to block cable layout to connect all the buildings in the most appropriate manner for
efficient communication.
c) What will be the best possible connectivity out of the following, you will suggest to connect the new
setup of offices in Bangalore with its London based office?
Satellite Link, Infrared, Ethernet cable
d) Which of the following devices will be suggested by you to connect each computer in each of the
buildings.
Switch, modem, Gateway
(v) Perfect Edu Services Ltd. is an educational organization. It is planning to setup its India campus at
Chennai with its head office at Delhi. The Chennai campus has 4 main buildings – ADMIN, ENGINEERING,
BUSINESS and MEDIA (CBSE 2015)
Shortest distances between various buildings:
ADMIN to ENGINEERING 55 m
ADMIN to BUSINESS 90 m
ADMIN to MEDIA 50 m
ENGINEERING to BUSINESS 55 m
Assignment/XII/083/Final Revision/YK
64 ( © Yogesh Kumar)
ENGINEERING to MEDIA 50 m
BUSINESS to MEDIA 45 m
DELHI Head Office to CHENNAI Campus 2175 km
Number of Computers installed at various buildings are as follows:
ADMIN 110
ENGINEERING 75
BUSINESS 40
MEDIA 12
DELHI Head Office 20
(i) Suggest the most appropriate location of the server inside the CHENNAI campus (out of the 4 buildings), to get the best connectivity for maximum no. of computers. Justify your answer.
(ii) Suggest and draw the cable layout to efficiently connect various buildings within the CHENNAI campus for connecting the computers.
(iii) Which hardware device will you suggest to be procured by the company to be installed to protect and control the internet uses within the campus?
(iv) Which of the following will you suggest to establish the online face-to-face communication between the people in the Admin Office of CHENNAI campus and DELHI Head Office?
(a) Cable TV (b) Email (c) Video Conferencing (d) Text Chat
(vi) Xcelencia Edu Services Ltd. is an educational organization. It is planning to set up its India campus at
Hyderabad with its head office at Delhi. The Hyderabad campus has 4 main buildings ‐
ADMIN, SCIENCE, BUSINESS and MEDIA. (CBSE-Outside Delhi 2015)
You as a network expert have to suggest the best network related solutions for their problems raised in (i) to (iv), keeping in mind the distances between the buildings and other given parameters.
Shortest Distances between various buildings:
ADMIN to SCIENCE 65M
ADMIN to BUSINESS 100m
ADMIN to ARTS 60M
SCIENCE to BUSINESS 75M
SCIENCE to ARTS 60M
BUSINESS to ARTS 50M
DELHI Head Office to HYDERABAD Campus 1600KM
Number of Computers installed at various building are as follows:
ADMIN 100
SCIENCE 85
BUSINESS 40
ARTS 12
DELHI Head Office 20
Assignment/XII/083/Final Revision/YK
65 ( © Yogesh Kumar)
(i) Suggest the most appropriate location of the server inside the HYDERABAD campus (out of the 4
buildings), to get the best connectivity for maximum no. of computers. Justify your answer. (ii) Suggest and draw the cable layout to efficiently connect various buildings 'within the
HYDERABAD campus for connecting the computers. (iii) Which hardware device will you suggest to be procured by the company to be installed to
protect and control the internet uses within the campus? (iv) Which of the following will you suggest to establish the online face‐to‐face communication
between the people in the Admin Office of HYDERABAD campus and DELHI Head Office? (a) E‐mail (b) Text Chat (c) Video Conferencing (d) Cable TV
Assignment/XII/083/Final Revision/YK
66 ( © Yogesh Kumar)
ANSWERS
Assignment/XII/083/Final Revision/YK
67 ( © Yogesh Kumar)
2. Descriptive Question
(i)
Object Oriented Program Procedural Oriented Program
Data and related functions are represented as a unit in the form of classes.
Data is kept separate from functions.
Code reusability is supported in the form of Inheritance.
No concept of inheritance.
(ii)
TEXT FILE BINARY FILE
Data is stored in the form of lines of text. Data is stored in the form of sequence of bytes. There is no concept of lines in a Binary file.
A text file can be created as well as read using a C++ program or any text editor.
A Binary file can be created and read using a program only.
Character translation takes place while storing data in a text file and while reading data from it.
No character translation takes place while storing data in a binary file or reading data.
(iii) Local Variables: Local variables are those variables, which are declared within a function or a
compound statement and these variables can be used only within that function/scope. Global variables: Global variables are those variables, which are not declared within any function or scope. So, these variables can be accessed by any function of the program Example: Any program using local and global variables (with comments for explanation)
(iv) Private members of a class are accessible only to the member functions of the same class. Public members of a class are accessible to the member functions of the same class as well as to the member functions of its derived class(es) and also to the objects of the class.
(v)
Private Visibility Public Visibility
Members in private visibility mode are not accessible to the objects of class. They are only accessible inside the class to the member functions of the class,
Members in public visibility mode of the class are accessible to the objects of the class.
Example: Any program, including both types of members, which clearly demonstrates the difference.
(vi)
seekg() tellg()
Sets the value of get pointer of a file object. Returns the current value of the get pointer of a file object
Takes parameter(s) Does not take any parameter
Does not return any value Returns an integer value
(vii)
Syntax error Run time error Logical error
Caused by incorrect use of grammar of the language.
Caused by invalid operations during program execution.
Caused by incorrect logic of the program.
Reported by compiler and program does not compile.
Reported at run time and cause the program to terminate inappropriately.
Not reported at all. The user/programmer has to notice it manually.
Example: Missing ; where required.
Example: Division by zero Example: a+b instead of a-b
Assignment/XII/083/Final Revision/YK
68 ( © Yogesh Kumar)
(viii)
Constructor Destructor
A constructor executes whenever an object of a class is created.
A destructor is executed whenever the scope of an object gets over.
Constructor can be overloaded. Destructor cannot be overloaded.
Function Header: Member(); Function Header: ~Member();
(ix)
Formal parameters Actual parameters
The parameters mentioned in the function header are called the formal parameters.
Values/variables which are used while making a call to the function are called actual parameters.
Example: Any program, including both types of members, which clearly demonstrates the difference.
(x) A constructor
1) has the same name as the class name 2) has no return type 3) is called automatically when an object of the class is created 4) is not inherited in the derived class (if any)
(xi) A function prototype helps in calling the function from anywhere in the program.
Example: Any program, including a function prototype, function definition, and function call. (xii) typedef is a keyword in C++. It is used to give an alias to a data type.
Example: The statement typedef int number;
gives an alias to the data type int. Now in the program, in as well as number can be used to create variables of integer type, as in the following statements:
int a;
number b;
(xiii) The program execution starts from main() only. Therefore each C++ program must have main()
function. A program without main() is an incomplete program. Example: Any program, including main() and a user defined function which is called from main()
(xiv) A constant an identifier whose value cannot be changed in the program.
Example: The statement const float PI = 3.14;
defines PI to be a constant whose value is 3.14. The value of PI cannot be changed in the program in which it is defined.
Macro Constant
Macro Identifier has no data type Constant Identifier has a data type
No memory is allocated to a Macro Identifier Memory is allocated to a Constant
Identifier (xv) A reference variable is an alias (another name) given to an already existing variable.
Example: int x=35;
int& y=x; //y becomes a reference variable for x.
(xvi) A preprocessor statement is a statement which is executed before the program compilation starts. A
preprocessor statement starts with a # sign in the program.
Example: If a program contains the statements: #include <iostream.h>
#define pi 3.14
Assignment/XII/083/Final Revision/YK
69 ( © Yogesh Kumar)
Both these statements will be executed before the program compilation starts. The first statement will include the code from the header file iostream.h into the source code. The second statement will replace the token pi with 3.14 throughout the source code.
(xvii) Function Overloading is the concept of having more than one functions with the same name but different lists of formal parameters in a program. In their parameter lists, either the number of parameters should be different or the data types of at least one corresponding parameter should be different.
Example:
#include<iostream.h>
void add(int a, int b) //f1
int s=a+b;
cout<<"Sum="<<s<<endl;
void add(int a, int b, int c) //f2
int s = a+b+c;
cout<<"Sum="<<s<<endl;
void main()
add(2,3); //f1 is called
add(8, 4, 5); //f2 is called
(xviii) A class is a user defined data type which includes data members and function members to represent a particular kind of objects. In a class the default visibility mode is private wheras in a structure the default visibility mode is public.
(xix) Data Hiding: The concept of keeping the data memebrs of a class in private visibility mode so as to
save them from accidental changes is known as data hiding.
Encapsulation: The concept of wrapping up of data members and corresponding member functions
inside a class is called encapsulation.
Inheritance: Inheritance is the capability of a class to inherit the properties (data and functions) of
another existing class. The class which inherits the properties is called the derived class and the existing class from which the properties are inherited is called the base class.
Abstraction: Abstraction is the act of representing essential features without including background
details or explanation. Abstraction supports data hiding so that only relevant information is exposed to the user and rest of the information remains hidden from the user.
(xx) If a function does not have a local variable with the same name as a global variable, then the global variable can be accessed by simply referring to its name. If a function has a local variable with the same name as a global variable, then the global variable can be accessed inside the function using scope resolution operator (::) before the variable name.
(xxi) A copy constructor is a constructor of a class which is used to copy an existing object into another object at the time of its creation. The copy constructor is invoked when: automatically whenever
1. an object is copied by means of a declaration initialization. 2. an object is passed by value to a function. 3. an object is returned by value from a function.
(xxii) While, Float, Amount2, _Counter
(xxiii) A copy constructor is an overloaded constructor in which an object of the same class is passed as reference parameter.
class Point
Assignment/XII/083/Final Revision/YK
70 ( © Yogesh Kumar)
int x;
public:
Point()x=0;
Point(Point &p) // Copy constructor
x = p.x;
.
.
;
void main()
Point p1;
Point p2(p1);//Copy constructor is called here
//OR
Point p3=p1;//Copy constructor is called here
(xxiv) For, INT, NeW, name1
(xxv) ctype.h, stdio.h (xxvi) ctype.h, stdio.h
3. Finding Errors (i) #include <iostream.h>
struct Pixels
int color, style; ; //1
void ShowPoint(Pixels P)
cout<<P.color<<P.style<<endl;//2
void main()
Pixels Point1 = 5, 3; //3
ShowPoint (Point1); //4
Pixels Point2 = Point1; //5
Point1.color += 2; //6
ShowPoint(Point2);
(ii) #include <iostream.h>
#include <stdio.h> //1
void main()
struct movie
char movie_name[20];
char movie_type;
int ticket_cost; //2
MOVIE;
gets(MOVIE.movie_name); //3
cin>>MOVIE.movie_type; //4,5
(iii) #include <iostream.h> const int multiple=3; //1
void main()
int Value = 15; //2
for (int counter = 1; counter <= 5; counter++, Value -= 2)//3
if (Value%multiple == 0)
cout<<Value * multiple;
cout<<endl;
//4
else
Assignment/XII/083/Final Revision/YK
71 ( © Yogesh Kumar)
cout<<Value+multiple<<endl;
(iv) #include <iostream.h> //1 class PAYITNOW
int charge;
public: //2
void Raise() cin>>charge;
void Show() cout<<charge;
;
void main()
PAYITNOW P;
P.Raise();
P.Show(); //3
(v) #include <iostream.h> //1
#include <string.h> //2
typedef char Text[80]; //3
void main()
Text T="Indian";
int Count = strlen(T);
cout<<T<<"has"<<Count<<"characters"<<endl; //4
(vi) #include<iostream.h>
#include<iomanip.h> //1
class BOOK
long BId, Qty;
public: //2
void Purchase() cin>>BId>>Qty;
void Sale() //3
cout<<setw(5)<<BId<<"Old:"<<Qty<<endl;
cout<<"New:"<<--Qty<<endl;
;
void main()
BOOK B;
B.Purchase();
B.Sale(); //4
B.Sale(); //5
(vii) #define Convert(P, Q) P+2*Q //1 - Semi-colon removed
void main()
float A, B, Result; //2
cin>>A>>B;
Result = Convert(A,B); //3
cout<<"Output:"<<Result<<endl; //4
Assignment/XII/083/Final Revision/YK
72 ( © Yogesh Kumar)
(viii) typedef char STRING[50]; //1
void main()
STRING City; //2
gets(City);
cout<<City[0]<<'\t'<<City[2]; //3
cout<<City<<endl; //4
(ix) #define Max 70.0 //Error 1,2,3
void main() //Error 4
int Speed ; //Error 5
char Stop=’N’;
cin>>Speed;
if (Speed>Max) //Error 6
Stop=’Y’;
cout<<Stop<< endl ; //Error 7
(x) #define float MaxSpeed = 60.5 ; //Error 1,2,3
void main()
int MySpeed ; //Error 4
char Alert='N';
cin>>MySpeed;
if (MySpeed>MaxSpeed) //Error 5
Alert=’Y’;
cout<<Alert<< endl; //Error 6
4. Finding Output (a)
(i) DynAmiC ACt#10
(ii) cOMMuTEE ComPUteR
cOMMuTEE
cOMMuTEE
(iii) 6 10 8 6
8 8
6 8
(iv) value is: Pass
(v) J s this Easy?
(vi) 190280100 28010
57010
(vii) 3510 8210
Assignment/XII/083/Final Revision/YK
73 ( © Yogesh Kumar)
81020
(viii) VHAT A QOFIS!
(ix) 22
(x) NagpurDelhi MumbaiNagpurDelhi
(xi) 30 21#42
30#240
250#
(xii) Striker>10 Next@50
Last@40
Reset To0
(xiii) Ur2GRe r2GR
2G
(xiv) Ur2GReat r2GREat
2GrEat
great
(xv) 10SHAKTI 15HAKTI
(xvi) 2:30&60% 5:22&75%
2:30&65%
(xvii) 1SARGAM 9ARGAM
(xviii) A@1 0
A@2
75
A@3
120
(xix) 22,4 22,6
(xx) C#0 J#1
H#1
(xxi) 10, 8 20, 8
(xxii) B#0 I#1
G#1
(b) (i) Expected correct output is (i)
Least Value of Guess = 50
Highest value of Guess = 53
(ii) None of the outputs are correct
Variable named Chances does not exist in the program, hence no minimum
and maximum values for it.
(iii) Expected correct outputs are (i) and (iii)
Assignment/XII/083/Final Revision/YK
74 ( © Yogesh Kumar)
When Count = 3,
Minimum value of Trick = 0
Maximum value of Trick = 2
(iv) Expected correct outputis (iv)
Minimum value of Start = 2
Maximum value of Start = 3
(v) (iii) and (iv) Min Value of NUM = 2
Max Value of NUM = 4
(vi) (ii) and (iii) Min Value of VAL = 2
Max Value of VAL = 4
(c) @@@@ 91827
Polymorphism / Function Overloading (Any one)
5. Questions based on given class (i) (a) Constructor Overloading ( OR Polymorphism)
(b) Destructor. It is called when an object of the class goes out of scope.
(ii) (a) Option 2 is correct
(b) Constructor overloading / function Overloading / Polymorphism
(iii) (a) Function 1
(b) Health G(H); (OR Health G = H;)
(iv) (i) T.Book(1234567,”Ravi”); //Line 1 T.Print(); //Line 2
(ii) Function 4
OR
~Traveller()
It is a Destructor function.
(v) (i) P.Book(1234567,”Ravi”); //Line 1 P.Print(); //Line 2
(ii) Function 4 OR
~Passenger()
It is a Destructor function.
6. Define a class (i) class Candidate
long RNo;
char Name[20];
float score;
char Remarks[20];
void AssignRem()
if (Score >= 50)
strcpy(Remarks, “Selected”);
else
strcpy(Remarks, “Not selected”);
public:
void ENTER()
cin>>RNo;
Assignment/XII/083/Final Revision/YK
75 ( © Yogesh Kumar)
gets(Name);
cin>>Score;
AssignRem();
void Display()
cout<<RNo<<Name<<Score<<Remarks<<endl;
;
(ii) class SUPPLY
int Code;
char FoodName[20];
char Sticker[20];
char FoodType[20];
void GetType()
if (strcmpi(Sticker,"GREEN")==0)
strcpy(FoodType, "Vegetarian");
else if (strcmpi(Sticker, "YELLOW")==0)
strcpy(FoodType, "Contains Egg");
else if (strcmpi(Sticker, "RED")==0)
strcpy(FoodType, "Non-Vegetarian");
public:
void FoodIn()
cin>>Code;
gets(FoodName);
gets(Sticker);
GetType();
void FoodOut()
cout<<Code<<", "<<FoodName<<", "
<<Sticker<<", "<<FoodType<<endl;
;
(iii) class Tourist
int Carno;
char Origin[20], Destination[20], Type;
float Distance, Charge;
public:
Tourist()
Type = 'E';
Charge = 250;
void CalcCharge()
if (Type == 'E')
Charge = 16*Distance;
else if (Type=='A')
Charge = 22*Distance;
else if (Type == 'L')
Charge = 30*Distance;
void Enter()
Assignment/XII/083/Final Revision/YK
76 ( © Yogesh Kumar)
cin>>Carno;
gets(Origin);
gets(Destination);
cin>>Type;
cin>>Distance;
CalcCharge();
void Show()
cout<<Carno<<", "<<Origin<<", "<<Destination<<", ";
cout<<Type<<", "<<Distance<<", "<<Charge;
;
(iv) class CABS
int CNo;
char Type;
float Dis, PKM;
public:
CABS()
Type = 'A';
CNo = 1111;
void Charges()
if (Type == 'A')
PKM = 25;
else if (Type=='B')
PKM = 20;
else if (Type == 'C')
PKM = 15;
void Enter()
cin>>CNo;
cin>>Type;
Charges();
void ShowCab()
cin>>Dis;
cout<<CNo<<", "<<Type<<", "<<PKM;
cout<<endl<<"Amount = "<<PKM*Dis;
;
(v) class TravelPlan
private:
long PlanCode;
char Place[20];
float No_of_Travellers, No_of_Buses;
public:
TravelPlan()
PlanCode = 1001;
strcpy(Place, "Agra");
No_of_Travellers=5;
No_of_Buses=1;
Assignment/XII/083/Final Revision/YK
77 ( © Yogesh Kumar)
void NewPlan()
cin>>PlanCode>>Place>>No_of_Travellers;
if (No_of_Travellers < 20)
No_of_Buses = 1;
else if (No_of_Travellers < 40)
No_of_Buses = 2;
else No_of_Buses = 3;
;
(vi) class TEST
private:
int TestCode;
char Description[20];
int NoCandidate, CenterReqd;
void CALCNTR()
return (NoCandidate/100+1);
public:
void SCHEDULE()
cin>>TestCode>>Description>>NoCandidate;
CALCNTR();
void DISPTEST()
cout<<TestCode<<", "<<Description<<", ";
cout<<NoCandidate<<", "<<CenterReqd;
;
(vii) class FLIGHT
private:
int FlightNumber;
char Destination[20];
float Distance, Fuel;
void CALFUEL()
if (Distance <= 1000)
Fuel = 500;
else if (Distance <=2000)
Fuel = 1100;
else Fuel = 2200;
public:
void FEEDINFO()
cin>>FlightNumber>>Destination>>Distance;
CALFUEL();
void SHOWINFO()
cout<<FlightNumber<<", "<<Destination<<", ";
cout<<Distance<<", "<<Fuel;
;
(viii) class PIC
int Pno;
char Category[20];
Assignment/XII/083/Final Revision/YK
78 ( © Yogesh Kumar)
char Location[20];
void FixLocation();
public:
void Enter();
void SeeAll();
;
void PIC::FixLocation()
if(strcmpi(Category,”Classic”)==0)
strcpy(Location,”Amina”);
else if(strcmpi(Category,”Modern”)==0)
strcpy(Location,” Jim Plaq” );
else if strcmpi(Category,”Antique”)==0)
strcpy(Location,” Ustad Khan” );
void PIC::Enter()
cin>>Pno;gets(Category);
FixLocation();
void PIC:: SeeAll()
cout<<Pno<<Category<<Location<<endl;
(ix) class Photo
int Pno;
char Category[20];
char Exhibit[20];
void FixExhibit();
public:
void Register();
void ViewAll();
;
void Photo::FixExhibit()
if(strcmpi(Category,”Antique”)==0)
strcpy(Exhibit,”Zaveri”);
else if(strcmpi(Category,”Modern”)==0)
strcpy(Exhibit,”Johnsen”);
else if strcmpi(Category,”Classic”)==0)
strcpy(Exhibit,”Terenida”);
void Photo::Register()
cin>>Pno;
gets(Category);
FixExhibit();
void Photo:: ViewAll()
cout<<Pno<<Category<<Exhibit<<endl;
7. Inheritance
(i) a. None b. Enter(), Show()
Assignment/XII/083/Final Revision/YK
79 ( © Yogesh Kumar)
c. SHOP(), Sales_Entry(), Sales_Detail() Register(), CUSTOMER(), Status() SALESMAN(), Enter(), Show(), Voucher_No, Sales_Date, Salary
d. 66 (Turbo C++) / 70 (Borland C++) (Both these answers are correct) (ii) a. base class: Mydata, derived class: mydata1
Base class: mydata1, derived class: person b. data1, get_mydata1(), show_data1() c. show_data2(), get_mydata1(), show_data1() d. mydata1, person
(iii) a. base class: zoo, derived class: carnivorous b. paw_size, legs c. None d. No
(iv) base CC base CC
der1 CC
base CC
base CC
der1 CC
der2 CC
I am derived2
I am derived1
I am base
der2 DC
der1 DC
base DC
base DC
der1 DC
base DC
base DC
(v) a. Multiple Inheritance
b. CCode, CourseName, StartDate, EndDate, Pay c. Commerce(), CDetail(), Register(), Display() d. Enter(), Show()
(vi) (a) Hierarchical Inheritance
(b) Address, Area, Sale (c) Enter(), Display(), Get(), Show() (d) Enter(), Show()
(vii) (a) Multilevel Inheritance
(b) OverallGrade, Remarks (c) Revaluate(), RPrint(), Sentry(), Sdisplay() (d) Grade, marks, SName
(viii) (a) Multilevel Inheritance (b) Enroll(), View(), Enter(), Show() (c) RegNo, Name, Budget (d) No (OR University class does not exist)
(ix) (i) Multi Level Inheritance (ii) WallArea, ColorCode,Type, Advance
(iii) Billing(), Print(), PBook(), PView(), Book(), View()
Assignment/XII/083/Final Revision/YK
80 ( © Yogesh Kumar)
(iv) Exterior(), Paint(), Bill()
(x) (i) Multi Level Inheritance (ii) WallArea, ColorCode,Type, Advance
(iii) Bill(), BillPrint(), PBook(), PView(), Book(), View()
(iv) Interior, Painting, Billing
8. Functions on 1D Arrays (i) void SwapHalf(int A[], int n)
int i = 0, j = (n+1)/2, temp;
while (j<n)
temp = A[i];
A[i] = A[j];
A[j] = temp;
i++;
j++;
(ii) void Reversearray(int NUMBERS[], int N)
int i=0, j=N-1, temp;
while (i<j)
temp = NUMBERS[i];
NUMBERS[i] = NUMBERS[j];
NUMBERS[j] = temp;
i++; j--;
(iii) void SwapArray(int NUMBERS[], int N)
int temp;
for (int i=0; i<N-1; i+=2)
temp = NUMBERS[i];
NUMBERS[i] = NUMBERS[i+1];
NUMBERS[i+1] = temp;
(iv) void merge(int A[], int B[], int C[], int n1, int n2)
int i, j, k;
i = k = 0; j = n2-1;
while (i < n1 && j >= 0)
if (A[i] < B[j])
C[k++] = A[i++];
else
C[k++] = B[j--];
while(i < n1)
C[k++] = A[i++];
While (j >= 0)
C[k++] = B[j--];
Assignment/XII/083/Final Revision/YK
81 ( © Yogesh Kumar)
(v) void reassign(int A[], int N)
for (int i=0; i<N; i++)
C[i] = 2*A[i]+3*B[i];
(vi) void Combine(int A[], int N)
for (int i=0; i<N; i++)
if (A[i]%5 == 0)
A[i]/=5;
else
A[i]*=2;
(vii) void get(int first[], int second[], int ALL[], int m, int n)
int i=0, j=0, k=0;
while(i<m && j<n)
ALL[k++] = second[j++];
ALL[k++] = first[i++];
while(i < m)
ALL[k++] = first[i++];
While (j < n)
C[k++] = B[j++];
(viii) void Replace(int A[], int N)
for (int i=0; i<N; i++)
if (A[i]%2 == 0)
A[i]/=2;
else
A[i]*=2;
(ix) void Convert(int t[], int Num)
int temp = A[0];
for (int i=1; i<N; i++)
A[i-1]= A[i];
A[N-1] = temp;
(x) void SWAP2CHANGE(int P[], int N)
for (int i=0; i<N-1; i++) //because last does not have next element
if (A[i]%10 == 0)
int temp = A[i];
A[i] = A[i+1];
A[i+1] = temp;
Assignment/XII/083/Final Revision/YK
82 ( © Yogesh Kumar)
(xi) void OddEven(int s[], int N)
for (int i=0; i<N; i++)
if (A[i]%2 == 0)
A[i]+=10;
else
A[i]+=5;
(xii) void Alter(int A[ ],int N)
for (int i=0;i<N;i++)
if(A[i]%5==0)
A[i]=5;
else
A[i]=0;
(xiii) void Change(int P[],int N)
for (int i=0;i<N;i++)
if(P[i]%10==0)
P[i]=10;
else
P[i]=1;
OR Any other correct equivalent function definition
9. Functions on 2D Arrays
(i) void row_sum(int a[][10], int R, int C)
for(int i=0; i<R; i++)
int sum=0;
for(int j=0; j<C; j++)
sum+=a[i][j];
cout<<"Sum of row "<<i+1<<" = "<<sum<<endl;;
(ii) void diagonal_sum(int a[][10], int R, int C)
int i=0, j=C-1, sum1=0, sum2=0;
for(i=0; i<R; i++)
sum1 += a[i][i];
sum2 += a[i][j];
j--;
cout<<"sum of 1st and 2nd diagonal is="<<sum1<<endl<<sum2<<endl;
Assignment/XII/083/Final Revision/YK
83 ( © Yogesh Kumar)
(iii) void row_col_sum(int a[][10], int R, int C)
for(int i=0; i<R; i++)
int sum=0;
for(int j=0; j<C; j++)
sum+=a[i][j];
cout<<"Sum of row "<<i+1<<" = "<<sum<<endl;;
for(int i=0; i<C; i++)
int sum=0;
for(int j=0; j<R; j++)
sum+=a[j][i];
cout<<"Sum of col "<<i+1<<" = "<<sum<<endl;;
(iv) void sum_3_5(int A[][10], int R, int C)
int i, j, sum = 0;
for(i=0; i<R; i++)
for(int j=0; j<C; j++)
if (A[i][j]%3 == 0 || A[i][j]%5 == 0)
sum += A[i][j];
cout<<"Required sum = "<<sum<<endl;
(v) void OneD_TwoD(int A[], int n)
int B[10][10]=0; //Assuming that n<=10
for (int i = 0; i<n; i++)
for (int j = 0; j<n; j++)
if (i+j<n)
B[i][j]=A[j];
for (int i = 0; i<n; i++)
for (int j = 0; j<n; j++)
cout<<B[i][j]<<'\t';
cout<<endl;
(vi) int altersum(int b[][5],int n, int m)
int i, j, sum = 0;
int count=0;
for(i=0; i<n; i++)
for(j=0; j<m; j++)
if (count%2 == 0)
sum += b[i][j];
count++;
return sum;
Assignment/XII/083/Final Revision/YK
84 ( © Yogesh Kumar)
(vii) void row_pro(int a[][10], int R, int C)
for(int i=0; i<R; i++)
int pro=0;
for(int j=0; j<C; j++)
sum+=a[i][j];
cout<<"Product of row "<<i+1<<" = "<<pro<<endl;;
(viii) void middle_row_col(int A[][5],int n)
if (n%2 == 0)
cout<<"Size not appropriate to find middle row or column";
else
int i;
cout<<"Middle row: ";
for(i=0; i<n; i++)
cout<<A[n/2][i]<<" ";
cout<<"\nMiddle column: ";
for(i=0; i<n; i++)
cout<<A[i][n/2]<<" ";
(ix) void Swap_Cols(int A[][5],int n, int m)
for(int i=0; i<n; i++)
int temp = A[i][0];
A[i][0] = A[i][m-1];
A[i][m-1] = temp;
for (int i=0; i<n; i++)
for (int j=0; j<m; j++)
cout<<A[i][j]<<'\t';
cout<<endl;
(x) void Swap_Rows(int A[][5],int n, int m)
for(int i=0; i<m; i++)
int temp = A[0][i];
A[0][i] = A[n-1][i];
A[n-1][i] = temp;
for (int i=0; i<n; i++)
for (int j=0; j<m; j++)
cout<<A[i][j]<<'\t';
cout<<endl;
(xi) void col_sum(int a[][10], int N, int M)
for(int i=0; i<M; i++)
int sum=0;
for(int j=0; j<N; j++)
Assignment/XII/083/Final Revision/YK
85 ( © Yogesh Kumar)
sum+=a[j][i];
cout<<"Sum of col "<<i+1<<" = "<<sum<<endl;;
(xii) Void SKIPEACH(int H[][3],int C, int R)
int i, j;
int count=0;
for(i=0; i<R; i++)
for(j=0; j<C; j++)
cout<<H[i][j]<<” “;
count++;
(xiii) Void DisTen(int L[][4],int R, int C)
int i, j;
for(i=0; i<R; i++)
for(j=0; j<C; j++)
if (H[i][j]%10 != 0)
cout<<H[i][j]<<” “;
(xiv) void SumLast3(int A[][4], int N, int M)
int i, j, sum = 0;
for(i=0; i<N; i++)
for(j=0; j<M; j++)
if (A[i][j]%10 == 3)
sum += A[i][j];
cout<<"Required sum = "<<sum<<endl;
(xv) void REVCOL(int P[][5],int N,int M)
for(int I=N1;I>=0;I)
for(int J=0;J<M;J++)
cout<<P[I][J];
cout<<endl;
(xvi) void REVROW(int P[][5],int N,int M)
for(int I=0; I<N; I++)
for(int J=M1;J>=0; J)
cout<<P[I][J];
cout<<endl;
OR
Assignment/XII/083/Final Revision/YK
86 ( © Yogesh Kumar)
void REVROW(int P[ ][5],int N,int M)
for(int I=0; I<N; I++)
for(int J=0; J<M/2; J++)
int T = P[I][J];
P[I][J] = P[I][MJ1];
P[I][MJ1]= T;
for(I=0; I<N; I++)
for(int J=0; J<M; J++)
cout<<P[I][J];
cout<<endl;
10. Address Calculation (i) (i) 1528, 1544 (ii) 5190 (iii) 2872, 4092 (iv) 4612 (v) 116 (vi) 5320
(ii) (viii) 7892 (viii) 14332 (ix) 42430 (x) 16100
(iii)
(iv)
(v)
(vi)
(vii)
(viii)
(ix)
(x)
(xi) Loc(ARR[I][J]) along the row
=BaseAddress + W [( I – LBR)*C + (J – LBC)]
(where C is the number of columns, LBR = LBC = 0
LOC(ARR[10][5]) = BaseAddress + W [ I*C + J]
15000 = BaseAddress + 4[10*20 + 5]
= BaseAddress + 4[200 + 5]
= BaseAddress + 4 x 205
= BaseAddress + 820
=> BaseAddress = 15000-820
= 14180
=> LOC(ARR[30][10])= 14180 + 4[30 * 20 + 10]
= 14180 + 4 * 610
= 14180 + 2440
= 16620
OR
LOC(ARR[30][10])= LOC(ARR[10][5])+ W[( ILBR)*C + (JLBC)]
= 15000 + 4[(3010)*20 + (105)]
= 15000 + 4[ 20*20 + 5]
= 15000 + 4 *405
= 15000 + 1620
= 16620
OR
Where C is the number of columns and LBR=LBC=1
LOC(ARR[10][5])
Assignment/XII/083/Final Revision/YK
87 ( © Yogesh Kumar)
15000 = BaseAddress + W [( I1)*C + (J1)]
= BaseAddress + 4[9*20 + 4]
= BaseAddress + 4[180 + 4]
= BaseAddress + 4 * 184
= BaseAddress + 736
=> BaseAddress = 15000-736
= 14264
LOC(ARR[30][10]) = 14264 + 4[(301)* 20 + (101)]
= 14264 + 4[29*20 + 9]
= 14264 + 4[580 + 9]
= 14264 + 4*589
= 14264 + 2356
= 16620
(xii)
11. Sorting (i)
void selectionsort(Employee A[], int n)
for(int i = 0; i<n-1; i++)
Employee max = A[i]; int pos = i;
for (int j = i+1; j<n; j++)
if (A[j].salary > max.salary)
max = A[j];
pos = j;
A[pos] = A[i];
A[i] = max;
(ii) void BubbleSort(Student S[], int n)
for(int x = 1; x<n; x++)
for (int k = 0; k<n-x; k++)
if (S[k].Marks < S[k+1].Marks)
Student temp = S[k];
S[k] = S[k+1];
S[k+1] = temp;
(iii) void InsertionSort(int arr[], int n)
for(int k=1; k<n; k++)
int t=arr[k];
int x=k-1;
while(x>=0 && t<arr[x])
arr[x+1]=arr[x];
x--;
arr[x+1]=t;
Selection Sort
Assignment/XII/083/Final Revision/YK
88 ( © Yogesh Kumar)
Bubble Sort
Insertion Sort
Assignment/XII/083/Final Revision/YK
89 ( © Yogesh Kumar)
12. Merging (i)
void merge(int A[], int B[], int C[], int M, int N)
int i, j, k;
i = k = 0; j = N-1;
while (i < M && j >= 0)
if (A[i] < B[j])
C[k++] = A[i++];
else
C[k++] = B[j--];
while(i < M)
C[k++] = A[i++];
While (j >= 0)
C[k++] = B[j--];
(ii)
void MIX(int A[], int B[], int C[], int M, int N)
int i, j = M+N-1, k=0;
for (i=0; i<M; i++)
if (A[i]%2 == 0)
C[k++] = A[i];
for (i=0; i<M; i++)
if (A[i]%2 == 1)
C[j--] = A[i];
for (i=0; i<N; i++)
if (B[i]%2 == 0)
C[k++] = B[i];
for (i=0; i<M; i++)
if (B[i]%2 == 1)
C[j--] = B[i];
(iii)
void merge(int A[], int B[], int C[], int M, int N)
int i, j, k;
i = M-1, j = N-1, k = 0;
while (i >= 0 && j >= 0)
if (A[i] < B[j])
C[k++] = A[i--];
else if (B[j] < A[i])
C[k++] = B[j--];
else //A[i] == B[j]
C[k++] = A[i--];
j--;
while(i >= 0)
C[k++] = A[i--];
While (j >= 0)
C[k++] = B[j--];
13. Stacks
(i) class stack
int data[10];
int top;
public:
Assignment/XII/083/Final Revision/YK
90 ( © Yogesh Kumar)
stack() top = -1;
void push(int item); // to push an element into the stack
void pop(int &item); // to pop an element from the stack
void Delete(int ITEM); //to delete all elements which are equal to ITEM
;
void stack::push(int item)
if (top == 9)
cout<<"Overflow error. Stack is full";
else
data[++top] = item;
void stack::pop(int &item)
if (top == -1)
cout<<"Underflow error. Stack is empty";
else
item = data[top--];
void stack::Delete(int ITEM) //to delete all elements which are equal to ITEM
stack temp;
int item;
while (top != -1)
pop(item);
if (item != ITEM)
temp.push(item);
while (temp.top != -1)
temp.pop(item);
push(item);
(ii) void STACK::PUSH()
Node *N = new Node;
if (N == NULL)
cout<<"Overflow error. Out of memory";
else
cin>>N->X>>N->Y;
N->Link = Top;
Top = N;
(iii) void stack::stackpush()
node *N = new node;
if (N == NULL)
cout<<"Overflow error. Out of memory";
getch();
else
gets(N->name);
cin>>N->age;
N->Link = top;
top = N;
(iv) void POPBOOK()
if (TOP == NULL)
cout<<"Underflow error! Empty stack";
else
Assignment/XII/083/Final Revision/YK
91 ( © Yogesh Kumar)
NODE *N = TOP;
cout<<N->Bno<<N->Title<<" Popped";
TOP = TOP -> Link;
delete N;
(v) void STACK::POP()
if (Top!=NULL)
TEXTBOOKS *Temp;
Temp=Top;
cout<<Top->ISBN<<Top->TITLE<<”deleted”<<endl;
Top=Top->Link;
delete Temp;
else
cout<<”Stack Empty”<<endl;
(vi) void STACK::PUSH()
BOOKS *Temp;
Temp=new BOOKS;
gets(Temp->ISBN);
gets(Temp->TITLE);
Temp->Link=Top;
Top=Temp;
OR Any other correct equivalent function definition
14. Infix to Postfix expression (i) A, B, *, C, D, F, /, -, + (ii) A, B, +, C, *, D, E, /, +, F, -
(iii) A, B, +, C, +, D, E, *, F, /, - (iv) A, B, C, *, D, E, /, F, -, *, * (v) A, B, AND, C, D, NOT, OR, AND, E, AND (vi) X,Y,/,U,V,W,-,*,+
(vii) U * V + R/ (S-T) = (U * V + R/ (S-T))
Element Stack Postfix
( (
U ( U
* (* U
V (* UV
+ (+ UV*
R (+ UV*R
/ (+/ UV*R
( (+/( UV*R
S (+/( UV*RS
- (+/(- UV*RS
T (+/(- UV*RST
) (+/ UV*RST-
) UV*RST-/+
OR Any other method for converting the given Infix expression to its equivalent Postfix expression showing stack contents
Assignment/XII/083/Final Revision/YK
92 ( © Yogesh Kumar)
15. Evaluation of Postfix expression (i) 10 (ii) 203 (iii) 1000 (iv) 500 (v) FALSE (vi) 1100 (vii) TRUE (viii)
Element scanned Stack status
60 60
6 60, 6
/ 10
5 10, 5
2 10, 5, 2
* 10, 10
5 10, 10, 5
- 10, 5
+ 15
Hence the final result is 15.
(ix) FALSE
16. Queues (i) void QUEUE::DELETE()
if (Front == NULL)
cout<<"Underflow error! Queue is empty";
else
Node *N = Front;
if (Front == Rear)
Front = Rear = NULL;
else Front = Front -> Link;
cout<<N->U<<N->V<<" Deleted";
delete N;
(ii) void queue::queins() node *N = new node;
if (N == NULL)
cout<<"Overflow error. Out of memory";
else
gets(N->name);
cin>>N->age;
N->Link = NULL;
if (front == NULL)
front = rear = N;
else
rear->Link = N;
rear = N;
void queue::quedel()
if (front == NULL)
cout<<"Underflow error! Queue is empty";
else
Assignment/XII/083/Final Revision/YK
93 ( © Yogesh Kumar)
node *N = front;
if (front == rear)
front = rear = NULL;
else front = front -> Link;
cout<<N->name<<N->age<<" Deleted";
delete N;
(iii) class queue int data[10];
int front, rear;
public:
queue() front = rear = -1;
void insertq(int ITEM); // to insert an element into the queue
void deleteq(int &ITEM); // to delete an element from the queue
void Remove(int ITEM); //to delete all elements which are equal to ITEM
;
void queue::insertq(int ITEM)
if ((front == 0 && rear == 9) || (rear == front-1))
cout<<"Overflow error. Queue is full";
else
if (rear == 9)
rear = 0;
else if (rear == -1)
rear = front = 0;
else rear++;
data[rear] = ITEM;
void queue::deleteq(int &ITEM)
if (front == -1)
cout<<"Underflow error! Queue is empty";
else
ITEM = data[front];
if (front == rear)
front = rear = -1;
else if (front == 9)
front = 0;
else front++;
void queue::Remove(int ITEM)
queue temp; int item;
while (front != -1)
deleteq(item);
if (item != ITEM)
temp.insertq(item);
while (temp.front != -1)
temp.deleteq(item);
insertq(item);
(iv) void queins()
Assignment/XII/083/Final Revision/YK
94 ( © Yogesh Kumar)
NODE *N = new NODE;
if (N == NULL)
cout<<"Overflow error. Out of memory";
else
cin>>N->Pno;
gets(N->Pname);
N->Link = NULL;
if (front == NULL)
front = rear = N;
else
rear->Link = N;
rear = N;
(v) void queins() DVD *N = new DVD;
if (N == NULL)
cout<<"Overflow error. Out of memory";
else
cin>>N->No;
gets(N->Title);
N->Link = NULL;
if (front == NULL)
front = rear = N;
else
rear->Link = N;
rear = N;
(vi) void QINSERT() NODE *N = new NODE;
if (N == NULL)
cout<<"Overflow error. Out of memory";
else
cin>>N->Cno;
gets(N->Cname);
N->Next = NULL;
if (front == NULL)
front = rear = N;
else
rear->Next = N;
rear = N;
17. Text File Operations (i) 4
(ii) void count_blank()
char ch; int count = 0;
fstream infile("PARA.TXT");
while (infile.get(ch))
Assignment/XII/083/Final Revision/YK
95 ( © Yogesh Kumar)
if (ch == ' ')
count++;
cout<<"File contains "<<count<<" blanks";
infile.close();
(iii) void vowelwords()
char word[20], ch;
ifstream infile("TEXT1.TXT");
ofstream outfile("TEXT2.TXT");
while (infile>>word)
ch = word[0];
if (ch != 'A' && ch != 'E' && ch != 'I' && ch != 'O' && ch != 'U')
outfile<<word<<" ";
infile.close();
outfile.close();
(iv) void count_lines()
char line[80], ch;
int count = 0;
ifstream tf(“STORY.TXT”);
while (tf.getline(line, 80))
int l = strlen(line);
ch = toupper(line[l-1]);
if (ch==’A’ || ch==’E’ || ch==’I’ || ch==’O’ || ch==’U’)
count++;
tf.close();
cout<<count<<” lines end with vowel”;
(v) void countwords()
char word[20], ch;
Int count=0;
ifstream infile("LINES.TXT");
while (infile>>word)
ch = word[0];
if (ch != 'A' || ch != 'a')
count++;
Cout<<count;
(vi) void Last3()
char word[20], ch;
ifstream infile("TEXT1.TXT");
infile.seekg(0, ios::end);
int n = infile.tellg();
infile.seekg(n-3);
while (infile.get(ch))
cout<<ch;
infile.close();
(vii) void copy()
char word[20], ch;
ifstream infile("FAIPS.TXT");
ofstream outfile("DPS.TXT");
while (infile>>word)
if (isupper(word[0]))
Assignment/XII/083/Final Revision/YK
96 ( © Yogesh Kumar)
outfile<<word<<" ";
infile.close();
outfile.close();
(viii) void show(int n)
char ch;
ifstream infile("MIRA.TXT");
infile.seekg(0, ios::end);
int size = infile.tellg();
if (n > size)
cout<<”invalid n”;
else
infile.seekg(n-1);
infile.get(ch);
cout<<ch;
infile.close();
(ix) void countMeMy()
char word[20];
int count = 0;
ifstream infile("DIARY.TXT");
while (infile>>word)
if (strcmpi(word,"Me")==0 || strcmpi(word,"My")==0)
count++;
infile.close();
cout<<"Count of Me/My in the file: "<<count;
(x) void Disp_PS()
char line[80], ch;
ifstream tf("Places.txt");
while (tf.getline(line, 80))
ch = toupper(line[0]);
if (ch=='P' || ch=='S')
cout<<line<<endl;
tf.close();
(xi) void CountHisHer()
char word[20];
int His=0, Her=0;
ifstream infile("Equality.txt");
while (infile>>word)
if (strcmpi(word,"His")==0)
His++;
else if (strcmpi(word,"Her")==0)
Her++;
infile.close();
cout<<"Count of His: "<<His<<endl;
cout<<"Count of Her: "<<Her;
(xii) void EUCount()
char ch;
Assignment/XII/083/Final Revision/YK
97 ( © Yogesh Kumar)
int CountE=0, CountU=0;
ifstream infile("IMP.TXT");
while (infile.get(ch))
if (toupper(ch) == 'E')
CountE++;
else if (toupper(ch) == 'U')
CountU++;
infile.close();
cout<<"E: "<<CountE<<endl;
cout<<"U: "<<CountU;
(xiii) void SUCCESS()
int count=0;
ifstream f("STORY.TXT");
char s[20];
while (!f.eof())
f>>s;
if(strcmpi(s,”STORY”)==0)
//OR if(strcmpi(s,”SUCCESS”)==0) count++;
cout<<count;
f.close();
(xiv) void TOWER()
int count=0;
ifstream f("WRITEUP.TXT");
char s[20];
while (!f.eof())
f>>s;
if (strcmpi(s,”TOWER”)==0)
count++;
cout<<count;
f.close();
OR Any other correct function definition
18. Binary File Operations (i) void update()
fstream df;
product p;
char code[10];
cout<<"Enter the product code: "; gets(code);
df.open("PRODUCT.DAT",ios::in|ios::out|ios::binary);
int found = 0;
while(df.read((char*)&p, sizeof(p)) && found==0)
if (strcmp(p.product_code,code)==0)
found = 1;
Assignment/XII/083/Final Revision/YK
98 ( © Yogesh Kumar)
cout<<"Enter new value of stock: ";
cin>>p.stock;
df.seekg(-sizeof(p),ios::cur);
df.write((char*)&p, sizeof(p));
if (found == 0)
cout<<"Record not found...";
df.close();
(ii) void show()
student s; int found = 0;
ifstream df("Student.dat",ios::binary);
while(df.read((char*)&s, sizeof(s)))
if (s.returnPercentage() > 75)
found = 1;
s.showdata();
if (found == 0)
cout<<"No such record is found";
df.close();
(iii) void showfile()
Vehicle v; int count = 0;
ifstream df("SPEED.DAT",ios::binary);
while(df.read((char*)&v, sizeof(v)))
v.showdetails();
Count++;
if (count == 0)
cout<<"No such record is found";
else cout<<count<<” records are present in the file”;
df.close();
(iv) void Search()
Book b;
Int BookNo;
cout<<"Enter the book number to serach for: "; cin>>BookNo;
ifstream df("BOOK.DAT",ios::binary);
int found = 0;
while(df.read((char*)&b, sizeof(b)) && found==0)
if (b.Rbook_no() == BookNo)
found = 1;
if (found == 1)
cout<<"Book found in the file";
else cout<<"Book not found in the file";
df.close();
(v) Statement 1: File.tellp() (OR File.tellg())
Statement 2: File.seekp(-sizeof(PRODUCT), ios::cur); (OR File.seekg())
(vi) Statement 1: File.seekp(Location);
Statement 2: File.write((char*)&CU, sizeof(CU));
(vii) Statement 1: File.seekp(-sizeof(I), ios::cur);
Assignment/XII/083/Final Revision/YK
99 ( © Yogesh Kumar)
Statement 2: File.write((char*)&I, sizeof(I)); (viii) Statement 1: M.ChangeMobile();
Statement 2: File.seekp(-sizeof(M), ios::cur); (ix) Missing Statement: File.seekp(-sizeof(OB), ios::cur);
Missing Expression: found == 0 (x) void show()
VINTAGE V; int found = 0;
ifstream df("vintage.dat",ios::binary);
while(df.read((char*)&V, sizeof(V)))
if (V.ReturnPrice()>200000 && V.returnPrice() < 2500000)
found = 1;
V.VIEW();
if (found == 0)
cout<<"No such record is found";
df.close();
(xi) void search()
LAPTOP L; long ModelNo;
int found = 0;
cout<<”Enter the Model number to search for: “;
cin>>ModelNo;
ifstream df("LAPTOP.DAT",ios::binary);
while(df.read((char*)&L, sizeof(L)))
if (L.ReturnModelNo() == ModelNo)
found = 1;
L.StockDisplay();
if (found == 0)
cout<<"No such record is found";
df.close();
(xii) void search()
Mobile M;
int found = 0;
ifstream df("mobile.dat",ios::binary);
while(df.read((char*)&M, sizeof(M)))
if (M.GetCalls() > 1000)
found = 1;
M.Billing();
if (found == 0)
cout<<"No such record is found";
df.close();
(xiii) void search()
GAMES G;
int found = 0;
ifstream df("GAMES.DAT",ios::binary);
while(df.read((char*)&G, sizeof(G)))
if (strcmp(G.AgeR(), “8 to 13”)==0)
found = 1;
G.Display();
if (found == 0)
cout<<"No such record is found";
Assignment/XII/083/Final Revision/YK
100 ( © Yogesh Kumar)
df.close();
(xiv) void Economic()
ITEMS I;
ifstream fin(“ITEMS.DAT”,ios::binary);
while (fin.read((char *)&I,sizeof(I)))
if(I.GetCost()<2500)
I.See();
fin.close();
(xv) PRESENT RECORD: 3
(xvi) void COSTLY()
GIFTS G;
ifstream fin(“GIFTS.DAT”,ios::binary);
while (fin.read((char *)&G,sizeof(G)))
if(G.GetPrice()>2000)
G.View();
fin.close();
OR Any other correct equivalent function definition
(xvii) PRESENT RECORD: 3
19. RDBMS – Descriptive Questions (i) Union (Binary operator): It operates on two relations and is indiacted by U. For example, R=R1 U R2
represents union operation between two relations R1 and r2. The degree of R is equal to the degree of R1. Following have to be considered for operation R1 U R2.
Degree of R1 = degree of R2
The corresponding attributes of R1 and R2 must have common domains. Example:
Relation: R1 Relation: R2
Student_ID Name Student_ID Name
S001 Adil S101 Mukta
S002 Shabana S102 Naveen
Cartesian product (Binary Operator): It operates on two relations and is denoted by X. Let Cartesian product of two tables R1 and R2 is R (R=R1 X R2). The degree of R is equal to the sum of the degrees of R1 and R2 and cardinality of R is the product of the cardinalities of R1 and R2. Example:
Relation: R1 Relation: R2
Student_ID Name Teacher_ID TName
S001 Adil T101 Mukta
S002 Shabana T102 Naveen
Relation: R1 U R2
Student_ID Name
S001 Adil
S002 Shabana
S101 Mukta
S102 Naveen
Assignment/XII/083/Final Revision/YK
101 ( © Yogesh Kumar)
(ii) A table may have more than one such attribute/group of attributes that identify a row/tuple uniquely.
All such attribute(s)/group(s) are known as Candidate keys. Out of the candidate keys, one is selected as primary key. Example:
Relation: Stock
Ino Item Qty Price
I01 Pen 560 2
I02 Pencil 600 1
I03 CD 200 3
In this relation Ino and Item are Candidate keys. Any one of these can be designated as the Primary key.
(iii) Degree of a table is the number of coulmns (attributes) in It, whereas Cardinality is the number of rows (tuples) in it. Degree of the given table is 3 and its Cardinality is 2.
(iv) Part (i) above (v) A table may have more than one such attribute/group of attributes that identify a row/tuple uniquely.
All such attribute(s)/group(s) are known as Candidate keys. Out of the candidate keys, one is selected as primary key and the other keys are known an alternate keys.
Example: Relation: Stock
Ino Item Qty Price
I01 Pen 560 2
I02 Pencil 600 1
I03 CD 200 3
In this relation Ino and Item are Candidate keys. If Ino is selected as the primary key, then Item will be the alternate key, and vice-versa.
(vi) Candidate keys : Id, Product Primary keys : Id
(vii) Candidate keys : Code, Item Primary keys : Code
20. SQL – Writing queries and finding outputs (i)
a) SELECT * FROM TEACHER WHERE DEPARTMENT = “History”;
b) SELECT NAME FROM TEACHER WHERE DEPARTMENT = “Maths” AND SEX = “F”;
c) SELECT NAME FROM TEACHER ORDER BY DATE_OF_JOIN;
d) SELECT NAME, SALARY, AGE FROM TEACHER WHERE SEX = “M”;
e) SELECT COUNT(*) FROM TEACHER WHERE AGE>23;
(ii)
a) SELECT * FROM STUDENT WHERE DEPARTMENT = “History”;
b) SELECT * FROM STUDENT WHERE DEPARTMENT = “Hindi” AND SEX=’F’;
c) SELECT * FROM STUDENT ORDER BY DATEOFADM;
d) SELECT NAME, FEE, AGE FROM STUDENT WHERE SEX=“M”;
e) SELECT COUNT(*) FROM STUDENT AGE>23;
Relation: R1 X R2
Student_ID Name Teacher_ID TName
S001 Adil T101 Mukta
S002 Shabana T101 Mukta
S001 Adil T102 Naveen
S002 Shabana T102 Naveen
Assignment/XII/083/Final Revision/YK
102 ( © Yogesh Kumar)
(iii) a) SELECT * FROM CLUB WHERE SPORTS = “Swimming”;
b) SELECT Name FROM CLUB ORDER BY date_of_app desc;
c) SELECT COACHNAME, PAY, AGE, PAY*15/100 AS BONUS FROM CLUB;
d) INSERT INTO CLUB VALUES (11, “Neelam”, 35, “Basketyball”, “2000/04/01”,
2200, “F”);
e)
i. 4
ii. 34
(iv) a) SELECT * FROM FURNITURE WHERE TYPE = “Baby cot”; b) SELECT ITEMNAME FROM FURNITURE WHERE PRICE > 15000; c) SELECT ITEMNAME, TYPE FROM FURNITURE WHERE DATEOFSTOCK<”2002/01/22”
ORDER BY ITEMNAME DESC;
d) SELECT ITEMNAME, DATEOFSTOCK FROM FURNITURE WHERE DISCOUNT>25; e) SELECT COUNT(*) FROM FURNITURE WHERE TYPE=”Sofa”; f) INSERT INTO FURNITURE VALUES (14, “Valvet touch”, "Double bed",
“2003/03/03”);
g) (i) 5
(ii) 30
(iii) 18.33
(iv) 65500
(v)
a) SELECT GAMENAME, GCODE FROM GAMES; b) SELECT * FROM GAMES WHERE PRZEMONEY > 7000; c) SELECT * FROM GAMES ORDER BY SCHEDULEDATE; d) SELECT NUMBER, SUM(PRIZEMONEY) FROM GAMES GROUP BY NUMBER;
(e1) 2 4
(e2) MAX(ScheduleDate) MIN(ScheduleDate) ----------------- -----------------
19-Mar-2004 12-Dec-2003
(e3) 59000
(e4) 101 108
103
(vi)
(a) (i) SELECT * FROM WORKER ORDER BY DOB DESC;
(ii) SELECT NAME, DESIG FROM WORKER WHERE PLEVEL IN (“P001”, “P002”); (iii) SELECT * FROM WORKER WHERE DOB BETWEEN “19-JAN-1984” AND “18-JAN-1987”; (iv) INSERT INTO WORKER VALUES
(19, ‘Daya kishore’, ‘Operator’, ‘P003’, ’19-Jun-2008’, ’11-Jul-1984’);
(b) (i)
COUNT(PLEVEL) PLEVEL
1 P001
2 P002
2 P003
(ii)
MAX(DOB)) MIN(DOJ)
Assignment/XII/083/Final Revision/YK
103 ( © Yogesh Kumar)
12-Jul-1987 13-Sep-2004
(iii)
Name Pay
Radhey Shyam 26000
Chander Nath 12000
(iv)
PLEVEL PAY+ALLOWANCE
P003 18000
(vii)
(a) 1) SELECT VehicleName FROM CARHUB WHERE Color = ‘WHITE’; 2) SELECT VehicleName, Make, Capacity FROM CARHUB ORDER BY CAPACITY; 3) SELECT MAX(Charges) FROM CARHUB; 4) SELECT CName, VehicleName, FROM CUSTOMER, CARHUB
WHERE CUSTOMER.Vcode = CARHUB.Vcode; (b)
1)
COUNT(DISTINCT Make)
4
2)
MAX(Charges) MIN(Charges)
35 12
3)
COUNT(*)
5
4)
VehicleName
SX4
C Class
(viii)
a) SELECT * FROM ITEMS ORDER BY INAME;
b) SELECT INAME, PRICE FROM ITEMS WHERE PRICE BETWEEN 10000 AND 22000;
c) SELECT TCODE, COUNT(*) FROM ITEMS GROUP BY TCODE;
d) SELECT PRICE, INAME, QTY FROM ITEMS WHERE QTY > 150;
e) SELECT INAME FROM TRADERS WHERE CITY IN (‘DELHI’, ‘MUMBAI’);
f) SELECT COMPANY, INAME FROM ITEMS ORDER BY COMPANY DESC; g1)
MAX(PRICE) MIN(PRICE)
38000 1200
g2)
AMOUNT
1075000
g3)
DISTINCT TCODE
T01
T02
T03
g4)
INAME TNAME
Assignment/XII/083/Final Revision/YK
104 ( © Yogesh Kumar)
LED SCREEN 40 DISP HOUSE INC
CAR GPS SYSTEM ELECTRONIC SALES
(ix) (a)
1) SELECT IName, price from Item ORDER BY Price;
2) SELECT SNo, SName FROM Store WHERE Area=’CP’;
3) SELECT IName, MIN(Price), MAX(Price) FROM Item GROUP BY IName;
4) SELECT IName, Price, SName FROM Item, Store Where Item.SNo = Store.SNo; (b)
1)
DISTINCT INAME
Hard disk
LCD
Mother Board
2)
Area Count(*)
CP 2
GK II 1
Nehru Place 2
3)
COUNT(DISTINCT AREA)
3
4)
INAME DISCOUNT
Keyboard 25
Mother Board 650
Hard Disk 225
(x)
(i) SELECT Wno,Name,Gender FROM Worker
ORDER BY Wno DESC;
(ii) SELECT Name FROM Worker
WHERE Gender=’FEMALE’;
(iii) SELECT Wno, Name FROM Worker
WHERE DOB BETWEEN ‘19870101’ AND ‘19911201’;
OR SELECT Wno, Name FROM Worker
WHERE DOB >=‘19870101’ AND DOB <=‘19911201’
OR WHERE DOB >=‘19870101’
AND DOB <=‘19911201’)
(iv) SELECT COUNT(*) FROM Worker
WHERE GENDER=’MALE’ AND DOJ > ‘19860101’;
OR SELECT * FROM Worker
WHERE GENDER=’MALE’ AND DOJ > ‘19860101’;
(v)
COUNT(*) DCODE
2 D01
2 D05
(vi)
Assignment/XII/083/Final Revision/YK
105 ( © Yogesh Kumar)
Department
MEDIA
MARKETING
INFRASTRUCTURE
FINANCE
HUMAN RESOURCE
(vii)
NAME DEPARTMENT CITY
George K MEDIA DELHI
Ryma Sen INFRASTRUCTURE MUMBAI
(viii)
MAX(DOJ) MIN(DOB)
2014-06-09 1984-10-19
(xi)
(i) SELECT Eno,Name,Gender FROM Employee ORDER BY Eno;
(ii) SELECT Name FROM Employee WHERE Gender=’MALE’;
(iii) SELECT Eno,Name FROM Employee
WHERE DOB BETWEEN ‘19870101’ AND ‘19911201’;
OR SELECT Eno,Name FROM Employee
WHERE DOB >=‘19870101’ AND DOB <=‘19911201’;
OR SELECT Eno,Name FROM Employee
WHERE DOB >‘19870101’ AND DOB <‘19911201’;
(iv) SELECT count(*) FROM Employee
WHERE GENDER=’FEMALE’ AND DOJ > ‘19860101’;
OR SELECT * FROM Employee
WHERE GENDER=’FEMALE’ AND DOJ > ‘19860101’;
(v) COUNT DCODE
2 D01
2 D05
(vi) Department
INFRASTRUCTURE
MARKETING
MEDIA
FINANCE
HUMAN RESOURCE
(vii) NAME DEPARTMENT
George K INFRASTRUCTURE
Ryma Sen MEDIA
(viii) MAX(DOJ) MIN(DOB)
20140609 19841019
21. Postulates and theorems of Boolean algebra i) Absorption Laws: a) X + X.Y = X
Assignment/XII/083/Final Revision/YK
106 ( © Yogesh Kumar)
b) X . (X + Y) = X
X Y X.Y X+X.Y
0 0 0 0
0 1 0 0
1 0 0 1
1 1 1 1
ii) De Morgan's Laws: a) (X+Y)' = X'.Y'
b) (X.Y)' = X'+Y' Proof: To prove De Morgan's theorem we shall prove that i) (X+Y)+(X'.Y') = 1, ii) (X+Y).(X'.Y') = 0 i) (X+Y)+(X'.Y') = (X+Y+X').(X+Y+Y') (Distributive Law) = (X+X'+Y).(X+Y+Y') (Commutative Law) = (1+Y).(X+1) (Complementation) = 1.1 (Dominance of 1) = 1 .................(1) ii) (X+Y).(X'.Y') = (X'.Y').(X+Y) (Commutative Law) = (X'.Y'.X)+(X'.Y'.Y) (Distributive Law) = (X'.X.Y')+(X'.Y'.Y) (Commutative Law) = (0.Y')+(X'.0) (Complementation) = 0.0 (Dominance of 1) = 0 .................(2) From (1) and (2), we conclude that (X+Y) and (X'.Y') are complements of each other. Therefore, (X+Y)' = (X'.Y') Hence Proved Proof of (b) holds by duality.
iii) Idempotence Laws : a) X . X = X
b) X + X = X Proof: LHS: X . X = (X . X) + 0 (Identity of OR) = (X . X) + (X . X') (Complementation Law) = X . (X + X') (Distributive Law) = X . 1 (Complementation Law) = X (Identity of AND) = RHS Hence Proved Proof of (b) holds by duality.
iv) Principle of Duality : Any identity in Boolean algebra exists in two forms. From one form, the other can be obtained by:
1. replacing each 'AND' sign with 'OR' sign and vice-versa. 2. replacing each '0' with '1' and vice versa. throughout the expression.
v) Distributive Law.
Verification:
A B C B.C A+B.C A+B A+C (A+B).(A+C)
0 0 0 0 0 0 0 0
0 0 1 0 0 0 1 0
Verified: X+X.Y=X
Assignment/XII/083/Final Revision/YK
107 ( © Yogesh Kumar)
0 1 0 0 0 1 0 0
0 1 1 1 1 1 1 1
1 0 0 0 1 1 1 1
1 0 1 0 1 1 1 1
1 1 0 0 1 1 1 1
1 1 1 1 1 1 1 1
22. Proving/Verifying identities of Boolean algebra i)
U V U’ U’+V U.(U’+V) U+V
0 0 1 1 0 0
0 1 1 1 0 1
1 0 0 0 0 1
1 1 0 1 1 1
ii)
X X+0 X’ X+X’
0 0 1 1
1 1 0 1
iii) Proof: RHS: A+A’.C+B.C = (A+A’).(A+C)+B.C = 1.(A+C)+B.C = A+C+B.C = A+C.(1+B) = A+C.1 = A+C =LHS Hence Proved
iv) Proof:
L.H.S
=X + Y’
=X.(Y+Y’)+ (X + X’).Y’
=X.Y + X.Y’ + X.Y’ +X’.Y’
=X.Y + X.Y’ + X’.Y’
=R.H.S
OR
R.H.S
=X.Y + X.Y’ + X’.Y’
=X.(Y + Y’)+ X’.Y’
=X.1 + X’.Y’
=X + X’.Y’
=X + Y’
=L.H.S
Hence Proved
v) Proof: L.H.S
Not Verified
Verified
X+0 = X
Verified
X+X’ = 1
Verified: A+B.C=(A+B).(A+C)
Assignment/XII/083/Final Revision/YK
108 ( © Yogesh Kumar)
=U’+ V
=U’.(V+V’)+ V.(U’+ U)
=U’.V + U’.V’ + U’.V + U.V
=U’.V+U’.V’+U.V
=R.H.S
OR
R.H.S
=U’V’+U’.V +U.V
=U’.(V’+ V)+ U.V
=U’.1 + U.V
=U’+ U.V
=U’+ V
=L.H.S
23. K-Map
(i) (U+W).(V+Z).(U+Z) (ii) (W+Z).(U+W).(U+Z) (iii) (x+y’).(y’+z) (iv) y (v) D+B.C’+A.B+A’B’C (vi) A’.B+A.B’+A’.C OR A’B+A.B’+B’C (vii) W’.Z’+U’.W’+U’.Z’ (viii) P’.Q+P’.S+P’.R+P.Q’.S’ (ix) Q’.S’+P’.S+Q’.R’+P.Q.R (x) C’.D+B.C’+A.D (xi)
OR
Simplified Expression: XY’ + Y’Z’ + XZ’W’ + XZW + X’YZW’
(xii)
Assignment/XII/083/Final Revision/YK
109 ( © Yogesh Kumar)
Simplified Expression: Y’Z’ + X’Y + XZW
24. Logic diagrams (i) x’.y + x.(y’+z’)
= x’y+x.y’+x.z’ = ((x’.y)’.(x.y’)’.(x.z’)’)
(ii) X.Y’+Z
= (X+Z).(Y’+Z) = ((X+Z)’+(Y’+Z)’)
(iii) (x+y)(y+z)(x+z)
= ((x+y)’+(y+z)’+(z+x)’)’
(iv) x.(y’+z)
Assignment/XII/083/Final Revision/YK
110 ( © Yogesh Kumar)
(v)
a. (X+Y’).(X+Z’) b. (U+V’).(U+W’) c. (X’+Y)+(Y.Z’) d. (X.Y’)’+(Z’+W)
(vi)
(vii)
25. Finding expression from given Truth Table
(i) SOP: (P’.Q.R’)+(P’.Q.R)+(P.Q’.R’)+(P.Q.R’) POS: (P+Q+R).(P+Q+R’).(.(P’+Q+R’).(P’+Q’+R’)
(ii) POS: (A+B+C).(A+B’+C’).(A’+B+C’).(A’+B’+C)
(iii) POS: (A+B+C).(A+B’+C’).(A’+B+C).(A’+B+C’)
(iv) POS: (U+V+W’).(U+V’+W’).(U’+V+W’).(U’+V’+W)
(v) F(P,Q,R) = (P’.Q’.R’)+(P’.Q.R)+(P.Q.R’)+(P.Q.R)
(vi) F(A,B,C) = A’B’C’ + A’BC + AB’C’ + ABC OR
F(A,B,C) = Σ(0,3,4,7)
(vii) F(P,Q,R)= (P+Q+R’)(P+Q’+R)(P’+Q+R’)(P’+Q’+R) OR
F(P,Q,R)= Π(1,2,5,6)
26. Communication Technologies – descriptive questions (i) Packet switching: In packet switching, a fixed size of data packet that can be transmitted across the
network is specified and then the data packets are sent through switching stations to the final destinations. All the packets are stored in the main memory instead of disk. As a result accessing time of packets is reduced. Message switching: The source computer sends data (message) to the switching station, which stores data in a buffer. It then looks for a free link to another switching station and sends data to that station. This process continues until data is delivered to the destination computer. This type of switching technique is also known as “store and forward” switching.
(ii)
Bus Topology Star Topology
Slower as compared to Star topology of network
Expensive as compared to Bus topology
Breakage of wire at any point disturbs the entire network.
Long wire length is required.
Assignment/XII/083/Final Revision/YK
111 ( © Yogesh Kumar)
(iii) Voice over Internet Protocol: It is a communication protocol and transmission technology for delivery of voice communications and multimedia sessions over Internet Protocol (IP) networks, such as the Internet. Also, we can say, VoIP are IP telephony, Internet Telephony, Internet telephony and broadband telephony.
(iv) JavaScript and VBScript are client side scripts. JSP and ASP are server side scripts.
(v) (b) and (c) (vi) VoIP (vii) Client Side Scripting Language: JavaScript (OR VBScript)
Server Side Scripting Language: JSP (OR ASP) (viii) a. Stealing a mouse from someone’s computer. (ix) Independent line of connection allows freedom of removing or adding nodes from the network.
(x) URL: http://cbseacademic.in/results.html Domain Name: cbseacademic.in
(xi) Domain Name: It is the unique name that identifies an Internet site IP Address: It is the unique address for each computer on a network
(xii) 1) Optical Fiber can carry data without any loss 2) Optical fiber can carry data at the speed of light
(xiii) (b) and (c) (xiv) 2G: Better voice service, Speed around 64kbps
3G: Improved data services with multimedia, Speed around 2Mbps (xv) Video Conferencing: It is a conference between two or more participants at different locations in real
time over the Internet or a private network using video camera, microphone and speakers. Chat: It is an application to communicate with a person, a group, or a site on the Internet in real time by typing text.
(xvi) GPRS: General packet Radio service CDMA: Code Division Multiple Access
(xvii) PAN (xviii) 1) Broad network access (e.g, mobile phones, tablets, laptops, and workstations)
2) Resource pooling
(xix) Bus topology
Star Topology
OR any valid illustration of Bus and Star Topology.
(xx) Spam is the abuse of electronic messaging systems (including most broadcast media, digital delivery systems) to send unsolicited bulk messages indiscriminately.
Assignment/XII/083/Final Revision/YK
112 ( © Yogesh Kumar)
(xxi) FTP is a protocol to transfer files over the Internet, whereas HTTP is a protocol which allows the use of
HTML to browse web pages in the World Wide Web.
(xxii) (i) Wired – Optical Fiber (ii) Wireless ‐ Infrared OR Microwave
(xxiii) A worm is a self‐replicating computer program. It uses a network to send copies of itself to other
computers on the network and it may do so without any user intervention. Most of the common anti‐virus(anti‐worm) remove worm.
(xxiv) (ii) & (iii) (xxv) When a Website with cookie capabilities is visited, its server sends certain information about the
browser, which is stored in the hard drive as a text file. It's a way for the server to remember things about the visited sites.
(xxvi) Packet Switching follows store and forward principle for fixed packets. Fixes an upper limit for packet
size. Message Switching follows store and forward principle for complete message. No limit on block size.
(xxvii) A Trojan Horse is a code hidden in a program, that looks safe but has hidden side effects typically
causing loss or theft of data, and possible system harm.
(xxviii) (ii) & (iii)
27. Network Setup (i) a) HR Center as it has the maximum number of computers.
b)
c) Switch d) WAN as the given distance is more than the range of LAN and MAN.
(ii)
a) Building “Jamuna” as it contains the maximum number of computers. b)
c)
(i) Switch is needed to be placed in each building to interconnect the computers within that building. (ii) Repeater is needed to be placed between “Jamuna” and “Ravi” as the distance is more than 90m.
d) Optical Fibre cable
Assignment/XII/083/Final Revision/YK
113 ( © Yogesh Kumar)
(iii) a) Faculty Studio as it contains the maximum number of computers. b)
c) LAN d) Satellite
(iv) a) Finance b)
c) Satellite Link d) Switch
(v)
(i) ADMIN (due to maximum number of computers) OR MEDIA (due to shorter distance from the other buildings)
(ii) Any one of the following
(iii) Firewall OR Router
(iv) Video Conferencing (vi)
(i) ADMIN (due to maximum number of computers) OR ARTS (due to shorter distance from the other buildings)
(ii) Any one of the following
Assignment/XII/083/Final Revision/YK
114 ( © Yogesh Kumar)
(iii) Firewall OR Router
(iv) Video Conferencing