Escolar Documentos
Profissional Documentos
Cultura Documentos
CLASS – XII
OLD QUESTIONS & ANSWERS
Data Structures
C++
D
Ddat
Structured Query Language
Boolean Algebra
Communication concepts
Network concepts
G
C
T
S)
(P
ar
m
Ku
Prepared By:
er
nd
VIRENDER KUMAR
re
Vi
XII Computer
1
XII COMPUTER SCIENCE
CBSE Board - 2013
1|Page
Important Note:
- All the desired header files are already included in the code, which are required to run the code.
void main()
{
char *Text=”AJANTA”; int
*P, Num[]={1,5,7,9};
P=Num;
cout<<*P<<Text<<endl;
Text++;
P++;
cout<<*P<<Text<<endl;
}
Ans. Output:
1AJANTA
5JANTA
(e) Observe the following C++ code carefully and obtain the output, which will appear on the screen after 3
execution of it.
#include<iostream.h>
class Mausam
{
int City,Temp,Humidity;
public:
Mausam(int C=1) {City=C; Temp=10; Humidity=63;}
void Sun(int T) {Temp+=T;}
void Rain(int H) { Humidity+=H;}
void CheckOut()
{
cout<<City<<":"<<Temp<<"&"<<Humidity<<"%"<<endl;
}
};
void main()
{
Mausam M,N(2);
M.Sun(5);
M.CheckOut();
N.Rain(10);
N.Sun(2);
N.CheckOut();
M.Rain(15);
M.CheckOut();
}
Ans. Output:
1:15&63%
2:12&73%
1:15&78%
(f) Based on the following C++ code find out the expected correct output(s) from the option (i) to(iv). Also, find 2
out the minimum and the maximum value that can be assigned to the variable Guess used in the code at the
time when value of Turn is 3.
void main()
{
char Result[][10]={"GOLD","SILVER","BRONZE"};
2|Page
int Getit=9,Guess;
for(int Turn=1;Turn<4;Turn++)
{
Guess=random(Turn);
cout<<Getit-Guess<<Result[Guess]<<"*";
}
}
(i) 9GOLD*9GOLD*8SILVER*
(ii) 9GOLD*7BRONZE*8GOLD*
(iii) 9GOLD*8SILVER*9GOLD*
(iv) 9GOLD*8SILVER*8GOLD*
Ans. Correct answer is 9GOLD*9GOLD*8SILVER*
2. (a) Write any two similarities between Constructor and Destructor. Write the function headers for constructor and 2
destructor of a class Flight.
Ans. Similarities:
Constructors and destructors do not have return type, not even void nor can they return values.
References and pointers cannot be used on constructors and destructors because their addresses cannot be
taken.
For example:
class Flight
{
public:
Flight(); // Constructor for class Flight
~Flight(); // Destructor for class Flight
};
(b) Answer the questions (i) and (ii) after going through the following class: 2
class Race
{
int CarNo, Track;
public:
Race(); // Function 1
Race(int CN); // Function 2
Race(Race &R); // Function 3
void Register(); // Function 4
void Drive(); // Function 5
};
void main()
{
Race R;
:
}
(i) Out of the following, which of the option is correct for calling Function 2?
Option 1-Race T(30);
Option 2-Race U(R);
(ii) Name the feature of Object Oriented Programming, which is illustrated by Function 1, Function 2 and
Function 3 combined together.
Ans. (i) Option-1 Race T (30) is correct.
(ii) Constructor overloading.
3|Page
(c) Define a class Bus in C++ with the following specifications: 4
Data Members
Busno - to store Bus No
From – to store Place name of origin
To – to store Place name of destination
Type – to store Bus Type such as ‘O’ for ordinary
Distance – to store the Distance in Kilometers
Fare –to store the Bus Fare
Member Functions
A constructor function to initialize Type as ‘O’ and Freight as 500
A function CalcFare() to calculate Fare as per the following criteria:
Type Fare
‘O’ 15*Distance
‘E’ 20*Distance
‘L’ 24*Distance
A function Allocate() to allow user to enter values for Busno, From, To, Type and Distance. Also,
this function should call CalcFare() to calculate Fare.
A function Show() to display the content of all the data members on screen.
Ans. #include <iostream.h>
#include <conio.h>
class Bus
{
private:
char From[20],To[20];
int fare,busno,distance;
char Type;
public:
Bus ( );//Constructor
~Bus( );//Destructor
int CalcFare();
void Allocate();
void Show();
};
Bus :: Bus( )
{
fare=500;
Type='O';
}
void Bus :: Allocate( )
{
cout<<"Enter the Bus no: ";
cin>>busno;
cout<<"\nFrom: ";
cin>>From;
cout<<"\nTo: ";
cin>>To;
cout<<" \nEnter the Type: ";
cin>>Type;
cout<<"\nEnter the distance: ";
cin>>distance;
CalcFare();
4|Page
}
int Bus:: CalcFare( )
{
if(Type=='O')
{
fare=15*distance;
}
else if(Type=='E')
{
fare=20*distance;
}
else if(Type=='L')
{
fare=24*distance;
}
else
cout<<"Wrong Type";
return fare;
}
void Bus :: Show()
{
cout<<"\n\n****Your Booking Detail***"<<endl;
cout<<"Bus no: "<<busno<<endl;
cout<<"From: "<<From<<endl;
cout<<"To: "<<To<<endl;
cout<<"Type: "<<Type<<endl;
cout<<"Distance: "<<distance<<endl;
cout<<"Total Fare: "<<fare<<endl;
}
Bus :: ~Bus( )
{
cout<<"Bus Detail is Closed";
}
void main( )
{
Bus s;
clrscr();
s.Allocate();
s.Show();
getch( );
}
(d) Consider the following c++ code and answer the questions from (i) to (iv): 4
class Personal
{
int Class,Rno;
char Section;
protected:
char Name[20];
public:
personal(); void
pentry();
void Pdisplay();
};
class Marks: private Personal
{
5|Page
float M[5];
protected:
char Grade[5];
public:
Marks();
void Mentry();
void Mdisplay();
};
class Result: public Marks
{
float Total, Agg;
public:
char FinalGrade, comments[20];
Result();
void Rcalculate();
void Rdisplay();
};
(i) Which type of inheritance is shown in the above example?
(ii) Write the names of those data members, which can be directly accessed from the objects of
class Result.
(iii) Write the names of those member functions which can be directly accessed from the objects
of class Result.
(iv) Write names of those data members, which can be directly accessed from the Mentry()
function of class Marks.
Ans. (i) Multilevel Inheritance
(ii) FinalGrade, comments
(iii) Rcalculate(), Rdisplay(), Mentry(), Mdisplay();
(iv) Name[20], M[5], Grade[5]
3.(a) Write code for a function void ChangOver (int P[],int N) in C++, which re-positions all the elements of the array by 3
shifting each of them to the next position and by shifting the last element to the first position.
For example:If the content of array is
0 1 2 3 4
12 15 17 13 21
6|Page
+ 55
(e) Write a function QDELETE() in C++ to perform delete operation on a Linked Queue, which contains Passenger 4
no and Passenger name. Consider the following definition of node in the code.
struct node
{
long int Pno;
char Pname[20];
node *Link;
};
Ans. class Queue
{
NODE *front, *rear;
Queue() {front=NULL; rear=NULL;}
public:
void Addq();
void Delete();
};
void Queue::Delete()
{
if(front==NULL)
cout<<”Queue is empty”;
else
{
NODE *t = front;
front = front->Link;
if(front==NULL)
rear = NULL;
delete t;
}
}
4 (a) Fill in the blanks marked as Statement 1 and Statement 2, in the program segment given below with 1
appropriate functions for the required task.
class Club
{
long int MNo; // Member Number
char MName[20]; // Member Name
char Email[30]; //Email of Member
public:
void Register(); // Function to register member
void Disp(); // Function to display details
void ChangeEmail() // Function to change Email
{
cout<<"Enter Changed Email:";
cin>>Email;
}
long int GetMno() { return MNo;}
};
void ModifyData()
{
fstream File;
File.open("CLUB.DAT",ios::binary|ios::in|ios::out);
int Modify=0,Position;
long int ModiMno;
8|Page
cout<<"Mno - whose email required to be modified:";
cin>>ModiMno;
Club CL;
while(!Modify && File.read((char*)&CL,sizeof(CL)))
{
if(CL.GetMno()==ModiMno)
{
CL.ChangeEmail();
Position=File.tellg()-sizeof(CL);
//Statement 1: To place file pointer to the required position
____________________________________;
9|Page
cout<<"Count for me:"<<C2;
Fil.close();
}
(c) Assuming the class ANTIQUE as declared below, write a function in C++ to read the objects of ANTIQUE 3
from binary file ANTIQUE.DAT and display those antique items, which are priced between 10000 and
15000.
class ANTIQUE
{
int ANO;
char Aname[10];
float Price;
public:
void BUY() { cin>>ANO;gets(Aname);cin>>price;}
void SHOW()
{
cout<<ANO<<endl;
cout<<Aname<<endl;
cout<<Price<<endl;
}
float GetPrice() { return Price;}
};
Ans void search(float pr)
{
Ifstream ifile(“ANTIQUE.DAT”, ios::in | ios::binary);
if(!ifile)
{
cout<<”could not open ANTIQUE.DAT file “; exit(-1); }
else
{
ANTIQUE a; int found=0;
while(ifile.read((char *)&a, sizeof(a)))
{
Pr=a.GetPrice();
if(pr>=10000 && pr<=15000)
{
a.SHOW(); found=1; break;
}
}
}
if(found==0)
cout<<”given price not match”;
}
5 (a) Explain the concept of candidate keys with the help of an appropriate example. 2
Note:
Write SQL queries for (b) to (g) and write the outputs for the SQL queries mentioned shown in (h1) to
(h4) parts on the basis of tables PRODUCTS and SUPPLIERS
Table: PRODUCTS
PID PNAME QTY PRICE COMPANY SUPCODE
101 DIGITAL CAMERA 14X 120 12000 RENIX S01
102 DIGITAL PAD 11i 100 22000 DIGI POP S02
104 PEN DRIVE 16 GB 500 1100 STOREKING S01
106 LED SCREEN 32 70 28000 DISPEXPERTS S02
105 CAR GPS SYSTEM 60 12000 MOVEON S03
Table: SUPPLIERS
Page 10 of 14
SUPCODE SNAME CITY
S01 GET ALL INC KOLKATA
S03 EASY MARKET CORP DELHI
S02 DIGI BUSY GROUP CHENNAI
Ans. A table may have more than one such attribute/group of attribute that identifies a tuple uniquely, all such
attribute(s) are known as Candidate Keys.
Candidate Key
(b) To display the details of all the products in ascending order of product names (i.e. PNAME). 1
Ans SELECT * FROM PRODUCTS ORDER BY PNAME;
(c) To display product name and price of all those products, whose price is in the range of 10000 and 15000 1
(both value inclusive).
Ans: select PNAME,PRICE FROM PRODUCTS WHERE PRICE>=10000 && PRICE<=15000;
(d) To display the number of products, which are supplied supplier. i.e., the expected output should be: 1
S01 2
S02 2
S03 1
Ans. SELECT SUPCODE, COUNT(SUPCODE) FROM PRODUCTS GROUP BY SUPCODE;
(e) To display the price, product name and quantity (i.e., qty) of those products which have quantity more 1
than 100.
Ans. SELECT PRICE,PNAME,QTY FROM PRODUCTS WHERE QTY>100;
(f) To display the names of those suppliers, who are either from DELHI or from CHENNAI. 1
Ans: SELECT SNAME FROM SUPPLIERS WHERE CITY="DELHI" || CITY="KOLKATA";
(g) To display the name of the companies and the name of the products in descending order of company 1
names.
Ans: SELECT COMPANY,PNAME FROM PRODUCTS ORDER BY COMPANY DESC;
(h) Obtain the outputs of the following SQL, queries based on the data given in tables PRODUCTS and 2
SUPPLIERS above.
(h1) SELECT DISTINCT SUPCODE FROM PRODUCTS;
(h2) SELECT MAX(PRICE), MIN(PRICE) FROM PRODUCTS;
(h3) SELECT PRICE*QTY AMOUNT FROM PRODUCTS WHERE PID=104;
(h4) SELECT PNAME,SNAME FROM PRODUCTS P, SUPPLIERS S WHERE P.SUPCODE=S.SUPCODE AND
QTY>100;
Ans: (h1) SUPCODE
Page 11 of 14
S01
S02
S03
(h2)
MAX(PRICE) MIN(PRICE)
28000 1100
(h3) AMOUNT
55000
(h4)
PNAME SNAME
DIGITAL CAMERA 14X GET ALL INC
PEN DRIVE 16GB GET ALL INC
IMPORTANT NOTE: This question was wrong in board paper expected question may this X+Z=X+Y'.Z+Yy.Z
Ans. x+z=x+y'.z+y.z
RHS=x+y'.z+y.z
=x+z(y'+y) (y'+y=1 Complementarity law)
=x+z(1)
=x+z
=LHS
(b) Obtain the Boolean Expression for the logic circuit shown below: 2
Ans. The equivalent Boolean expression for the given Logic Circuit is: F = P’Q + (Q + R’)
(c) Write the Sum of Product form of the function F(A, B, C) for the following truth table representation of F. 1
A B C F
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 0
1 1 1 1
Ans. Add a new column containing minterms. Now the table is as follows :
A B C F minterms
0 0 0 0 A’B’C’
0 0 1 0 A’B’C
0 1 0 1 A’BC’
0 1 1 1 A’BC
Page 12 of 14
1 0 0 1 AB’C’
1 0 1 0 AB’C
1 1 0 0 ABC’
1 1 1 1 ABC
Now by adding all the minterms for which output is 1, we get desired sum-of-products expression which is
F(A,B,C) = A’BC’ + A’BC + AB’C’ + ABC
(d) Obtain the minimal form for the following Boolean expression using Karnaugh map. 3
F(U, V, W, Z) = ∑(0, 1, 2, 3, 6, 7, 8, 9, 10, 13, 15)
Ans. There are four pairs and one quad that reduce as given below:
Pair-1(m7 + m6) reduces to U’VW
Pair-2(m8 + m9) reduces to UV’W’
Pair-3(m13 + m15) reduces to UVZ
Pair-4(m8 + m10) reduces to UV’Z’
Quad (m0 + m1 + m2 + m3) reduces to U’V’
Simplified Boolean expression for given K-map is
F(U,V,W,Z) = U’VW + A’C’O + UVZ + UV’Z’ + U’V’
7. (a) Write two advantages of using an optical fiber cable over an Ethernet cable to connect two service stations, 1
which are 200 m away from each other.
Ans. Optical fiber cable guarantees secure transmission and a very high transmission capacity.
Optical fiber cable is immune to electrical and magnetic interference.
(b) What is the different between HTTP and FTP? 1
Ans. FTP, is a protocol used to upload files from a workstation to a FTP server or download files from a FTP server to
a workstation whereas, HTTP, is a protocol used to transfer files from a Web server onto a browser in order to
view a Web page that is on the Internet.
Rovenza Communication International (RCI) is an online corporate training provider company for IT related courses.
The company is setting up their new campus in Kolkata. You as a network expert have to study the physical locations
of various blocks and the number of computers to be installed. In the planning phase, provider the best possible
answer for the queries (i) to (iv) raised by them.
Page 13 of 14
Block Computers
Administrative Block 30
Finance Block 20
Faculty Recording Block 100
(i) Suggest the most appropriate block, where RCI should plan to install the server.
(ii) Suggest the most appropriate block to block cable layout to connect all three blocks for efficient
communication.
(iii) Which type of network out of the following is formed by connecting the computers of these
three blocks?
LAN
MAN
Wam
(iv) Which wireless channel out of the following should be opted by RCI to connect to students from
all over the world?
Infrared
Microwave
Satellite
Ans. (i) Faculty recording block
(i)
(ii) LAN
(iii) Satellite
(d) Write two advantages of using open source software over proprietary software. 1
Ans. Open Source Software is software whose source code is available to customer and it can be modified and
redistributed without any limitations whereas source code of proprietary Software is not available.
Open Source Software may come free of cost or with a payment of normal charges whereas proprietary
software is neither open nor freely available.
(e) Which of the following crime(s) does not come under cybercrime? 1
(i) Copying some important data from a computer without taking permission from the owner of the
data.
(ii) Stealing keyboard and mouse from a shop.
(iii) Getting into unknown person’s social networking account and start messaging on his behalf.
Ans. (i) Stealing keyboard and mouse from a shop.
Page 14 of 14
XII COMPUTER SCIENCE
CBSE Board - 2012
3|Page
return a+b ; i=35;
} j=45;
void main( ) //both i & j are accessible here
{ cout<<"Value of i "<<i;
Example ex; cout<<"Value of j "<<j;
ex.a = 10; // OK: because a is }
public };
ex.b = 20; // Error: because b is void main()
private {
int sum=ex.add(); // local ExDerived exd;
variable exd.show();
cout << "Sum of a + b : " << //both I and j are not accessible
} exd.i=50;
Output: Error due to access of exd.j=60;
private member }
(b) Answer the question (i) and (ii) after going through the following class : 2
class Travel
{
int PlaceCode; char Place[20]; float Charges;
public:
Travel( ) //Function 1
{
PlaceCode=1;strcpy(Place,”DELHI”);Charges=1000;
}
void TravelPlan(float C ) // Function 2
{
cout<<PlaceCode<<“:”<<Place<<”:”<<Charges<<endl;
}
~Travel( ) // Function 3
{
cout<<”Travel Plan Cancelled”<<endl;
}
Travel(int PC,char p[],float C) // Function 4
{
PlaceCode=PC;strcpy(Place,P);Charges=c;
}
};
i) In Object Oriented Programming, what are Function 1 and Function 4 combined together referred as?
ii) In Object Oriented Programming, which concept is illustrated by Function 3? When is this function
called/invoked?
Ans. (i) Polymorphism OR Constructor Overloading
(ii) Function 3: Destructor
A destructor called/invoked when an object of that class is destroyed. When a variable goes out of scope,
or a dynamically allocated variable is explicitly deleted using the delete keyword, the class destructor is
called to help clean up the class before it is removed from memory.
(c) Define a class RESTRA in C++ with following description: 4
Private Members:
FoodCode of type int
Food of type string
FType of type string
Sticker of type string
A member function GetSticker() to assign the following values for Sticker as per the given Ftype:
4|Page
FType Sticker
Vegetarian GREEN
Contains Egg YELLOW
Non-Vegetarian RED
Public Members :
A function GetFood() to allow user to enter values for FoodCode, Food,Ftype and call function
GetSticker() to assign Sticker.
A function ShowFood() to allow user to view the concept of all the data members.
Ans. class RESTRA
{
int FoodCode;
char Food[20];
char FType[20];
char Sticker[20];
void GetSticker();
public:
void GetFood();
void ShowFood();
};
void RESTRA::GetFood()
{
cin>>FoodCode;
cin>>Food;
cin>>FType;
GetSticker ();
}
void RESTRA:: GetSticker ()
{
if (strcmp(FType,"Vegetarian"))
strcpy(Sticker,"GREEN");
else if (strcmp(FType,"Contains Egg"))
strcpy(Sticker,"YELLOW");
else if(strcmp(FType,"Non-Vegetarian"))
strcpy(Sticker,"RED");
}
void RESTRA:: ShowFood ()
{
cout<< FoodCode <<'\t'<<Food<<'\t'<<FType<<'\t'<<Sticker<<endl;
}
(d) Answer the questions (i) to (iv) based on the following: 4
class COMPANY
{
char Location[20];
double Budget,Income;
protected:
void Accounts( );
public:
COMPANY();
void Register( );
void Show( );
};
class FACTORY: public COMPANY
{
5|Page
char Location[20];
int Workers;
protected:
double Salary;
void Computer();
public:
FACTORY();
void Enter( );
void show( );
};
class SHOP: private COMPANY
{
char Location[20];
float Area;
double Sale;
public:
SHOP();
void Input();
void Output();
};
(i) Name the type of inheritance illustrated in the above C++ code.
(ii) Write the names of data members, which are accessible from member functions of class SHOP.
(iii) Write the names of all the member functions, which are accessible from objects belonging to class
FACTORY.
(iv) Write the names of all the members, which are accessible from objects of class SHOP.
Ans. (i) Hierarchical Inheritance
(ii) None of the data members can be accessible except SHOP class data members.
(iii) Register( ),Enter( ) and Show( ) of Factory class.
(iv) Input( ), Output( )
3. ( a ) Write a function SWAP2BEST (int ARR[],int Size) in C++ to modify the content of the array in such a way that the 3
elements, which are multiples of 10 swap with the value present in the very next position in the array.
For example:
If the content of array ARR is
90,56,45,20,34,54
The content of array ARR should become
56,90,45,34,20,54
Ans. #include <iostream.h>
#include <conio.h>
void SWAP2BEST(int ARR[], int Size);
int main ()
{
//Here we are taking different values for more perfect result with more
//numbers of array elements. You can change the values and number of array
//elements as per your choice.
int ListofNum[8] = {6, 28, 30, 17, 50, 45, 80, 82};
clrscr();
SWAP2BEST(ListofNum, 8 ) ;
return 0;
}
void SWAP2BEST(int ARR[], int Size)
{
int i= 0;
int temp=0;
6|Page
for (i = 0; i < Size; ++i)//loop for printing original array values
{
cout<<ARR[i]<<" ";
}
cout<<endl;
for (i = 0; i < Size; ++i)
{
if(ARR[i+1]=='\0')
{
}
else
{
if(ARR[i+1]%10==0)
{
temp=ARR[i];
ARR[i]=ARR[i+1];
ARR[i+1]=temp;
}
}
}
for (i = 0; i < Size; ++i) //loop for printing swapped array value
{
cout<<ARR[i]<<" ";
}
}
(b) An array T[20][10] is stored in the memory along the column with each of the element occupying 2 bytes, find 3
out the memory location of T[10][5], if an element T[2][9] is stored at location 7600.
Ans. AssumingLBR=LBC=0
B=7600
W=2 bytes
Number of Rows(N)=20
Numberof Columns(M)=10
LOC(Arr[I] [J]) = B +(I + J*N)*W
LOC(T[10][5]) = 7600+(10+5*20)*2
= 7600 + (300*2)
= 7600 + 600
= 8200
(c) Write a function in C++ to perform insert operation in a static circular Queue containing Book’s information 4
(represented with the help of an array of structure BOOK).
struct BOOK
{
long Accno; // Book Accession Number
char Title[20]; // Book Title
};
Ans. Student try to answer this question
(d) Write a function ALTERNATE (int A[][3],int N,int M) in C++ to display all alternate element 2
from two-dimensional array A (starting from A[0][0]).
For example:
If the array is containing:
23 54 76
7|Page
37 19 28
62 13 19
The output will be:
23 76 19 62 19
Ans. #include <iostream.h>
#include <conio.h>
void process_Array(int Arr[][3],int x, int y);
void process_Array(int A[][3],int N, int M)
{
clrscr();
for (int R = 0; R < N; R++)
{
if(R%2==0)
{
for (int C = 0; C < M; C=C+2)
{
cout<< A[R][C]<<" ";
}
}
else
{
for (int C = 1; C < M;C=C+2)
{
cout<< A[R][C]<<" ";
}
}
}
cout<<endl;
cout<<endl;
for (int I = 0; I < N; I++)
{
for (int J = 0; J < M; J++)
{
cout << A[I][J]<<" ";
}
cout<<endl;
}
}
int main ()
{
int arr[3][3] ={{23, 54, 76},
{37, 19, 28},
{62, 13, 19},
};
process_Array(arr,3,3);
return 0;
}
(e) Evaluate the following POSTFIX notation. Show status of stack after every step of evaluation (i.e. after each 2
operator):
True,False,NOT,AND,False,True,OR,AND
Ans. Student try to answer this question
4 (a) Observe the program segment given below carefully and the question that follow: 1
class Stock
8|Page
{
int Ino,Qty; char Item[20];
public:
void Enter() {cin>>In0;gets(Item); cin>>Qty;}
void Issue(int Q) { Qty+=Q}
void Purchase(int Q) { Qty-=Q}
int GetIno(return Ino;}
};
void Purchaseitem(int Pino, int PQty)
{
fstream file;
File.open(“STOCK.DAT”,ios::binary|ios::in|ios::out);
Stock S;
int Success=0;
while (Success==0 && File.read((char*)&S, sizeof(S)))
{
if (Pino==S.GetIno())
{
S.Purchase(PQty);
File.seekp(Success); //Statement 1
File.write((char*) &S, sizeof(S)); //statement 2
Success++;
}
}
if (Success==1)
cout<<“Purchase Updated”<<endl;
else
cout<<”Wrong Item 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 item.
(ii) Write statement 2 to perform the write operation so that the updation is done in the binary file.
Ans. Statement 1 - File.seekp(Success);
Statement 2 - File.write((char*) &S, sizeof(S));
(b) Write a function in C++ to read the content of a text file “DELHI.TXT” and display all those lines on screen, 2
which are either starting with ‘D’ or starting with ‘M’.
Ans. #include<fstream.h>
#include<conio.h>
int main()
{
ifstream fin;
fin.open("out.txt");
char str[80]; int count=0;
clrscr();
while(!fin.eof())
{
fin.getline(str,80);
if(str[0]=='D' || str[0]=='M')
{
cout<<str<<endl;
}
count++;
}
9|Page
cout<<"Number of lines in file is "<<count;
fin.close();
getch();
return 0;
}
(c) Write a function in C++ to search for the details (Phoneno and Calls) of those Phones, which have more 3
than 800 calls from a binary file “phones.dat”. Assuming that this binary file contains records/objects of
class Phone, which is defined below.
class Phone
{
char Phoneno[10]; int Calls;
public:
void Get( ) { gets(Phoneno); cin>>Calls; }
void Billing( ) { cout<<Phoneno<<”#”<<Calls<<endl; }
int GetCalls( )
{
return Calls;
}
};
(Ans) void search ()
{
Phone pObj;
ifstream ifs;
ifs.open("phones.dat",ios::binary);
while(ifs.read((char*)&pObj,sizeof(pObj)))
{
if(pObj.GetCalls()>=800)
pObj.Billing();
}
ifs.close();
}
5 (a) Give a suitable example of a table with sample data and illustrate Primary and Alternate Keys in it. 2
Ans. Primary Key: Primary key is a set of one or more fields/columns of a table that uniquely identify a record in
database table. It cannot accept null, duplicate values. Only one Candidate Key can be Primary Key.
Alternate key: Alternate key is a key that can be work as a primary key. Basically it is a candidate key that
currently is not primary key.
Example: In below table AdmissionNo becomes Alternate Keys when we define RegistrationNo as Primary Key.
Student Registration Table:
RegistrationNo AdmissionNo Name Phone Gender DOB
CBSE4554 215647 Mihir Ranjan 9568452325 Male 1992-04-15
CBSE6985 265894 Amita Guha 8456985445 Female 1993-03-24
CBSE5668 458961 Rajesh Singh 9654212440 Male 1992-12-04
CBSE3654 469799 Mohit Patel 7421589652 Male 1992-05-16
Primary Key – Registration Number
Alternate Key –Admission No
Consider the following tables CARDEN and CUSTOMER and answer (b) and (c) parts of question:
TABLE: CARDEN
Ccode CarName Make Color Capacity Charges
501 A-Star Suzuki RED 3 14
503 Indigo Tata SILVER 3 12
502 Innova Toyota WHITE 7 15
509 SX4 Suzuki SILVER 4 14
10 | P a g e
510 C Class Mercedes RED 4 35
TABLE: CUSTOMER
CCode Cname Ccode
1001 Hemant Sahu 501
1002 Raj Lal 509
1002 Feroza Shah 503
1004 Ketan Dhal 502
Write SQL commands for the following statements: 4
(b) (i) To display the names of all the silver colored Cars.
(ii) To display name of car, make and capacity of cars in descending order of their sitting capacity.
(iii) To display the highest charges at which a vehicle can be hired from CARDEN.
(iv) To display the customer name and the corresponding name of the cars hired by them.
Ans. (i) SELECT CarName FROM carden WHERE Color LIKE 'Silver';
(ii) SELECT CarName,Make,Capacity FROM carden ORDER BY Capacity;
(iii) SELECT MAX(Charges) FROM carden;
(iv) SELECT Cname,CarName FROM carden,customer WHERE
carden.Ccode=customer.Ccode;
(c) Give the output of the following SQL queries: 2
(i) SELECT COUNT(DISTINCT Make) FROM CARDEN;
(ii) SELECT MAX(Charges),MIN(Charges) FROM CARDEN;
(iii) SELECT COUNT(*),Make FROM CARDEN;
(iv) SELECT CarName FROM CARDEN WHERE Capacity=4;
Ans. (i) COUNT(DISTINCT Make)
4
(ii) MAX(Charges)
MIN(Charges) 35 12
(iii) COUNT(*) Make
5 Suzuki
(iv) CarName
SX4
C Class
6 (a) Verify the following using truth table: 2
(i) X.X’=0
(ii) X+1=1
Ans.
X X’ X.X’ X+1
0 1 0 1
0 1 0 1
1 0 0 1
1 0 0 1
(b) Write the equivalent Boolean Expression for the following Logic Circuit: 2
11 | P a g e
X Y Z F
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
12 | P a g e
Ans. Easy to extend
In star topology, 4 computers can be connected with each other through a server.
(e) Workalot consultants are setting up a secured network for their office campus at Gurgaon for their day-to-day 4
office and web-based activities. They are planning to have connectivity between 3 buildings and the head office
situated in Mumbai. Answer the questions (i) to(iv) after going through the building positions in the campus
and other details, which are given below:
(i) Suggest the most suitable place (i.e. building) to house the server of this organization. Also give a reason
to justify your suggested location.
(ii) Suggest a cable layout of connection between the buildings inside the campus.
(iii) Suggest the placement of the following device with justification:
(1) Switch
(2) Repeater
(iv) The organization is planning to provide a high speed link with its head office situated in MUMBAI using a
wired connection. Which of the following cables will be most suitable for this job?
(1) Optical Fiber
(2) Co-axial Cable
(3) Ethernet Cable
13 | P a g e
Ans. RED building because maximum number of computers are there
(ei) OR
BLUE building because closest to all other building (minimum cable length required)
Ans.
(eii) Gurgaon Campus
Building
“GREEN”
Building Building
“BLUE” “RED”
Ans. Switch. By using 1 switch per building we can use maximum numbers of computers to connect them in
(eiii) network.
Ans. Optical Fiber
(eiv)
(f) Give one suitable example of each URL and Domain Name. 1
Ans. URL - http://www.cbsecsnip.in/index.php
Domain - cbsecsnip
(g) Name two Proprietary software along with their application. 1
Ans. (i) Microsoft Office – Microsoft Office belongs to Microsoft Corporation. This software is used for office
automation and also can be used other than office productivity at personal level. Microsoft Office contains
following other applications like Microsoft Word, Microsoft Excel, Microsoft PowerPoint, etc.
(ii) Oracle – Oracle Corporation is the owner of Oracle software. Oracle is one of most popular RDBMS
software in world.
14 | P a g e
COMPUTER SCIENCE
Sample Paper – I
1.
(a) What is the difference between Object Oriented Programming and Procedural
Programming? 2
(b) Write the names of the header files to which the following belong: 1
(i) frexp() (ii) isalnum()
(c) Rewrite the following program after removing the syntactical errors (if any). Underline
each correction. 2
#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);
}
1
#include <iostream.h>
struct Game
{
char Magic[20];int Score;
};
void main()
{
Game M={“Tiger”,500};
char *Choice;
Choice=M.Magic;
Choice[4]=’P’;
Choice[2]=’L’;
M.Score+=50;
cout<<M.Magic<<M.Score<<endl;
Game N=M;
N.Magic[0]=’A’;N.Magic[3]=’J’;
N.Score-=120;
cout<<N.Magic<<N.Score<<endl;
}
(f) In the following program, if the value of N given by the user is 20, what maximum and
minimum values the program could possibly display? 2
#include <iostream.h>
#include <stdlib.h>
void main()
{
int N,Guessnum;
randomize();
cin>>N;
Guessnum=random(N-10)+10;
cout<<Guessnum<<endl;
}
2.
(a) What do you understand by Polymorphism? Give a suitable example of the same. 2
(b) Answer the questions (i) and (ii) after going through the following program: 2
class Match
{
int Time;
public:
Match() //Function 1
{
Time=0;
cout<<”Match commences”<<end1;
}
void Details() //Function 2
{
cout<<”Inter Section Basketball Match”<<end1;
}
2
Match(Match &M) //Function 4
{
Time=M.Duration;
cout<<”Like Previous Match ”<<end1;
}
};
ii) Write statements that would call the member Functions 1 and 3
3
char Sales_Date[8];
public:
SHOP();
void Sales_Entry();
void Sales_Detail();
};
(i) Write the names of data members which are accessible from objects belonging to
class CUSTOMER.
(ii) Write the names of all the member functions which are accessible from objects
belonging to class SALESMAN.
(iii) Write the names of all the members which are accessible from member functions of
class SHOP.
(iv) How many bytes will be required by an object belonging to class SHOP?
3.
(a) Write a function in C++ to combine the contents of two equi-sized arrays A and B by
computing their corresponding elements with the 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.
4
(b) An array P[20][30] is stored in the memory along the column with each of the element
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. 4
(c) Write a function in C++ to perform Push operation on a dynamically allocated Stack
containing real numbers. 4
(d) Write a function in C++ to find sum of rows from a two dimensional array. 2
4.
(a) Observe the program segment given below carefully and fill the blanks marked as
Statement 1 and Statement 2 using seekg() and tellg() functions for performing the
required task. 1
#include <fstream.h>
class Employee
{
int Eno;char Ename[20];
public:
//Function to count the total number of records
int Countrec();
};
int Item::Countrec()
{
fstream File;
File.open(“EMP.DAT”,ios::binary|ios::in);
______________________ //Statement 1
4
return Count;
}
5
(b) Write a function in C++ to count the number of alphabets present in a text file
“NOTES.TXT”. 2
(b) Write a function in C++ to add new objects at the bottom of a binary file
“STUDENT.DAT”, assuming the binary file is containing the objects of the following class.
3
class STUD
{
int Rno;
char Name[20];
public:
void Enter(){cin>>Rno;gets(Name);}
void Display(){cout<<Rno<<Name<<endl;}
};
void Addnew()
{
fstream FIL;
FIL.open(“STUDENT.DAT”,ios::binary|ios::app);
STUD S;
char CH;
do
{
S.Enter();
FIL.write((char*)&S,sizeof(S));
cout<<”More(Y/N)?”;cin>>CH;
}
while(CH!=’Y’);
FIL.close();
}
5.
(a) What do you understand by Primary Key & Candidate Keys? 2
(b) Consider the following tables GAMES and PLAYER. Write SQL commands for the
statements (i) to (iv) and give outputs for SQL queries (v) to (viii) 6
Table: 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
Table: PLAYER
PCode Name Gcode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
6
(ii) To display details of those games which are having PrizeMoney more than 7000.
(iii) To display the content of the GAMES table in ascending order of ScheduleDate.
(iv) To display sum of PrizeMoney for each of the Number of participation groupings (as
shown in column Number 2 or 4)
6.
(a) State and algebraically verify Absorbtion Laws. 2
(b) Write the equivalent Boolean Expression for the following Logic Circuit 2
(c) Write the SOP form of a Boolean function G, which is represented in a truth table as
follows: 1
P Q R G
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1
7
(d) Reduce the following Boolean Expression using K-Map: 3
F(U,V,W,Z)=(0,1,2,4,5,6,8,10)
7.
a) Define the term Bandwidth. Give unit of Bandwidth. 1
e)
Ravya Industries has set up its new center at Kaka Nagar for its office and web
based activities. The company compound has 4 buildings as shown in the
diagram below:
Fazz
Raj
Building
Building
Jazz
Harsh Building
Building
e2) Suggest the most suitable place (i.e. building) to house the server of this
organisation with a suitable reason. 1
8
e3) Suggest the placement of the following devices with justification: 1
(i) Internet Connecting Device/Modem
(ii) Switch
e4) The organisation is planning to link its sale counter situated in various parts of
the same city, which type of network out of LAN, MAN or WAN will be
formed? Justify your answer. 1
9
Computer Science (Code 083)
Sample Paper with Solution Set –I
Max. Marks: 70 Duration: 3 Hours
1.
(a) What is the difference between Object Oriented Programming and Procedural
Programming? 2
Answer:
Object Oriented Programming Procedural Programming
Emphasis on Data Emphasis on doing things (functions)
Follows Bottom-Up approach in Follows Top-down approach in
program design program design
Data hiding feature prevents accidental Presence of Global variables
change in data increase chances of accidental
change in data
Features like data encapsulation, Such features are not available
polymorphism, inheritance are present
(d) Write the names of the header files to which the following belong: 1
(i) frexp() (ii) isalnum()
Answer:
(i) math.h (ii) ctype.h
(e) Rewrite the following program after removing the syntactical errors (if any). Underline
each correction. 2
#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);
}
Answer:
#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;
10
Point1.Color+=2;
ShowPoint(Point2);
}
11
Answer:
TiLeP550
AiLJP430
(g) In the following program, if the value of N given by the user is 20, what maximum and
minimum values the program could possibly display? 2
#include <iostream.h>
#include <stdlib.h>
void main()
{
int N,Guessnum;
randomize();
cin>>N;
Guessnum=random(N-10)+10;
cout<<Guessnum<<endl;
}
Answer:
Maximum Value: 19 Minimum Value: 10
2.
(a) What do you understand by Polymorphism? Give a suitable example of the same. 2
Answer:
Polymorphism: It is a method of using the same operator or function (method) to work
using different sets of input. Function overloading is one of the example of polymorphism,
where more than one function carrying same name behave differently with different set of
parameters passed to them.
void Display()
{
cout<<”Hello!”<<endl;
}
void Display(int N)
{
cout<<2*N+5<<endl;
}
(c) Answer the questions (i) and (ii) after going through the following program: 2
class Match
{
int Time;
public:
Match() //Function 1
12
{
Time=0;
cout<<”Match commences”<<end1;
}
void Details() //Function 2
{
cout<<”Inter Section Basketball Match”<<end1;
}
};
iii) Which category of constructor - Function 4 belongs to and what is the purpose of
using it?
Answer:
Copy Constructor, it is invoked when an object is created and initialised with
values of an already existing object.
iv) Write statements that would call the member Functions 1 and 3
Answer:
Match M1; //for Function 1
Match M2(90); //for Function 3
13
Public Members
A function FEEDINFO() to allow user to enter values for Flight Number,
Destination, Distance & call function CALFUEL() to calculate the quantity of Fuel
A function SHOWINFO() to allow user to view the content of all the data
members
Answer:
class FLIGHT
{
int Fno;
char Destination[20];
float Distance, Fuel;
void CALFUEL();
public:
void FEEDINFO();
void SHOWINFO();
};
void FLIGHT::CALFUEL()
{
if (Distance<1000)
Fuel=500;
else
if (Distance<2000)
Fuel=1100;
else
Fuel=2200;
}
void FLIGHT::FEEDINFO()
{
cout<<”Flight No :”;cin>>Fno;
cout<<”Destination :”;gets(Destination);
cout<<”Distance :”;cin>>Distance;
CALFUEL();
}
void FLIGHT::SHOWINFO()
{
cout<<”Flight No :”<<Fno<<endl;
cout<<”Destination :”<<Destination<<endl;
cout<<”Distance :”<<Distance<<endl;;
cout<<”Fuel :”<<Fuel<<endl;;
}
14
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();
};
(vi) Write the names of data members which are accessible from objects belonging to
class CUSTOMER.
(vii) Write the names of all the member functions which are accessible from objects
belonging to class SALESMAN.
(viii) Write the names of all the members which are accessible from member functions
of class SHOP.
(ix) How many bytes will be required by an object belonging to class SHOP?
Answer:
(i) None of data members are accessible from objects belonging to class CUSTOMER.
(ii) Enter(), Show()
(iii) Data members: Voucher_No, Sales_Date, Salary
Member function: Sales_Entry(), Sales_Details(), Enter(), Show(), Register(), Status()
(iv) 66
3.
(a) Write a function in C++ to combine the contents of two equi-sized arrays A and B by
computing their corresponding elements with the 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.
4
Answer:
void AddNSave(int A[],int B[],int C[],int N)
{
for (int i=0;i<N;i++)
C[i]=2*A[i]+3*B[i];
}
15
(1 Mark for the formula)
(1 Mark for transferring elements in the resultant array)
(f) An array P[20][30] is stored in the memory along the column with each of the element
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. 4
Answer:
Given,
W=4
N=20
M=30
Loc(P[2][20])=5000
Column Major Formula:
Loc(P[I][J]) =Base(P)+W*(N*J+I)
Loc(P[2][20]) =Base(P)+4*(20*20+2)
5000 =Base(P)+4*(400+2)
Base(P) =5000- 1608
Base(P) =3392
Loc(P[5][15]) =3392+4*(20*15+5)
=3392+4*(300+5)
=3392+1220
=4612
(1/2 Mark for correct formula/substitution of values in formula)
(1 ½ Mark for correctly calculating Base Address)
(2 Mark for correctly calculating address of desired location)
(g) Write a function in C++ to perform Push operation on a dynamically allocated Stack
containing real numbers. 4
Answer:
struct NODE
{
float Data; NODE *Link;
};
class STACK
{
NODE *Top;
public:
STACK();
void Push();
void Pop();
};
void STACK::Push()
{
NODE *Temp;
Temp=new NODE;
cin>>Temp->Data;
Temp->Link=Top;
Top=Temp;
}
( ½ Mark for appropriate function header)
( ½ Mark for declaring a Temporary pointer - TEMP)
(1 Mark for new operation)
(1 Mark for Temp->Link to Top)
(1 Mark for assigning Top as Temp)
16
(h) Write a function in C++ to find sum of rows from a two dimensional array. 2
Answer:
void MatAdd(int A[100][100],int N,int M)
{
for (int R=0;R<N;R++)
{
int SumR=0;
for (int C=0;C<M;C++)
SumR+=A[C][R];
cout<<SumR<<endl;
}
}
True
Step 2: Push
False
True
Step 3: AND Push
Pop Pop
Op2=True Op1=False
Op2=True
True False
Step 4: Push
True
False
Step 5: Push
True
True
False
Step 6: NOT Push
Pop
Op2=True False
True True
False False
Step 7: OR Push
Pop Pop
Op2=False Op1=True
True Op2=False True
17
False False False
Step 8: AND Push
Pop Pop
Op2=True Op1=False
Op2=True
False False
Step 9: Pop
Result
False
( 1½ Mark for showing stack position for operations NOT,OR and AND)
( ½ Mark for correctly evaluating the final result)
4.
(a) Observe the program segment given below carefully and fill the blanks marked as
Statement 1 and Statement 2 using seekg() and tellg() functions for performing the
required task. 1
#include <fstream.h>
class Employee
{
int Eno;char Ename[20];
public:
//Function to count the total number of records
int Countrec();
};
int Item::Countrec()
{
fstream File;
File.open(“EMP.DAT”,ios::binary|ios::in);
______________________ //Statement 1
Answer:
File.seekg(0,ios::end); //Statement 1
File.tellg(); //Statement 2
18
(b) Write a function in C++ to count the number of alphabets present in a text file
“NOTES.TXT”. 2
Answer:
void CountAlphabet()
{
ifstream FIL(“NOTES.TXT”);
int CALPHA=0;
char CH=FIL.get();
while (!FIL.eof())
{
if (isalpha(CH)) CALPHA++;
CH=FIL.get();
}
cout<<”No. of Alphabets:”<<CALPHA<<endl;
FIL.close();
}
(c) Write a function in C++ to add new objects at the bottom of a binary file
“STUDENT.DAT”, assuming the binary file is containing the objects of the following class.
3
class STUD
{
int Rno;
char Name[20];
public:
void Enter(){cin>>Rno;gets(Name);}
void Display(){cout<<Rno<<Name<<endl;}
};
Answer:
void Addnew()
{
fstream FIL;
FIL.open(“STUDENT.DAT”,ios::binary|ios::app);
STUD S;
char CH;
do
{
S.Enter();
FIL.write((char*)&S,sizeof(S));
cout<<”More(Y/N)?”;cin>>CH;
}
while(CH!=’Y’);
FIL.close();
}
19
5.
(a) What do you understand by Primary Key & Candidate Keys? 2
Answer:
An attribute or set attributes which are used to identify a tuple uniquely is known as
Primary Key. If a table has more than one such attributes which identify a tuple uniquely
than all such attributes are known as Candidate Keys.
(b) Consider the following tables GAMES and PLAYER. Write SQL commands for the
statements (i) to (iv) and give outputs for SQL queries (v) to (viii) 6
Table: 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
Table: PLAYER
PCode Name Gcode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
(ii) To display details of those games which are having PrizeMoney more than 7000.
Answer:
SELECT * FROM GAMES WHERE PrizeMoney>7000
( ½ mark for correct SELECTion of columns)
( ½ mark for correct use of WHERE)
(iii) To display the content of the GAMES table in ascending order of ScheduleDate.
Answer:
SELECT * FROM GAMES ORDER BY ScheduleDate;
( ½ mark for correct SELECTion of columns)
( ½ mark for correct use of ORDER BY)
(iv) To display sum of PrizeMoney for each of the Number of participation groupings (as
shown in column Number 2 or 4)
Answer:
SELECT SUM(PrizeMoney),Number FROM GAMES GROUP BY Number;
( ½ mark for correct SELECTion of columns)
( ½ mark for correct use of GROUP BY)
20
(vi)SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;
Answer:
19-Mar-2004 12-Dec-2003
( ½ mark for correct output)
6.
(a) State and algebraically verify Absorbtion Laws. 2
Answer:
X+X.Y = X
L.H.S = X+X.Y
= X.1+X.Y
= X.(1+Y)
= X.1
= X
= R.H.S
X+X’.Y = X+Y
L.H.S. = X+X’.Y
= (X+X’).(X+Y)
= 1.(X+Y)
= X+Y
= R.H.S
(b) Write the equivalent Boolean Expression for the following Logic Circuit 2
Answer:
F(U,V)=U’.V+U.V’
(Full 2 marks for obtaining the correct Boolean Expression for the Logic Circuit)
OR
(1 mark correctly interpreting Product terms)
21
(e) Write the SOP form of a Boolean function G, which is represented in a truth table as
follows: 1
Answer:
P Q R G
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1
G(P,Q,R) = P’.Q.R’+P.Q’.R’+P.Q.R’+P.Q.R
F(U,V,W,Z)=UV+WZ+UZ
7.
b) Define the term Bandwidth. Give unit of Bandwidth. 1
Answer:
Bandwidth is the capability of a medium to transmit an amount of information
over a distance. Bandwidth of a medium is generally measured in bits per second
(bps) or more commonly in kilobits per second (kbps)
22
e) Define the term firewall. 1
Answer:
Firewall is a feature used for Network Security. In a Network there is always
danger of information leaking out or leaking in. Firewall is a feature which forces
all information entering or leaving the network to pass through a check to make
sure that there is no unauthorized usage of the network.
(1 Mark for correct definition)
e)
Ravya Industries has set up its new center at Kaka Nagar for its office and web
based activities. The company compound has 4 buildings as shown in the
diagram below:
Fazz
Raj
Building
Building
Jazz
Harsh Building
Building
23
e1) Suggest a cable layout of connections between the buildings. 1
Answer:
Layout 1:
Fazz
Raj
Building
Building
Jazz
Harsh Building
Building
Layout 2: Since the distance between Fazz Building and Jazz Building is quite
short
Fazz
Raj
Building
Building
Jazz
Harsh Building
Building
e2) Suggest the most suitable place (i.e. building) to house the server of this
organisation with a suitable reason. 1
Answer:
The most suitable place / block to house the server of this organisation would
be Raj Building, as this block contains the maximum number of computers,
thus decreasing the cabling cost for most of the computers as well as
increasing the efficiency of the maximum computers in the network.
24
e3) Suggest the placement of the following devices with justification: 1
(iii) Internet Connecting Device/Modem
(iv) Switch
Answer:
(i) Raj Building
(ii) In both the layouts, a hub/switch each would be needed in all the
buildings, to interconnect the group of cables from the different
computers in each block
( ½ Mark for placement of each device correctly)
e4) The organisation is planning to link its sale counter situated in various parts of
the same city, which type of network out of LAN, MAN or WAN will be
formed? Justify your answer. 1
Answer:
The type of network that shall be formed to link the sale counters situated in
various parts of the same city would be a MAN, because MAN (Metropolitan
Area Networks) are the networks that link computer facilities within a city.
( ½ mark for correct type and ½ mark for correct justification)
Free Download
CBSE QUESTION PAPERS, C++ PROJECT, C++ PRACTICAL QUESTION &
ANSWERS http://www.cppforschool.com
25
P.X-=Step;
1. C++ REVISION TOUR P.Y+=Step;
P.Z–=Step;
2010 Delhi: }
void main ( )
1. (a) What is the difference between {
automatic type conversion and type POINT P1={15, 25, 5}, P2={10, 30, 20};
casting? Also, give a suitable C++ code to StepIn(P1);
illustrate both. 2 StepOut(P2,4);
cout<<P1.X<<“,”<<P1.Y<<“,”<<P1.Z<<en
Ans. Automatic Type Conversion: it is dl;
an implicit process of conversion of a cout<<P2.X<<“,”<<P2.Y<<“,”<<P2.Z<<en
data from one type to another. dl;
For example StepIn(P2,12);
int N = 65; cout<<P2.X<<“,”<<P2.Y<<“,”<<P2.Z<<en
char C = N; // Automatic type dl;
conversion }
cout<<C; Ans.
OUTPUT: 16, 24, 6
A 6, 34, 16
Type Casting: It is an explicit process of
18, 22, 28
conversion of a data from one type to
(e) Find the output of the following
another. For example
program : 2
int A=1, B=2;
#include <iostream.h>
float C = (float)A/B; //Type Casting
#include <ctype.h>
S)
cout<<C;
void ChangeIt(char Text[ ], char C)
C
OUTPUT:
T
{
G
0.5
(P
{
m
Ku
else
Vi
1 if (Text[K]=’E’ || Text[K]==’e’)
void main( ) Text[K]==C;
{ else
int Eno=123, char Ename[ ]=”Rehan if (K%2==O)
Swamp”; Text[K]=toupper(Text[K]);
cout<<setw(5)<<Eno<<setw(25)<<EName<< else
endl;
Text[K]=Text[K-l];
}
}
Ans. (i) iostream.h (ii) iomanip.h
}
void main ( )
(d) Find the output of the following
{
program : 3
char OldText[ ]=”pOwERALone”;
#inc1ude <iostream.h>
ChangeIt(OldText,’%’);
struct POINT
cout<<“New
{
TEXT:”<<OldText<<endl;
int X, Y, Z;
}
};
Ans.
void StepIn(POINT & P, int Step=1)
{ New TEXT : PPW %
P.X+=Step; RR11N%
P.Y-=Step;
P.Z+=Step; (f) The following code is from a game,
} which generates a set of 4 random
void StepOut(POINT & P, int Step=1) numbers. Yallav is playing this game, help
{ him to identify the correct option(s) out
2 XII Computer
of the four choices given below as the }
possible set of such numbers generated
from the program code so that he wins (b) Which C++ header file(s) will be
the game. Justify your answer. essentially required to be included to
2 run/execute the following C++ code:
#include <iostream.h> 1
#include <stdlib.h> void main()
const int LOW=15; {
void main ( ) int Rno=24; char Name [] =” Amen
{ Singhania”;
randomize( ) ; cout<<setw(lO)<<Rno<<setw(20)<<Name<<
int POINT=5, Number; endl;
for (int 1=1;I<=4;I++) }
{ Ans.
Number=LOW+random(POINT) iostream.h
; iomanip.h
cout<<Number<<“:” ;
POINT--; (d) Find the output of the following
} program: 3
} #include <iostream.h>
(i) 19:16:15:18: struct THREE_D
(ii) 14:18:15:16: { int X,Y,Z;
(iii) 19:16:14:18 };
(iv) 19:16:15:16: void MoveIn(THREE_D &T, int Step=l)
Ans. {
(iv) 19:16:15:16: T.X+=Step;
T.Y-=Step;
S)
Justification is as follows:
T.Z+=Step;
C
I POINT Number
T
}
G
Minimum Maximum
(P
1 5 15 19
{
m
2 4 15 18
Ku
T.X-=Step;
3 3 15 17
er
T.Y+=Step;
nd
4 2 15 16
re
T.Z-=Step;
The only option that satisfies these values
Vi
}
is option (iv).
void main ()
{
2010 Outside Delhi: THREE_D Tl={lO,20,5},T2={30,lO,40};
MoveIn(T1);
1. (a) What is the difference between call MoveOut(T2,5) ;
by value and call by reference? Also, give cout<<Tl.X<<“,”<<Tl.Y<<“,”<<T1.Z<<en
a suitable C++ code to illustrate both. dl;
2 cout<<T2.X<<“,”<<T2.Y<<“,”<<T2.Z<<e
Ans. ndl;
Call by value: The formal parameter MoveIn(T2,l0);
makes a copy of actual parameter. It does cout<<T2.X<<“,”<<T2.y<<“,”<<T2.Z<<e
not make the changes In actual ndl;
parameter If the changes are done In }
formal parameters. Ans.
Call by reference: The formal parameter 11, 19, 6
Is an alias of actual parameter.
Thechanges made In the formal 25, 15, 35
parameter are reflected In actual 35, 5, 45
parameter. It is preceded by &.
void Caloulato(int A,int & B )// A is oall (e) Find. the output of the following
by value, program: 2
{ // B is call by roforonco
A++; #include <iostream.h>
a+=A; #include <ctype.h>
3 XII Computer
void MyCode (char Msg [], char CH) 1 5 25 29
{ 2 4 25 28
for (int (Cnt=O;Msg[Cnt]!=’\0';Cnt++) 3 3 25 27
{ 4 2 25 26
if (Msg[Cnt]>=’B’ && Msg[Cnt]<=’G’) The only option that satisfies these values
Msg[Cnt]=tolower(Msg[Cnt]); is option (iv).
else
if (Msg[Cnt]==’A’|| Msg[Cnt]==’a’) 2009 Delhi:
Msg[Cnt]=CH;
else 1. (a) What is the difference between call
if (Cnt%2==0) by value and call by reference? Give an
Msg[Cnt]=toupper(Msg[Cnt]); example in C++ to illustrate both. 2
else Ans
Msg[Cnt]=Msg[Cnt-l]; Call by value is used to create a
} temporary copy of the data coming from
} the actual parameter into the formal
void main () parameter. The changes done in the
{ function in formal parameter are not
char MyText [] =” ApEACeDriVE”; reflected back in the calling environment.
MyCode(MyText,’@’); It does
cout<<“NEW TEXT:”<<MyText<<endl; not use ‘&’ sign.
} Call by reference is used to share the
Ans. same memory location for actual and
NEW TEXT :@@e@ccddIIe formal parameters and so changes done
in the function are reflected back in the
(f) The following code is from a game, calling environment. It uses ‘&’ sign.
S)
#include <iostream.h>
Vi
}
#include <stdlib.h> void main ()
const int LOW=25; {
void main () int I=50,J=25;
{ cout<<”Before function call “<<endl;
randomize() ; cout<<”I=”<<I<<”&”<<”J=”<<J <<endl;
int P01NT=5,Number; Compute (I,J) ;
for (int I=1;I<=4;I++) cout<<”After function call “<<endl;
{ cout<<I=”<<I<<”&”<<”J=”<<J <<endl;
Number=LOW+random(POINT); }
cout<<Number<<“:”; OUTPUT
P0INT--; Before function call
} I=50&J=25
} In the function
(i) 29:26:25:28: A=51&B=26
(ii) 24:28:25:26: After function call
(iii) 29:26:24:28: I=50&J=26
(iv) 29:26:25:26:
Ans.
(iv) 29:26:25:26: 1(b) Write the names of the header files
to which the following belong:
Justification is as follows: 1
I POINT Number (i) puts ( ) (ii) sin ( )
Minimum Ans (i) stdio.h (ii) math. h
Maximum
4 XII Computer
1.(e) Find the output of the following as Formal Parameter, It is used to accept
program:2 the data from actual parameter.
#include <iostream.h> void Seventimes(int A)//A is formal
#include <ctype.h> parameter
void Encode (char Info [ ], int N) ; {
void main ( ) cout<<7*A;
{ }
char Memo [ ] = “Justnow” ; void main ()
Encode (Memo, 2) ; {
cout<<Memo<<endl ; int P=6;
} Seventimes(P);//p is actual
void Encode (char Info [ ], int N) parameter
{ }
for (int I = 0 ; Info[I] !=‘\0’ ; 1++) Other answer for the same question
if (1%2= =0)
Info[I] = Info[I] –N ; Ans) The parameters in the function call
else if (islower(Info[I])) statement (or calling function) are called
Info[I] = toupper(Info[I]) ; as Actual Parameters.
else The parameters in the function
Info[I] = Info[I] +N ; definition (or called function) are called
} as Formal Parameters.
Ans Eg:
HuqTlOu void manip(int x, int y)
{ ---
(f) Study the following program and ---
select the possible output from it : }
void main( )
S)
2
C
#include <iostream.h> {
T
G
----
ar
{ }
er
nd
5 XII Computer
Msg[C] = tolower(Msg[C]); void main( )
else { First = 10, Second = 20;
Msg[C] = Msg[C]-N; Jumpto(First;Second);
} Jumpto(Second);
Ans }
teRmttoe void Jumpto(int N1, int N2 = 20)
{ N1=N1+N2;
(f) Study the following program and count<<N1>>N2;
select the possible output from it : }
2 Ans)#include<iostream.h>
#include <iostream.h> void Jumpto(int N1,int N2=20);
#include <stdlib.h> //Prototype missing
const int MAX=3 ; void main( )
void main ( ) { int First = 10, Second = 20;
{ randomize( ) ; //Data type missing
int Number ; Jumpto(First,Second);
Number = 50 + random{MAX) ; //Comma to come instead of ;
for (int P=Number; P>=50; P– –) Jumpto(Second);
cout<<p<< “ # ” ; }
cout<<endl; void Jumpto(int N1, int N2)
} { N1=N1+N2;
(i) 53#52#51#50# cout<<N1<<N2;
(ii) 50#51#52# //Output operator << required
(iii) 50#51# }
(iv) 51#50#
Ans d)Find the output of the following
program;3
S)
(iv) 51#50#
C
#include<iostream.h>
T
#include<ctype.h>
(P
or 1 or 2. (random(N)will produce
m
no.between 1 to n-1)
for(int I=0; Text[I]!=’\0’;I++)
er
{ if(!isalpha(Text[I]))
The P value starts from Number, upto 50,
re
Text[I]=’*’;
Vi
6 XII Computer
Since Text[1] is ‘i’, Which is a character,
but which is not Upper case,
else part will be executed.
Ie Text[I]=Text[I+1] When I=6
Here Text[1]=Text[1+1] Since Text[6] is ‘o’, Which is a character,
=Text[2] but which is not Upper case, else part
Ie ‘n’ will be stored in place of ‘i’ will be executed.
Now the String Text[ ] = Ie Text[I]=Text[I+1]
Here Text[6]=Text[6+1]
=Text[7]
Ie ‘r’ will be stored in place of ‘o’
Now the String Text[ ] =
When I=2
Since Text[2] is ‘n’, Which is a character,
but which is not Upper case, else part will
be executed.
Ie Text[I]=Text[I+1] When I=7
Here Text[2]=Text[2+1] Since Text[7] is ‘r’, Which is a character,
=Text[3] but which is not Upper case, else part
Ie ‘d’ will be stored in place of ‘n’ will be executed.
Now the String Text[ ] = Ie Text[I]=Text[I+1]
Here Text[7]=Text[7+1]=Text[8]
Ie ‘k’ will be stored in place of ‘r’
Now the String Text[ ] =
When I=3
Since Text[3] is ‘d’, Which is a character,
S)
Here Text[3]=Text[3+1]
m
When I=4
Since Text[4] is ‘@’, Since which is not an
When I=9
alphabet,
Since Text[9] is ‘!’, Since which is not an
(!isalpha(Text[I])) will becomes true.
alphabet, (!isalpha(Text[I])) will becomes
Ie if(!isalpha(Text[I]))
true.
Text[I]=’*’;
Ie if(!isalpha(Text[I]))
Ie Text[4]=’*’
Text[I]=’*’;
Ie ‘*’ will be stored in place of ‘@’
Ie Text[9]=’*’
Now the String Text[ ] =
Ie ‘*’ will be stored in place of ‘!’
Now the String Text[ ] =
When I=5
Since Text[5] is ‘W’, Upper Case Letter,
(isupper(Text[I]) will becomes true.
So Text[I] =Text[I]+1 Output: Nnd@*Xrk!*
So Text[5]=Text[5]+1
Text[5] =87(ASCII Value of W) + 1 = 88
e) Find the output of the following
=X(88 is ASCII Value of X)
program: 2
Now the String Text[ ] =
#include<iostream.h>
7 XII Computer
void main( ) identifier gets replaced by the specified
{ int U=10,V=20; value by the compiler, before the code is
for(int I=1;I<=2;I++) turned into binary. This means that the
{ cout<<”[1]”<<U++<<”&”<<V – 5 compiler makes the substitution when
<<endl; you compile the application.
cout<<”[2]”<<++V<<”&”<<U + 2 Eg: #define number 100
<<endl; In this case every instance of “number”
} will be replaced by the actual number
}A 100 in your code, and this means the final
ns: Output: compiled program will have the number
[1]10&15 100 (in binary).
[2]21&13 #define with different types of data:
[1]11&16
[2]22&14 • The #define preprocessor allows
u s to define symbolic names and
f) In the following program, find the constants.
correct possible output(s) from the Eg: #define PI 3.14159
options: 2 • The #define allows you to make
#include<stdlib.h> text substitutions before
#include<iostream.h> compiling the program.
void main( ) Eg: #define MAX 70
{ randomize( ); Before compilation, if the C++
char City[][10]= preprocessor finds MAX as one
{“DEL”,”CHN”,”KOL”,”BOM”,”BNG”}; word, in the source code, it
int Fly; replaces it with the number 70.
for(int I=0; I<3;I++) • The #define preprocessor can be
S)
C
}
Ku
(ii) KOL : BOM : BNG: replaces it with its square (ie x*x). Here
(iii) KOL : CHN : KOL: a macro substitutes text only; It does not
check for data types.
Ans)Since random(2) gives either 0 or 1, On the other hand, when we use
Fly value will be either 1 or 2. const and the application runs, memory
(random(n) gives you any number is allocated for the constant and the value
between 0 to n-1) gets replaced when the application is run.
City[1] is “CHN”. City[2] is “KOL”. Syntax: const type variable_name=value;
Since I value from 0 to 2 (ie<3), 3
iterations will takes place. Eg: const int a=10;
So the possible output consists 3 strings The value of a constant is
separated by :, each of them may be fixed and in the above example, the value
either “CHN” or “KOL”. for a in entire program is 10 only. You
cannot change the value of a, since it is
So the possible output will be declared as constant.
(ii) CHN : KOL : CHN:
(iv) KOL :CHN : KOL: Difference between #define and const
in declaration:.
1.a) What is the difference between 1.#define: #define symbolic_constant
#define and const? Explain with suitable value.
example. 2 Eg: #define number 100 //No
Ans: While they both serve a similar semicolon ,no equal to symbol.
purpose, #define and const act 2.const: const type
differently. When using #define the variable_name=value;
8 XII Computer
Eg: const number=100; //Semicolon, equal Mystring[I]=Mystring[I]+1;
to symbol. else
Mystring[I] =Mystring[I+1];
2008 Outside Delhi: }
cout<<Mystring;}
1.b) Name the header files that shall be Ans: Output: hat@*PVUQVU*
needed for the following code:
1 e) Find the output of the following
void main( ) program: 2
{ #include<iostream.h>
char word[]=”Exam”; void main( )
cout<<setw(20)<<word; { int A=5,B=10;
} for(int I=1;I<=2;I++)
Ans: iostream.h, iomanip.h { cout<<”Line1”<<A++<<”&”<<B-2
<<endl;
1.c) Rewrite the following program after cout<<”Line2”<<++B<<”&”<<A +3
removing the syntax error(s) if any. <<endl;
Underline each correction. }
2 }
#include<iostream.h> Ans: Output:
void main( )
{ Line15&8
One=10,Two=20; Line211&9
Callme(One;Two); Line16&9
Callme(Two); Line212&10
}
void Callme(int Arg1,int Arg2)
S)
{
T
Arg1=Arg1+Arg2;
(P
options: 2
Count<<Arg1>>Arg2;
ar
#include<stdlib.h>
m
}
Ku
#include<iostream.h>
Ans:
er
void main( )
nd
#include<iostream.h>
Vi
randomize( );
void main( )
char Area[ ][10]
{
={“NORTH”,”SOUTH”,”EAST”,”WE
int One=10,Two=20;
ST”};
Callme(One,Two); //Given ; instead
int ToGo;
of ,
for(int I=0; I<3;I++)
Callme(Two);
{
}
ToGo=random(2) + 1;
void Callme(int Arg1,int Arg2)
cout<<Area[ToGo]<<”:”;
{
}
Arg1=Arg1+Arg2;
}
cout<<Arg1<<Arg2;
Ans: Outputs:
}
(i) SOUTH : EAST : SOUTH :
(ii) NORTH : SOUTH : EAST :
1.d)Find the output of the following
(iii) SOUTH : EAST : WEST :
program:3
(iv) SOUTH : EAST : EAST :
#include<iostream.h>
Ans)Since random(2) gives either 0 or 1,
#include<ctype.h>
ToGo value will be either 1 or 2.
void main( )
(random(n) gives you any number
{
between 0 to n-1)
char Mystring[ ] = "what@OUTPUT!";
Area[1] is “SOUTH”. Area[2] is “EAST”.
for(int I=0; Mystring[I]!='\0';I++)
Since I value from 0 to 2 (ie<3), 3
{ if(!isalpha(Mystring[I]))
iterations will takes place.
Mystring[I]='*';
else if(isupper(Mystring[I]))
9 XII Computer
So the possible output consists 3 strings 1.a) Differenctiate between a Run Time
separated by :, each of them may be Error and Syntax Error. Also give
either “SOUTH” or “EAST”. suitable examples of each in c++.
So the possible output will be 2
(i) SOUTH : EAST : SOUTH : Ans: Run Time Errors: Errors that occur
(iv) SOUTH : EAST : EAST : during the execution of a program are
called as run time errors. It is caused of
1.a) What is the purpose of using a some illegal operation taking place or
typedef command in C++?Explain with inavailability of desired or required
suitable example 2 conditions for the execution of the
Ans: C++ allows you to define program. For instance, if a program is
explicitly new data type names by using trying to open a file which does not exist
the keyword typedef. Using typedef does or it could not be opened, it results into
not actually create a new data class, an execution error. Similarly, if enough
rather it defines a new name for an memory is not available or an expression
existing type. This can increase the is trying to divide a number by zero are
portability of a program as only the run-time errors.
typedef statements would have to be Eg: Division by zero. c=a/b ;
changed. Typedef makes your code User will give the values of a and b at the
easier to read and understand. Using time of program execution.
typedef can also aid in self documenting If he give the value of b as ‘0’ , then
your code by allowing descriptive names division by zero, ie a run time error
for the standard data types. occurs.
The syntax of the typedef statement is Syntax Errors:Syntax errors occur when
typedef type name; rules of a programming languages
Where type is any C++ data type and (syntax) is misused. Ie when a
name is the new name for this type. This grammatical rule of C++ is violated.
S)
C
type of C++. For example, you could In this statement, since there is no
(P
create a new name for float values by semicolon at the end of the statement,
ar
m
recognize amount as an alternative name operator (<<) has given instead of stream
Vi
for float. Now you could create float extraction operation(>>), there will
variables using amount. occurs a syntax error.
amount loan, saving, installment;
Using typedef does not replace the 1.b) Name the header file(s) that shall be
standard C++ data type name with the needed for successful compilation of the
new name, rather the new name is in following C++ code.
addition to the existing name. You still 1
can create float variables using float. void main( )
Once a new name has been defined by { char String[20];
typedef, it can be used as a type for gets(String);
another typedef also. strcat(String,”CBSE”);
Eg: typedef amount money; puts(String);
Now, this statement tells the }
compiler to recognize money as another Ans) stdio.h string.h
name for amount, which itself is another
name for float. Typedef does not create 1. c) Rewrite the following program after
any new data types rather provides an removing the syntactical error(s) if any.
alternative name for standard types. Underline each correction.
Reference provides an alias name for a 2
variable and typedef provides an alias #include<iostream.h>
name for a data type. const int Max 10;
void main()
2007 Delhi : { int Numbers[Max];
Numbers = {20,50,10,30,40};
10 XII Computer
for(Loc=Max-1;Loc>=10;Loc--) 1.a) Differentiate between a Logical
cout>>Numbers[Loc]; Error and Syntax Error. Also give
} suitable examples of each in C++.
Ans) 2
#include<iostream.h> Ans: Logical Error: A logical error is that
const int Max=10;//Constant Variable error which causes a program to produce
‘Max’ //must be initialized.Declaration incorrect or undesired output.
Syntax Error An incorrectly implemented algorithm or
void main( ) use of a variable before its initialization,
{ int Numbers[Max]={20,50,10,30,40}; or unmarked end for a loop, or wrong
for(Loc=Max-1;Loc>=0;Loc--) parameters passed are causes logical
cout>>Numbers[Loc]; errors. These must be handled carefully.
} For instance, if we are trying to print the
table of a number 5 and if we say
e)Find the output of the following counter=1;
program. 3 while(counter>8)
#include<iostream.h> { cout<<n*counter;
void Withdef(int HisNum=30) counter=counter+1;
{ for(int I=20;I<=HisNum;I+=5) }
cout<<I<<”,”; Here the loop would not be executed
cout<<endl; even once as the condition (counter>8) is
} not fulfilled at all. Therefore, no output
void Control(int &MyNum) will be produced. Such an error is logical
{ MyNum+=10; error.
Withdef(MyNum); Syntax Error: Syntax errors occur when
} rules of a programming languages
void main() (syntax) is misused. Ie when a
S)
C
f)In the following C++ program what is 1.b) Name the header file(s) that shall be
the expected value of MyMarks from needed for successful compilation of the
options (i) to (iv)given below. Justify following C++ code.
answer. 2 1
#include<stdlib.h> void main( )
#include<iostream.h> {
void main( ) char Text[40];
{ strcpy(Text,”AISSCE”);
randomize( ); puts(Text);
int }
Marks[]={99,92,94,96,93,95},MyMarks; Ans:
MyMarks = Marks [1+random(2)]; string.h, stdio.h
cout<<MyMarks<<endl;
} 1.c) Rewrite the following program after
(i)99 (ii)94 (iii)96 (iv) None of the above. removing the syntactical error(s), if any.
Ans: Output: Underline each correction. 2
(ii) 94 #include<iostream.h>
const int Size 5;
2007 Outside Delhi: void main( )
{
11 XII Computer
int Array[Size]; (i) None of the above.
Array={50,40,30,20,10};
for(Ctr=0;Ctr<Size;Ctr++)
cout>>Array[Ctr]; 2006 Delhi:
}
Ans) 1.a) Name the header file to which the
#include<iostream.h> following below:
const int Size=5; 1
void main( ) (i) abs( ) (ii) isupper( )
{ Ans) (i) abs( ) - math.h, stdlib.h,
int Array[Size]; complex.h
Array={50,40,30,20,10}; (ii)isupper( ) - ctype.h
for(Ctr=0;Ctr<Size;Ctr++)
cout<<Array[Ctr]; 1.e) Find the output of the following
} program 2 #include<iostream.h>
void main( )
1.e)Find the output of the following { long NUM=1234543;
program3 int F=0,S=0;
#include<iostream.h> do
void Indirect(int Temp=20) { int R=NUM % 10;
{ if (R %2 != 0)
for(int I=10;I<=Temp;I+=5) F += R;
cout<<I<<”,”; else
cout<<endl; S += R;
} NUM / = 10;
void Direct(int &Num) } while (NUM>0);
{ Num+=10;
S)
cout<<F-S;
C
Indirect(Num);
2
T
} Ans: Output:
G
}
(P
void main( )
ar
{ int Number=20;
Ku
2
nd
Indirect( );
Ans: The #define preprocessor can be
re
cout<<”Number =”<<Number<<endl;
Vi
}
T
G
struct date
ar
m
{ int dd;
Ku
int yy;
Underline each correction.
re
};
Vi
2
struct student
#include<iostream.h>
{ char name[20];
void main( )
int roll;
{ struct movie
date dob;
{ char movie_name[20];
int marks;
char movie_type;
};
int ticket_cost=100;
The member of a nested structure is
}MOVIE;
referenced from the outermost to
gets(movie_name);
innermost with the help of dot operators.
gets(movie_type);
student stud;
}
Then the members of the nested
Ans:#include<iostream.h>
structure can be accessed as
#include<stdio.h>
stud.dob.mm=10;
void main( )
Eg2:
{ struct movie
struct addr
{ char movie_name[20];
{ int houseno;
char movie_type;
char area[26];
int ticket_cost;
char city[26]; //Initialization of variables inside a structure is not
char state[26]; allowed.
}; }MOVIE;
struct emp gets(MOVIE.movie_name);
{ int empno; cin>>MOVIE.movie_type;
char name[26]; //A single character cannot be read
char design[16]; using gets
}
13 XII Computer
2005 Delhi: Program to illustrate the call by
Reference method of function
invoking:
1.a) Differentiate between a Call by Value #include<iostream.h>
and Call by Reference, giving suitable #include<conio.h>
examples of each. int change(int&);
2 void main( )
Ans: Call by value: In call by value { clrscr( );
method, the called function creates a new int orig=10;
set of variables and copies the values of cout<<”\nThe original value
arguments into them. The function does is”<<orig<<”\n”;
not have access to the original variables cout<<”\nReturn value of function
(actual parameters) and can only work change()is
“<<change(orig)<<”\n”;
on the copies of values it created. Passing
cout<<”\nThe value after function change() is
arguments by value is useful when the over”<<orig<<”\n;
original values are not to be modified. getch();
In call by reference method, a }
reference to the actual argument int change(int &duplicate)
(original variable) is passed to the called { duplicate=20;
function. (Reference is an alias for a return duplicate;
predefined variable. Ie the same variable }
value can be accessed by any of the two
names: the original variable’s name and Output:
the reference name.) Thus, in call by The original value is 10
reference method, the changes are Return value of function change() is 20
reflected back to the original values. The The value after function change() is over
S)
20
T
original variables are to be changed using 1. b) Name the header files to which the
ar
a function.
m
following belong:
Ku
1
er
#include<iostream.h> complex.h
#include<conio.h> (ii) strcmp( ) - string.h
int change(int);
void main( ) 1. c) Rewrite the following program after
{ clrscr( ); removing the syntactical error(s), if any.
int orig=10; Underline each correction.
cout<<”\nThe original value 2 #include<iostream.h>
is”<<orig<<”\n”; const int Multiple 3;
cout<<”\nReturn value of function void main( )
change()is {
“<<change(orig)<<”\n”; value = 15;
cout<<”\nThe value after function for(int Counter = 1;Counter = <5;Counter ++,
change() is Value -= 2)
over”<<orig<<”\n; if(Value%Multiple = = 0)
getch(); cout<<Value * Multiple;
} cout<<end1;
int change(int duplicate) else
{ duplicate=20; cout<<Value + Multiple <<endl; }
return duplicate; Answer:
} #include<iostream.h>
Ans: Output: const int Multiple=3;
The original value is 10 void main( )
Return value of function change() is 20 {
The value after function change() is over
10 int Value = 15;
14 XII Computer
for(int Counter = 1;Counter <=5;Counter ++, cin>>Num;
Value -= 2) Rndnum = random(Num) + 5;
if(Value%Multiple == 0) for(int N = 1;N<=Rndnum;N++)
{ cout<<Value * Multiple; cout<<N<<” “;
cout<<endl; }
} Output Options:
else (i) 1 2 3 4 (ii) 1 2
cout<<Value + Multiple <<endl; (iii) 1 2 3 4 5 6 7 8 9
} (iv) 1 2 3
Ans: Expected Output:
1.e) Find the output of the following
program 2 (iii) 1 2 3 4 5 6 7
#include<iostream.h> 8 9
#include<string.h>
#include<ctype.h> 1.d) Find the output of the following
void Convert(char Str[ ],int Len) program:
{
for(int Count=0;Count<Len;Count++) #include<iostream.h>
{ if(isupper(Str[Count])) struct MyBox
Str[Count]=tolower(Str[Count]); { int Length,Breadth,Height;
else if (islower(Str[Count])) };
Str[Count]=toupper(Str[Count]); void Dimension(MyBox M)
else if(isdigit(Str[Count])) { cout<<M.Length<<”x”<<M.Breadth<
Str[Count]=Str[Count]+1; <”x”;
else Str[Count]=’*’; cout<<M.Height<<endl;
} }
} void main( )
S)
{ ++B1.Height;
G
(P
Convert(Text,Size); ++B3.Length;
er
cout<<Text<<endl; B3.Breadth++;
nd
+,R--) B2=B3;
{ char Temp=Text[C]; B2.Height+=5;
Text[C]=Text[R]; B2.Length--;
Text[R]=Temp; Dimension(B2);
} }
cout<<Text<<endl;
} 2005 Outside Delhi :
Ans: Output:
cbse*eXAM*3116 1.b) Name the header files to which the
6113*MXAe*esbc following belong: 1
(i) puts( ) (ii)isalnum( )
1. f) Observe the following program Ans)(i) puts( ) - stdio.h
SCORE.CPP carefully, if the value of Num (isalnum( ) - ctype.h
entered by the user is 5, choose the
correct possible output(s) from the 1.c) Rewrite the following program after
options from (i) to (iv), and justify your removing the syntactical error(s), if any.
option. Underline each correction.
2 2
//Program: SCORE.CPP #include<iostream.h>
#include<stdlib.h> const int dividor 5;
#include<iostream.h> void main( )
void main( ) { Number = 15;
{ randomize( ); for(int Count=1;Count=<5;Count++,Number
int Num,Rndnum; -= 3)
15 XII Computer
if(Number % dividor = = 0) entered by the user is 14, choose the
cout<<Number / Dividor; correct possible output(s) from the
cout<<endl; options from (i) to (iv), and justify your
else option.
cout<<Number + Dividor <<endl; 2
Ans: //Program:GAME.CPP
#include<iostream.h> #include<stdlib.h>
const int dividor= 5; #include<iostream.h>
void main( ) void main( )
{ { randomize( );
int Number = 15; int Num,Rndnum;
for(int Count=1;Count<=5;Count++,Number cin>>Num;
-= 3) Rndnum=random(Num)+7;
if(Number % dividor = = 0) for(int N=1;N<=Rndnum;N++)
{ cout<<Number / Dividor; cout<<N<<” “;
cout<<endl; }
} Output Options:
else (i) 1 2 3 (ii) 1 2 3 4 5 6 7 8 9 10
cout<<Number + Dividor <<endl; 11
} (iii) 1 2 3 4 5 (iv) 1 2 3 4
Ans: Expected Output
1.e) Find the output of the following (ii) 1 2 3 4 5 6 7 8 9 10
program 2
#include<iostream.h> 11
#include<string.h>
#include<ctype.h> 1.d) Find the output of the following
void Change(char Msg[],int Len) program:
S)
toupper(Msg[Count]); };
m
Ku
Msg[Count] = { cout<<M.Length<<”x”<<M.Breadth<
nd
<”x”;
re
tolower(Msg[Count]);
Vi
16 XII Computer
(ii)strcmp( ) - string.h else
(iii)abs( ) - math.h, { sum=sum-f/(pow(x1,c));
stdlib.h,complex.h }
(iv)isalnum( ) - ctype.h }
return sum;
1.e) What will be the output of the }
following program
#include<iostream.h> 1.c) Rewrite the corrected code for the
void main( ) following program. Underline each
{ int var1=5,var2=10; correction if any.
for(int i=1,i<=2;i++)
{ cout<<var1++<<’\t’<< - - var2<<endl; #include<iostream.h>
cout<<var2- -<<’\t’<<+ + var1<<endl; structure Supergym
} { int member number;
} char membername[20];
Ans: Output: char membertype[]=”HIG”;
5 9 };
void main( )
9 7 { Supergym person1,person2;
7 7 cin>>”Member Number: “;
7 9 cin>>person1.membhernumber;
cout<<”Member Name: “;
f)Write definition for a function cin>>person1.membername;
SumSequence( ) in C++ with two person1.member type = “MIG”;
arguments/ parameters – double X and person2=person1;
int n. The function should return a value cin>>”Member Number;“
of type double and it should perform sum <<person2.membernumber;
S)
C
of a number ie 5!= 1 X 2 X 3 X 4 X 5. }
er
nd
#include<iostream.h>
re
#include<math.h> Ans:#include<iostream.h>
Vi
#include<conio.h> #include<string.h>
double SumSequence(int x1,int n1); struct Supergym
void main() { int membernumber;
{ int x; char membername[20];
int n; char membertype[4];
clrscr(); };
cout<<"Enter the vaue of X and N"; void main( )
cin>>x>>n; { Supergym person1,person2;
cout<<”\nThe sum of the series = cin>>"Member Number: ";
“<<SumSequence(x,n);
getch(); cin>>person1.membernumber;
} cout<<"Member Name: ";
double SumSequence(int x1,int n1) cin>>person1.membername;
{ double sum=0;
int c=0; strcpy(person1.membertype,"MIG");
for(int i=1;i<=(2*n1);i=i+2) person2=person1;
{ int f=1; cin>>"Member Number;"
for(int j=1;j<=i;j++) >>person2.membernumber;
{ f=f*j; cin>>"Member Name"
} >>person2.membername;
c=c+1; cin>>"Member Number:"
if(c%2==1) >>person2.membertype;
{ sum=sum+f/(pow(x1,c)); }
}
17 XII Computer
2003 Annual Paper: switch(I)
{ case 0:
1.a) What is the difference between case 3:cout<<P[I]*Q<<endl; break;
global variables and local variables? Give case 1:
an example to illustrate the same. case 2: cout<<P[I]+Q;
2 }
Ans: The local variables are the variables }
defined within any function (or block)
and are hence accessible only within the 1.e) Write the output of the following
block in which they are declared. In program:
contrast to local variables, variables #include<iostream.h>
declared outside of all the functions in a int Execute(int M)
program are called global variables. { if(M%3==0)
These variables are defined outside of return M*3;
any function, so they are accessible to all else
functions. These functions perform return M+10;
various operations on the data. They are }
also known as External Variables. void Output(int B=2)
Eg: #include<iostream.h> { for(int T=0;T<B;T++)
int a,b; cout<<Execute(T)<<”*”;
void main() cout<<endl;
{ float f; }
---; void main( )
---; { Output(4);
} Output( );
In the above program segment, a and b Output(3);
}
S)
main( ) only.
m
1.b) Name the header file, to which the as double to find the sum of the series
er
nd
18 XII Computer
upper=pow(y1,(i*2-1)); cin>>x;
sum=sum+upper/f; for( int y=0;y<10;y++)
} cout<<x+y;
return sum; }
}
1.d)Write the output of the following
1.d) Give the output of the following program2
program: void main( )
#include<iostream.h> { int x=5,y=5;
struct Pixel cout<<x- -;
{ int C,R; cout<<”,”;
}; cout<- - x;
void Display(Pixel P) cout<<”,”;
{ cout<<y- -<<”,”<<- -y;
cout<<”col”<<P.C<<”Row”<<P.R<< }
endl; Ans: Output:
} 5,3,4,4
void main( )
{ 1.e)Write the output of the following
Pixel X={40,50},Y,Z; program 3
Z=X; #include<iostream.h>
X.C+=10; void X(int &A,int &B)
Y=X; { A=A+B;
Y.R+=20; B=A-B;
Z.C-=15; A=A-B;
Display(X); }
Display(Y);
S)
void main( )
C
} X(a,b);
(P
ar
cout<<a<<”,”<<b;
m
2002: }
Ku
Ans: Output:
er
nd
18,4
re
1.e) Give the output of the following 1.e)Give the output of the following
program: program. 3
#include<iostream.h>
#include<conio.h> #include<iostream.h>
int g=20; #include<conio.h>
void func(int &x,int y) int g=20;
{ x=x-y; void func(int &x,int y)
y=x*10; { x=x-y;
cout<<x<<’,’<<y<<’\n’; y=x*10;
cout<<x<<’,’<<y<<’\n’;
S)
}
C
void main( ) }
T
G
{ int g=7;
ar
func(g,::g);
m
cout<<g<<’,’<<::g<<’\n’; func(g,::g);
Ku
func(::g,g); cout<<g<<’,’<<::g<<’\n’;
er
nd
cout<<g<<’,’<<::g<<’\n’; func(::g,g);
re
} cout<<g<<’,’<<::g<<’\n’;
Vi
Ans: Output: }
-13,-130
2000:
-13,20
33,330 1.b) Name the header file, to which
-13,33 following built in function belong:
2
1.f) Write a function named SUMFIN( ), (i) isupper( ) ( ii)setw()
with arguments x, N, which returns the (iii)exp( ) (iv)strcmp( )
sum of N terms of the following series.: Ans) (i) isupper( ) - ctype.h
4 (ii)setw( ) - iomanip.h
x – x^3/3 + x^5/5 – x^7/7 + x^9/9 (iii)exp( ) - math.h
#include<iostream.h> (iv)strcmp( ) - string.h
#include<math.h>
#include<conio.h> 1.c)Will the following program execute
double SUMFIN(int x1,int n1); successfully?If not, state the eason(s) 2
void main() #include<stdio.h>
{ int x; void main( )
int n; { int s1,s2,num;
clrscr(); s1=s2=0;
cout<<"Enter the vaue of X and N"; for(x=0;x<11;x++)
cin>>x>>n; { cin<<num;
cout<<”\nThe sum of Series = if(num>0)s1+=num;else
“<<SUMFIN(x,n); s2=/num;
20 XII Computer
} q=func(p);
cout<<s1<<s2; cout<<p<<q<<endl;
} }
Ans: The program will not execute Ans: Output: 2023
successfully.
Because some syntax errors are there in
1023
the program. They are 1111
(i)cin and cout, stream objects used but
iostream.h header file is not included in f) Write a function seqsum( ) in C++ with
the program. two arguments, double x and int n. The
(ii)x is not declared, it should be declared function should return a value of type
as int. double and it should find the sum of the
(iii)With cin, we should use >> instead of following series. 4
<<. 1+ x/2! + x2/4! + x3/6! + x4/8! + x5/10! + ----+
xn/(2n)!
(iv)The shorthand operator /=, is given
#include<iostream.h>
wrongly as =/.
#include<math.h>
#include<conio.h>
So the corrected program is as follows:
double seqsum(int x1,int m1);
#include<iostream.h>
void main()
void main( )
{ int x;
{ int s1,s2,num;
int m;
s1=s2=0;
clrscr();
for(int x=0;x<11;x++)
cout<<"Enter the vaue of X and M";
{ cin>>num;
cin>>x>>m;
if(num>0)s1+=num;else s2/=num;
cout<<"\nThe sum of the series =
}
"<<seqsum(x,m);
cout<<s1<<s2;
S)
getch();
C
}
}
T
G
(P
{ double sum=1;
m
for(int i=1;i<=m1;i++)
header files are included in the program):
er
{ int f=1;
nd
2
for(int j=1;j<=2*i;j++)
re
{ f=f*j;
for(int x=0;x<strlen(NAME);x++)
}
if(islower(NAME[x]))
sum=sum+pow(x1,i)/f;
NAME[x]=toupper(NAME[x]);
}
else if(isupper(NAME[x]))
return sum;
if(x%2!=0)
}
NAME[x]=tolower(NAME[x-1]);
else
NAME[x]--; 1999 Annual Paper:
cout<<NAME<<endl;
1.a) Why main( ) function is so special.
Ans: Output: AOROoIiE Give two reasons?
1
1.e)Write the output of the following Ans: Execution of the program starts and
program3 ends at main( ). The main( ) is the driver
#include<iostream.h> function of the program. If it is not
int func(int &x,int y=10) present in a program, no execution can
{ if(x%y==0) return ++x;else return y- take place.
-;
} 1.b) Name the header file of C++ to which
void main( ) following functions belong. (i)strcat( )
{ int p=20,q=23; (ii) scanf( ) (iii) getchar( )
q=func(p,q); (iv)clrscr( )
cout<<p<<q<<endl; Ans: (i)strcat( ) - string.h
p=func(q); (ii)scanf( ) - stdio.h
cout<<p<<q<<endl; (iii)getchar( ) - stdio.h
21 XII Computer
(iv)clrscr( ) - conio.h x=n/10;
y=n%10;
1.c) Find the syntax error(s), if any, in the binary(x);
following program: binary(y);
#include<iostream.h> getch( );
main( ) }
{ int x[5],*y,z[5];
for(i=0;i<5;i++) 1998 Annual Paper:
{ x[i]=i;
z[i]=i+3; 1.b)Name the header files, to which the
y=z; following built in functions belongs to:
x=y; (i)cos( ) (ii)setw( )
} (iii)toupper( ) (iv)strcpy( )
} Ans: (i) cos( ) - math.h
Ans (i) Line No 5: Undefined symbol ‘i’. (ii) setw( ) - iomanip.h
The variable ‘i’ is not declared in the (iii) toupper( ) - ctype.h
program. (iv) strcpy( ) - string.h
(ii)Line No 10:Assign the value of a
pointer to an integer variable. Ie error in 1.c)Find the syntax error(s), if any, in the
x=y. following program:
include<iostream.h>
1.e) Write the output of the following void main( )
program. { int R; W=90;
#include<iostream.h> while W>60
static int i=100; { R=W-50;
void abc( ) switch(W)
{ static int i=8;
S)
{ 20:cout<<”Lower Range”<<endl;
C
} 40:cout<<”Higher Range”<<endl;
(P
main( )
ar
} }
m
abc( ); Ans:
er
nd
}
Vi
#include<iostream.h>
Ans: Output: (ii) Line 4:Variables should be
First =8second =2 separated using commas.
It should be int R,W=90;
1.f) Write a C++ function that converts a (iii) Line 5:Test expression
2-digit octal number into binary number should be in braces. It
and prints the binary equivalent. should be while (W>60)
#include<iostream.h> (iv) Line 10:It should be case
#include<conio.h> 20;
void binary(int a) (v) Line 11:It should be case
//member function for conversion 30;
{ int i,b[5]; //integer array 6 (vi) Line 13:It should be case
for(i=3;i>=1;i--) 40;
{ b[i]=a%2;
a=a/2; So the corrected version of the program is as
follows:
}
#include<iostream.h>
for(i=1;i<=3;i++)
void main( )
cout<<b[i];
{ int R, W=90;
}
while (W>60)
void main()
{R=W-50;
{ int n,x,y;
switch(W)
clrscr( );
{ case 20:cout<<”Lower Range”<<endl;
cout<<"Enter a two digit octal number:
case 30:cout<<”Middle Range
";
“<<endl;
cin>>n;
22 XII Computer
case 40:cout<<”Higher Range”<<endl; {
} } clrscr( );
} float x1;
int n1;
1.d) Give the output of the following program cout<<"\nEnter the value of X and N";
segment: char *NAME=”IntRAneT”; cin>>x1>>n1;
for(int x=0;x<strlen(NAME); x++) cout<<"\nThe Sum of the Series
if(islower(NAME[x]) ..."<<sum_series(x1,n1);
NAME[x]=toupper(NAME[x])); getch( ); }
else if(isupper(NAME[x]))
if(x%2==0) Model Paper 1 for 2008-09
NAME[x]=tolower(NAME[x]);
else
Batch:
NAME[x]=NAME[x-1];
Q1. (a) What is the difference between
puts(NAME);
Global Variable and Local Variable?
Ans: Output: INTTaNEE 2
Answer:
1.f) Write the output of the following Global Variable Local Variable
program: • It is a variable, • It is a variable,
#include<iostream.h> which is declared which is declared
void Execute(int &X,int Y=200) outside all the with in a function
{ int TEMP=X+Y; functions or with in a
X+=TEMP; compound
if(Y!=200) statement
cout<<TEMP<<X<<Y<<endl;
• It is accessible • It is accessible
}
throughout the only within a
S)
void main( )
program function/compoun
C
{ int A=50,B=20;
T
d statement in
G
Execute(B);
(P
which it is
ar
cout<<A<<B<<endl;
declared
m
Execute(A,B);
Ku
#include <iostream.h>
cout<<A<<B<<endl;
er
}
re
void LOCAL(int T)
Vi
T[i]='#'; Changethecontent(A,3);
er
Changethecontent(B,4);
nd
else if (islower(T[i]))
re
T[i]=toupper(T[i]); Changethecontent(C,2);
Vi
1.f)In the following program, if the value 1.b) Which C++ header file(s) will be
of N given by the user is 20, what essentially required to be included to
maximum and minimum values the run /execute the following C++ code:
program could possibly display? 1
2 void main()
#include <iostream.h> {
#include <stdlib.h> char Msg[ ]="Sunset Gardens";
void main() for (int I=5;I<strlen(Msg);I++)
{ int N,Guessnum; puts(Msg);
randomize(); }
S)
cin>>N;
C
Guessnum=random(N-10)+10;
G
(P
}
m
program:3
Ku
struct GAME
re
Value:10 {
Vi
A) #agaSbarr
C
2
Vi
2
#include <iostream.h>
#include <iostream.h>
#include <stdlib.h>
struct Pixels
void main()
{ int Color,Style;}
{
void ShowPoint(Pixels P)
int Guess;
{ cout<<P.Color,P.Style<<endl;}
randomize();
void main()
cin>>Guess;
{
for (int I=1;I<=4;I++)
Pixels Point1=(5,3);
{
ShowPoint(Point1);
New=Guess+random(I);
Pixels Point2=Point1;
cout<<(char)New;
Color.Point1+=2;
}
ShowPoint(Point2);
}
}
(i) ABBC
(ii) ACBA
Ans:
(iii) BCDA
#include <iostream.h> 2
(iv) CABD
struct Pixels
A)
{
(i) ABBC int Color,Style;
};
Sample Paper 2 for 2009-10 void ShowPoint(Pixels P)
Batch: {
cout<<P.Color<<P.Style<<endl;
26 XII Computer
} cout<<N.Magic<<N.Score<<endl;
void main() }
{ A)
Pixels Point1={5,3}; TiLeP550
ShowPoint(Point1);
Pixels Point2=Point1;
AiLJP430
Point1.Color+=2;
(f) In the following program, if the value
ShowPoint(Point2);
of N given by the user is 20, what
}
maximum and minimum values the
program could possibly display?
2
(d) Find the output of the following
program: 3
#include <iostream.h>
#include <iostream.h>
#include <stdlib.h>
void Changethecontent(int Arr[ ], int
Count)
{
void main()
for (int C=1;C<Count;C++)
{
Arr[C-1]+=Arr[C];
int N,Guessnum;
}
randomize();
void main()
cin>>N;
{
int Guessnum=random(N-10)+10;
A[]={3,4,5},B[]={10,20,30,40},C[]={900,1200} cout<<Guessnum<<endl;
; }
Changethecontent(A,3); A)
Changethecontent(B,4); Maximum Value: 19 Minimum Value: 10
S)
Changethecontent(C,2);
C
T
for (L=0;L<4;L++) cout<<B[L] <<'#'; Name the header files that shall be
m
Ku
Model Paper 1:
C
Lord
ar
Model Paper 2:
m
give an example in C++ to illustrate both. Ans: A class groups its members into
C
of data and functions together in a single members remain hidden from outside
m
class, we wrap up the data and functions protected members, a class enforces data
er
nd
together in a single unit. – hiding. (The outside world is given only the
re
Data Hiding: Keeping the data in essential and necessary information through
Vi
private/protected visibility mode of the public members, rest of the things remain
class hidden, which is nothing but abstraction. The
to prevent it from accidental change is act of representing only essential features
without including background details is
known as Data Hiding.
known as abstraction.)
class Computer Eg: class ABC
{ char CPU[lO] ;int RNM; //Data { private: int a,b;
Hiding protected: int c,d;
public: //Data public: int e,f;
Encapeulation void disp( )
void STOCK(); {
void SHOW(); ----
}; }
-----
}
2009 Outside Delhi: In the above class public members(ie
e,f and disp( )) only will be available to
2. (a) What is function overloading? Give outside the class.. The other private
an example in C++ to illustrate function members (a,b), protected members (c,d)
overloading. will not be available to outside the class.
2 This concept is called data hiding.
Ans Function overloading is an example
of polymorphism, where the functions
having same name with different set of
2005 Outside Delhi:
parameters perform different operations.
OR
29 XII Computer
2.a) Define the term Data Encapsulation Ans:Polymorphism is the attribute that
in the context of Object Oriented allows one interface to be used with
Programming. Give a suitable example different situation.C++ implements
using a C++ code to illustrate the same. polymorphism through virtual functions,
2 through overloaded functions and
Ans: Encapsulation is wrapping up of overloaded operators.
characteristics and behavior into one A virtual function is used to specify
unit. While implementing encapsulation, the interface in abstract class, but its
following things are taken care: implementation details are made
a) Anything that an object does not available by the concrete class(es).
know or An overloaded function refers to a
cannot do is excluded from the function having (one name and) more
objects. than one distinct meanings. Similarly,
b)Encapsulation is used to hide when two or more distinct meanings are
unimportant defined for an operator, it is said to be an
implementation details from other ‘overloaded operator’. It is the compiler’s
objects. job to select the specific action as it
c)Packaging an object’s variables within applies to each situation.
the protective custody of its methods Eg: The program in the next answer.
is called encapsulation and this task is
accomplished through classes. Ie the 2003:
data and associated functions are
wrapped up in one unit called
class. 2.a) What do you understand by function
A class binds together data and overloading? Give an example illustrating
its associated functions under one unit its use in a c++ program.
thereby enforcing encapsulation.
S)
Eg:class Rectangle
T
}
re
void calculate( )
reduces number of comparisons in a
{ area=len*bre;
}
program and thereby makes the program
void display( ) run faster.
{ cout<<”\nThe area of the rectangle =
“<<area; Example program illustrating function
} overloading:
};
Eg: Here in the above class the data //Program to find out area of a circle or
members ie len,bre,area and the member area of //rectangle using function
functions ie readData( ), calculate( ), overloading.
display( ) are bind together in a class
named as Rectangle. Ie The member #include<iostream.h>
functions can access any data member in #include<conio.h>
the class. void area(float r)
Benefits with encapsulation: {
(i) Modularity. cout<<”\nThe area of the circle =
(ii) Information hiding. “<<3.1415*r*r; }
void area(float l,float b)
2004: {
cout<<”\nThe area of the rectangle
1.a) What is polymorphism? Give an =
example in C ++ to show its “<<l*b; }
implementation in C++. void main( )
{
float rad,len,bre;
30 XII Computer
int n; Model Paper 1 for 2008-09
clrscr( );
cout<<”\n1. Area of a Circle…”;
Batch:
cout<<”\n2. Area of a Rectangle…”;
Q2.(a) What do you understand by
cout<<”\n\nEnter your choice: “;
Data Encapsulation and Data Hiding?
cin>>n;
2
switch(n)
Answer:
{
case 1: cout<<”\nEnter the radius: Data Encapsulation: Wrapping up
“; of data and function together in a
cin>>rad; single unit is known as Data
area(rad); Encapsulation. In a class, we wrap
break; up the data and function together
case 2: cout<<”\nEnter the length in a single unit.
and breadth: “; Data Hiding: Keeping the data in
cin>>len>>bre; private visibility mode of the class
area(len,bre); to prevent it from accidental
break; change is known as Data Hiding.
default: cout<<”\nYou have to
enter class Computer
either 1 or 2”; {
} //end of switch char CPU[10]; Data Hiding
getch( ); int RAM;
} public:
void STOCK();
void SHOW();
2000: };
Data Encapsulation
S)
C
Batch:
ar
1
m
Procedural Programming?
1.a) Define the following terms: 2
(i) Inheritance (ii)Encapsulation.
Ans:a) Inheritance: The capability of Answer:
one class to inherit properties from
another class is called as inheritance.The Object Oriented Procedural Programming
class inheritance, lets you generate a Programming
model that is closer to the real world. • Emphasis on Data • Emphasis on doing
things (functions)
The class inheritance lets you derive new
• Follows Bottom-Up • Follows Top-down
classes (derived class) from old ones
approach in approach in program
(base class), with the derived class program design design
inheriting the properties, including the • Data hiding feature • Presence of Global
methods of the old class. prevents accidental variables increase
Uses of Inheritance: change in data chances of accidental
i)Capability to express the inheritance change in data
relationship which ensures the closeness • Features like data • Such features are not
with the real world models. encapsulation, available
ii) Reusability. polymorphism,
iii)Transitive nature of inheritance. inheritance are
b) Encapsulation: The wrapping up of present
data and functions into a single unit
(class) is called as encapsulation. 2.(a)What do you understand by
Polymorphism? Give a suitable example
of the same.
2
31 XII Computer
Answer: (method) to work using different set of
Polymorphism: It is a method of inputs. Function overloading is one of the
using the same operator or examples of polymor-phism, where more
function (method) to work using than one function carrying same name
different sets of input. Function behave differently with different set of
overloading is one of the example parameters passed to them.
of polymorphism, where more
than one function carrying same void Display()
name behave differently with {
different set of parameters cout<<"Hello!"<<endl;
passed to them. }
void Display() void Display(int N)
{ {
cout<<”Hello!”<<endl; cout<<2*N+5<<endl;
} }
void Display(int N) “The moment which is lost,
{ is lost for ever.
cout<<2*N+5<<endl; So utilize the time
} properly”
give a suitable C++ code to illustrate both. code after removing the syntax error(s)
T
G
2
ar
m
{
nd
stock)
C
{
T
long FlightCode;
(P
item)
char Description[25];
ar
public
Ku
following rule:
nd
{
re
If Qty<=50 Offer is 0
cin>>FlightCode; gets (Description) ;
Vi
If 50<Qty<=100 Offer is 5
{
If Qty>100 Offer is 10
void ShowInfo ()
Public Members
(
_ A function GetStock() to allow user to
cout<<FlightCode<<“:”<<Description<<e
enter values for Code, Iname, Price, Qty
ndl;
and call function GetOffer() to calculate
}
the offer
};
_ A function ShowItem() to allow user to
void main()
view the content of all the data members
{
Ans.
FLIGHT F;
class ITEM
AddInfo.F(); ShowInfo.F();
{
}
int Code;
Ans.
char Iname [20] ;
#include <iostream.h> / / Error 1
float Price;
#include <stdio.h> / / Error 2
int Qty;
class FLIGHT
float Offer;
{
void GetOffer() ;
long FlightCode;
public:
//not required if gets( ) is re-placed
void GetStock ()
with
{
//cin.getline( ) or cin
cin>>Code;
char Description[25];
gets (Iname) ;
// OR cin.getline (Iname, 80) ; OR cin>>Iname;
public : / / Error 3
cin>>Price>>Qty; void AddInfo ( )
33 XII Computer
{ void STOCK::FindDisc()
cin>>FlightCode; gets (Description) ; {
} if (Qty<=50)
void ShowInfo ( ) Discount=0;
{ else if (Qty<=100)
cout<<FlightCode<<”:”<<Description Discount=5; // =0.05;
<<endl; Else
} Discount=10; // =0.1;
}; }
void main ( ) void STOCK::ShowAll()
{ {
FLIGHT F; cout<<ICode<<’\t’<<Item<<’\t’<<Price<<’\t’<
F.AddInfo( ) ; <Qty
F. ShowInfo ( ) ; / / Error 4 <<’\t’<<Discount<<endl;
} }
charges
T
rule:
G
values for ICode, Item, Price, Qty and call then as 1.02*Days*Charges
function FindDisc() to calculate the
Discount. Public Members
_ A function ShowAll() to allow user to _ Getinfo ( ) //A function to enter the
view the content of all the data members. content
Ans. Rno, Name ,Charges and Days
_ Dispinfo ( ) //A function to display Rno,
class STOCK Name,
{ Charges,Days and Amount (Amount
int ICode,Qty; to be
char Item[20]; displayed by calling function
float Price,Discount; COMPUTE ( ) )
void FindDisc();
public:
void Buy();
void ShowAll();
}; Ans
void STOCK::Buy() class RESORT
{ {
cin>>ICode; int Rno;
gets(Item); char Name [20];
cin>>Price; float Charges;
cin»Qty; int Days;
FindDisc(); float COMPUTE();
}
34 XII Computer
public: MyStudent( )
void Getinfo() ; {
void Dispinfo(); StudentId = 1001;
}; }
void RESORT::Getinfo() void Register( )
{ {
cin>>Rno; cin>>StudentId;
gets (Name); gets (Name);
cin>>Charges; }
cin>>Days; void Display ()
} {
void RESORT::Dispinfo() cout«StudentId<<”:“<<Name<<e
{ ndl;
cout<<Rno<<” “<<Name<<“ “<<Charges<<” }
“<<Days<< COMPUTE()<<endl; };
} void main ()
float RESORT::COMPUTE(} {
{ MyStudent MS;
float Amount = Charges*Days; MS. Register ();
if (Amount>11000) MS. Display () ;
Amount = }
1.02*Days*Charges;
return Amount; 2. (c) Define a class HOTEL in C++ with
} the following description:
4
2009 Outside Delhi: Private Members:
_ Rno //Data member to store Room No
S)
C
1.(c) Rewrite the following program after _ Name //Data member to store customer
T
G
2 charges
Ku
35 XII Computer
void Checkout() ; void Register( )
}; { cin>>StudentId;
float HOTEL::CALC() gets(Name);
{ }
float Amount = Tariff*NOD; void Display( )
if (Amount>10000) { cout<<StudentId<<":"<<Name<<endl
Amount = ;
1.05*NOD*Tariff; }
return Amount; };
} void main( )
void HOTEL::Checkin() { MyStudent MS;
{ MS.Register( );
cin>>Rno; MS.Display( );
gets (Name); }
cin>>Tariff;
cin>>NOD; 2008 Delhi:
}
void HOTEL::Checkout() 2.a) Differentiate between public and
{ private visibility modes in context of
cout<<Rno<<” “<<Name<<“
Object Oriented Programming using a
“<<Tariff<<”
“<<NOD<<CALC suitable example illustrating each.
()<<endl;
} Ans: public and private visibility
modes in context of OOP:
1.c) Rewrite the following program after The visibility mode (private or public or
removing the syntactical errors (if any). protected) in the definition of the derived
S)
2
G
include <stdio.h>
members of base class, in the derived
er
class MyStudent
nd
char Name[20];
public Public visibility mode: The public
MyStudent( ) { } derivation means that the derived class
void Register( ) can access the public and protected
{ cin>>StudentId; members of the base class but not the
gets(Name); private members of the base class. With
} publicly derived class, the public
void Display( ) members of the base class become the
{ cout<<StudentId<<”:”<<Name<<endl public members of the derived class, and
; the protected members of the base class
} become the protected members of the
}; derived class.
void main( )
{ MyStudent MS; Private visibility mode: The private
Register.MS( ); derivation means, the derived class can
MS.Display( ); access the public and private members of
} the base class privately. With privately
Ans: derived class, the public and protected
#include <iostream.h> members of the base class become
#include <stdio.h> private members of the derived class.
class MyStudent That means the inherited members can
{ int StudentId; be accessed only through member
char Name[20]; functions of the derived class.
public:
MyStudent( ) { }
36 XII Computer
Visibilit Inheritable Inheritabl Private derived class, the public and protected
y Mode public e member ofmembers of the base class become
member protected base classprivate members of the derived class.
becomes ( in member are not That means the inherited members can
derived becomes directly be accessed only through member
class) (in derived accessiblefunctions of the derived class.
class) to derivedProtected visibility mode: The
public Public protected class. protected derivation means that the
private Private private derived class can access the public and
e private members of the base class
protectedly. With protectedly derived
public and private access specifiers in
class, the public and protected members
context of OOP: public access specifier is
of the base calss become protected
used to define any method or a variable
members of the derived class. That
which may be accessed by any member
means the inherited members are now
function of the same class and also from
not available to the outside world and
outside the class. Private access specifier
can be accessed only through the
is used to make any variable or a method
member functions of the derived class
which has a limited access within the
and the classes based upon the derived
class only.The concept of data hiding is
classes. These members can be inherited
implemented through the private access
further if any classes are inheriting from
specifier only.
the derived class.
Eg:
class student Visibility Inheritabl Inheritabl Private
{ private: Mode e public e member of
int rno; member protected base class
char name[21]; becomes member are not
( in becomes directly
S)
public:
C
void input( );
class.
ar
Here, since rno and name are declared in private and protected access specifiers
nd
the class. Since age,input( ) and private access specifier is used to make
display() are declared in public, they can any variable or a method which has a
be accessed from outside class also. limited access within the class only.
At the time of inheritance, these variables
2008 Outside Delhi: cannot be accessed (inherited) to the
derived class.
2.a) Differentiate between private and protected access specifier is used to make
protected visibility modes in context of any variable or a method which has a
object oriented programming using a limited access within the class only (here
suitable example illustrating each. like private). But at the time of
Ans: private and protected visibility inheritance, these variables can be
modes in context of OOP: inherited to the derived class.
The visibility mode (private or public or Except regarding inheritance, both access
protected) in the definition of the derived specifiers ie private and protected will
class specifies whether the features of the work same.
base class are privately derived or Eg:
publicly derived or protected derived. class student
The visibility modes basically control the { private:
access specifier to be for inheritable int rno;
members of base class, in the derived char name[21];
class. protected:
Private visibility mode: The private int age;
derivation means, the derived class can void input( );
access the public and private members of void display( );
the base class privately. With privately }
37 XII Computer
Here, since rno and name are declared in };
private, they can be accessed only inside void ADMISSION::Draw_Nos( )
the class. Since age,input( ) and display() { //Dear Students, a test for you.
are declared in protected, they also can Complete this member function.
be accessed only inside the class but they
can be inherited, where as private }
members (rno and name) cannot be
inherited. 2006 Outside Delhi:
2006 Delhi: 1.b) Illustrate the use of Inline function in
C++ with the help of an example.
2.c) Define a class named ADMISSION in 2
C++ with the following descriptions:
Ans: INLINE FUNCTIONS: The inline
Private Members: functions are a C++ enhancement
AD_NO integer(Ranges 10 – 2000) designed to speed up programs. The
NAME Array of characters(String) coding of normal functions and inline
CLASS Character functions is similar except that inline
FEES Float functions definitions start with the
keyword inline.
Public Members: The working of inline functions:
Function Read_Data( ) to read an object After writing any program, it is
of ADMISSION type. Function Display( ) first compiled to get an executable code,
to display the details of an object. which consists of a set of machine
Function Draw-Nos.( ) to choose 2 language instructions. When this
students randomly. And display the executable code is executed, the
S)
details. Use random function to generate operating system loads these instructions
C
Ans:
ar
{ int AD_NO;
After loading the executable
er
char NAME[31];
nd
char CLASS;
Vi
Inline functions are best for small cout<<"\nThe Cost of the House:
functions that are called often.The "<<COST;
compiler may even ignore your attempt }
to linline a function if it consists more void Draw_Nos();
than 50 lines of code. };
void HOUSING::Draw_Nos( )
2. c) Define a class named HOUSING in C+ { //Dear Students, a test for you.
+ with the following descriptions: Complete this member function.
4
}
Private Members:
REG_NO integer(Ranges 10- 2004 :
1000)
NAME Array of 2.b) Declare a class myfolder with the
characters(String) following specifications:
TYPE Character
COST Float Private members of the class:
Filenames an array of strig of
Public Members: size[10][25]
Function Read_Data( ) to rread an object (to represent all the names of files inside
of HOUSING type. myfolder)
Function Display( ) to display the details Availspace long
of an object. (to represent total number of bytes
available in myfolder)
39 XII Computer
Usedspace long name of the function must be the full
(to represent total number of bytes used name including the class name as well.
in myfolder) When a member function is defined
inside the class, the name of the function
Public members of the class: is similar to an ordinary function but it
Newfileentry() : A function to accept will become an inline function.
values of Filenames, Availspace and
Usedspace from user. 2.b) Define a class Student for the
Retavailspace(): A function that returns following specifications.
the value of total kilobytes available Private members of the Student are:
(1 kilobyte=1024 bytes) roll_no integer
Showfiles( ): A function that displays the name array of characters of size 20
names of all the files in myfolder class_st array of characters of size 8
marks array of integers of size 5
Ans: Percentage float
class myfolder Calculate( ) that calculates overall
{ char Filenames[10][25]; percentage marks and returns the
long Availspace; percentage
long Usedspace; Public Members of the Student are:
public: Readmarks reads mark and invoke the
void Newfileentry( ) calculate function
{ Displaymarks prints the data.
cout<<"\nEnter any 10 file names: ";
for(int i=0;i<=9;i++) Ans:
{cout<<"\nEnter the "<<i+1<<" file class Student
name: "; { int roll_no;
gets(Filenames[i]); char name[20];
S)
C
} char class_st[8];
T
G
cin>>Usedspace; marks[3]+marks[4])/5;
Vi
} return percentage;
long RetavailSpace( ) }
{ ret Availspace; public:
} void Readmarks( )
void Showfiles( ) { cout<<”\nEnter any 5 subject marks;
{ cout<<"\nThe names of the files in cin>>marks[0]>>marks[1]>>marks[2]
myfolder object...."; >>
for(i=0;i<=9;i++) marks[3]>>marks[4];
{ puts(Filenames[i]); calculate( );
cout<<endl; }
} void Displaymarks( )
} { cout<<”\nThe Roll Number of the
Student: “<<roll_no;
2002: cout<<”\nThe Name of the Student:”
<<name;
2.a) What do you understand about a cout<<”\nThe class of the Student: “
member function? How does a member <<class_st;
function differ from an ordinary cout<<”\n5 subject marks of the
function? student…\n”;
Ans: A member function is a function cout<<marks[0]<<”\t”<<marks[1]<<”
declared within a class. It is said to be \t”<<
defined in two ways. Ie Outside the class marks[2]<<”\t”;
and inside the class. When a member cout<<marks[3]<<”\t”<<marks[4]<<”
function is defined outside the class, the \n”;
40 XII Computer
cout<<”Percentage =”<<percentage; cout<<”\nWithdraw is not
} possible”;
}; else
{ bal_amount=bal_amount-
2001: w_amount;
cout<<”\nThe balance is
2.b) Declare a class to represent bank “<<bal_amount-w_amount;
account of 10 customers with the }
following data members. Name of the }
depositor, account number, type of void display( )
account (S for Savings and C for Current), { cout<<”\nName of the depositor: “
Balance amount. The class also contains <<name;
member functions to do the following: cout<<”\nAccount Number:
(i)To initialize data members. “<<acc_no;
(ii) To deposit money cout<<”\nAccount Type:
(iii)To withdraw money after checking “<<acc_type;
the balance (minimum balance is cout<<”\nThe balance amount is
Rs.1000) “<<bal_amount;
(iv) To display the data members. }
[Note:You are also required to give };
detailed function definitions.]
class Bank 2000 :
{ char name[15];
int acc_no; 2.b) Define a class worker with the
char acc_type; following specification.
float bal_amount; 4
S)
cin>>acc_no; hrwrk*wgrate
re
Vi
salary and returns it. Salary is sum of Basic, data members on the screen.
T
G
DA and HRA
(P
class student
ar
m
} {
C
T
Answer:
G
CenterReqd=NoCandidate/100 +
(P
#include <iostream.h>
1;
ar
class PAYITNOW
m
}
Ku
{ int Charge;
void TEST::SCHEDULE()
er
public:
nd
cin>>TestCode;
Vi
void Show(){cout<<Charge;}
cout<<”Description :”;
};
gets(Description);
void main()
cout<<”Number :”;
{ PAYITNOW P;
cin>>NoCandidate;
P.Raise();
CALCNTR();
P.Show();
}
}
void TEST::DISPTEST()
{
Model Paper 1 for 2008-09 cout<<”Test
Batch: Code :”<<TestCode<<endl;
2.e)Define a class TEST in C++ with cout<<”Description :”<<Description<
<endl;
following description:
cout<<”Number :”<<NoCandidate<
4 <endl;;
Private Members cout<<”Centres :”<<CenterReqd<<
a. TestCode of type integer endl;;
b. Description of type string }
c. NoCandidate of type
integer
d. CenterReqd (number of
Model Paper 2 for 2008-09
centers required) of type Batch:
integer
e. A member function 2.d)Define a class in C++ with following
CALCNTR() to calculate description:
and return the number of 4
43 XII Computer
Private Members cout<<”Destination :”<<Destination<
*A data member Flight number of type <endl;
integer cout<<”Distance :”<<Distance<<en
*A data member Destination of type dl;;
string cout<<”Fuel :”<<Fuel<<endl;;
*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 Sample Paper 1 for 2009-10
following criteria Batch:
Distance 1.C ) Rewrite the following program after
Fuel removing the syntactical errors (if any).
<=1000 Underline each correction.
500 2
more than 1000 and <=2000 #include [iostream.h]
1100 class MEMBER
more than 2000 {
2200 int Mno;float Fees;
Public Members PUBLIC:
*A function FEEDINFO() to allow user to void Register(){cin>>Mno>>Fees;}
enter values for Flight Number, void Display{cout<<Mno<<" :
Destination, Distance & call function "<<Fees<<endl;}
CALFUEL() to calculate the quantity of };
Fuel void main()
*A function SHOWINFO() to allow user to {
view the content of all the data members MEMBER M;
Answer:
S)
Register();
C
{ int Fno; }
(P
char Destination[20];
ar
A)
m
void FEEDINFO();
Vi
public:
void SHOWINFO(); void Register()
}; {
void FLIGHT::CALFUEL() cin>>Mno>>Fees;
{ if (Distance<1000) }
Fuel=500; void Display()
else {
if (Distance<2000) cout<<Mno<<":"<<Fees<<end
l;
Fuel=1100; }
else };
void main()
Fuel=2200; {
} MEMBER M;
void FLIGHT::FEEDINFO() M.Register();
{cout<<”Flight No :”;cin>>Fno; M.Display();
cout<<”Destination :”;gets(Destinatio }
n);
cout<<”Distance :”;cin>>Distance;
2.c) Define a class TEST in C++ with
CALFUEL();
following description:
}
4
void FLIGHT::SHOWINFO()
Private Members
{
• TestCode of type integer
cout<<”Flight No :”<<Fno<<endl;
• Description of type string
• NoCandidate of type integer
44 XII Computer
• CenterReqd (number of centers • A data member Destination of type
required) of type integer string
• A member function CALCNTR() to • A data member Distance of type float
calculate and return the number of • A data member Fuel of type float
centers as • A member function CALFUEL() to
(NoCandidates/100+1) calculate the value of Fuel as per the
Public Members following criteria
• A function SCHEDULE() to allow user to Distance
enter values for TestCode, Fuel
Description, NoCandidate & call function <=1000
CALCNTR() to calculate the number of 500
Centres more than 1000 and <=2000
• A function DISPTEST() to allow user to 1100
view the content of all the data members more than 2000
A) 2200
class TEST Public Members
{ " A function FEEDINFO() to allow user to
int TestCode; enter values for Flight Number,
char Description[20]; Destination, Distance & call function
int NoCandidate,CenterReqd; CALFUEL() to calculate the quantity of
void CALCNTR(); Fuel
public: " A function SHOWINFO() to allow user to
void SCHEDULE(); view the content of all the data members
void DISPTEST(); A)
}; class FLIGHT
void TEST::CALCNTR() {
{ int Fno;
S)
C
{ public:
Ku
); };
Vi
45 XII Computer
cout<<"Distance :"<<Distance<<end the outside world (outside their class). A
l;; Constructor is used to initialize the
cout<<"Fuel :"<<Fuel<<endl;; objects of the class being created
} (automatically called by the compiler).
Constructor Member
Function
Name Name of the Class Any Valid
Identifier
Purpose Initialize the For any general
object when it is purpose
being created
Call Implicit Explicit
Return Should not keep Must be there at
type least void
A constructor is a member
function of a class with the same name as
that of its class name. A constructor is
defined like other member functions of a
class. It can be defined either inside the
5.CONSTRUCTORS & class definition or outside the class
S)
C
DESTRUCTORS definition.
T
G
(P
ar
MATERIAL
m
Eg: class X
Ku
int j,k;
Vi
46 XII Computer
}; having multiple constructors is called as
X :: X ( ) //Constructor constructor overloading.
defined outside
{ A constructor can also
i = j = k = 0; have default arguments. A constructor
} with default arguments is equivalent to a
default constructor.
Generally constructor will be
defined under public section, which can Eg: class Rectangle
be available to non members also. But it {
can also be defined under private or float l,b,a;
protected. A private or protected public:
constructor is not available to the non- Rectangle ( float len = 5.0, float bre =
member functions. Ie With a private or 5.0)
protected constructor, you cannot create //Constructor with Default arguments
an object of the same class in a non- {
member function. l = len;
b = bre;
There are three types of constructors }
-----
a) Non-parameterized or -----
Default Constructor };
b) Parameterized Constructor
c) Copy Constructors void main( )
{
a) Default constructor: Rectangle first(7.0,9.5);
Rectangle second;
S)
C
constructor. ----
ar
m
47 XII Computer
public:
Rectangle ( float len , float bre ) void test ( )
//Parameterized Constructor. {
{ l = len; Sample S1(2,5);
b = bre; //An object S1 created
} S1.print ( );
----- //Data values of S1 printed
----- Sample (4,9).print ( );
}; //Data values of a temporary
//sample instance printed
void main( ) }
{
Rectangle first(7.0,9.5); The primitive (fundamental)
---- types also have their own constructors.
---- When no values are provided, they use
} their default constructors but when you
provide initial values, the newly created
With a parameterized instance is initialized with the provided
constructor, the initial values must be value.
passed at the time of object created. This Eg: int a,b,c;
can be done in two manners: //Default constructor used
int i(3), j(4), k(5); //i,j,k
(i)By calling the constructor implicitly initialized
(implicit call)
Eg: Rectangle first(8.5,3.9); c) Copy Constructor:
(ii)By calling the construct or explicitly
(Explicit call) A copy constructor is a
S)
C
48 XII Computer
i = a; runtime. The benefit of dynamic
j = b; initialization is that it provides the
} flexibility of assigning initial values at run
Sample (Sample &s) //Copy time.
Constructor
{ Initialization of Const & Reference
i=s.i; Members:
j=s.j; If your class contains a constant and a
cout<<”Copy constructor reference as member field, then you need
Working\n”; to specify that through Member-
} Initialization List.
A constructor can initialize the
void print( ) constituent data members of its class
{ through a mem-initialization list that
cout<<i<<”\t”<<j<<”\n”; appears in the function header of the
} constructor.
-----
----- Eg:
};
class Test
void main( ) {
{ int a ;
Sample S1(4,9); char b;
//S1 initialized first constructor used public:
Sample S2(S1); Test(int i,char j):a(i), b(j);//a(i)
//S1 copied to S2. Copy constructor initializes member a with
called. //value i, b(j)….b
S)
C
//again. ….
ar
m
----- }
Ku
----- }
er
nd
49 XII Computer
{ initialized before any use is made
char fname[25]; of the object.
char lname[25]; 3. Constructor functions obey the
} S1; usual access rules. Ie private and
protected constructors are
class Test available only for member and
{ friend functions, however, public
int a,b; constructors are available for all
const int max; //const the functions. Only the functions
member that have access to the
Sname &name; //reference constructor of a class, can create
member an object of the class.
public: 4. No return type (not even void)
Test ( ):max(300),name(S1) can be specified for a constructor.
{ 5. They cannot be inherited, though
a=0; a derived class can call the base
b=10; class constructor.
} 6. A constructor may not be static.
------ 7. Default constructors and copy
}; constructors are generated(by
the compiler) where needed.
Mem-initialization lists are especially Generated constructors are
used in the following four cases: public.
8. Like other c++ functions,
(i)initialization of const members. constructors can also have default
(ii)initialization of reference members. arguments.
(iii)Invoking base class constructor. 9. It is not possible to take the
S)
C
member of a union.
Ku
The constructor of a class may also be 11. Member functions may be called
er
nd
50 XII Computer
the program terminates. A destructor 4.No argument can be provided to a
cleans up the storage (memory area of destructor, neither does it return any
the object) that is no longer accessible. value.
5. They cannot be inherited.
Eg: 6. A destructor may not be static.
7. It is not possible to take the address of
class Sample a destructor.
{ int i,j; 8. Member functions may be called from
Public: within a destructor.
Sample(int a, int b) //Constructor 9. An object of a class with a destructor
{ cannot be a member of a union.
i=a; j=b;
}
~Sample()
{
cout<<”Destructor at work\n”;
}
------ CONSTRUCTORS AND DESTRUCTORS
------ (PROGRAMS)
};
void main( ) 1.Program to find area of a circle using
{ class, constructor functions and
Sample s1(3,4); destructor.
//Local object s1 constructed with #include<iostream.h>
values 3 #include<conio.h>
// & 4 using Sample ( ) class Circle
----- { float r,a; //r and a are private
S)
C
} Constructor
Ku
{ r=0.0;
er
nd
}
Vi
51 XII Computer
{ cout<<"\nThe Radius of the Circle = void readProcess()
"<<r; { cout<<"\nEnter the 3 Subject marks
cout<<"\nThe Area of the Circle = of a
"<<a; student: ";
} cin>>m1>>m2>>m3;
}; total=m1+m2+m3;
void main() avg=total/3;
{ clrscr(); }
Circle c1; /*Default Constructor will be void display()
called implicitly. ie c1.r = 0.0 and c1.a = { cout<<"\nTotal Marks = "<<total;
0.0 */ cout<<"\nAverage Marks = "<<avg;
Circle c2(10.3); }
//Parameterized Constructor will be };
called //implicitly void main()
Circle c3(c2); {
//Copy Constructor will be called clrscr();
implicitly Student S1;
c1.take(); Student S2(50.5,90.0,75.5);
c1.calculate(); Student S3=S2;
c1.display(); S1.readProcess();
c2.display(); S1.display();
c3.display(); S2.readProcess();
getch(); S2.display();
} S3.display(); getch();
}
2. Program to process student data using
class concept, constructors and
S)
C
destructor.
T
G
#include<conio.h>
ar
m
class Student
Ku
{ float m1,m2,m3,total,avg; (b) Answer the questions (i) and (ii) after
er
public:
re
Student() 2
Vi
public: “<<EName<<endl;}
G
(P
Exam ( ) //Module 1 };
ar
{ void main ()
m
Ku
Rno=101; {
er
MaxMarks=l00; Employee E;
nd
re
MinMarks=40; Joining.E();
Vi
Marks=75; E.List()
} }
Exam (int Prno, int Pmarks) //Module
2
{ Ans
Rno=Prno; #include <iostream.h>
MaxMarks=l00; #include <stdio.h>
MinMarks=40; class Employee
Marks=Pmarks; { int EmpId;
} char EName[20];
~Exam () //Module 3 public :
{ Employee()
cout<<“Exam Over”<<endl; {
} EmpId=901;
void Show () //Module 4 }
{ void Joining( )
cout<<Rno<<“:”<<MaxMarks<<“:”<<MinMarks<< {
endl; cin>>EmpId;
cout<<“[Marks Got]”<<Marks<<endl; gets (EName);
} }
}; void List ( )
(i) As per Object Oriented Programming, {
which concept is illustrated byModule 1 cout<<EmpId<<”:
and Module 2 together? “<<EName<<endl;
Ans. }
53 XII Computer
}; Q.Disp();
void main () Play R=Q; //Copy constructor
{ ca11
Employee E; [same as P1ay R(Q);]
E.Joining (); R. Disp();
E.List (); }
}
(b) Answer the questions (i) and (ii) after
2.(a)What is copy constructor?Give ane going through the following class:
example in C++ to illustrate copy con- class WORK 2
structor. 2 {
Ans A copy constructor is an overloaded int WorkId;char WorkType ;
constructor function in which (an) public:
object(s) of the same class is/are passed -WORK ( ) //Function 1
as a reference parameter(s). It is used {
when an object’s data value is related to cout<<”Un-Allocated”<<endl ;
or is initialised using another }
object’s data value of the same class. In void status ( ) //Function 2
the example below the values of data {
members of object Q are dependent on cout<<WorkId<<”:
the values of data members of object P “<<WorkType<<endl ;
and Data members of object R dependent }
on Q. WORK ( ) //Function 3
//Example of Copy Constructor {
class Play WorkId = 10;
{ WorkType=’T’ ;
int Count, Number; }
S)
C
Play(); //constructor {
(P
void Change(int,int); }
er
nd
}; };
re
54 XII Computer
(b) Answer the questions (i) and (ii) after class bazaar
going through the following class: { char Type[20] ;
2 char product [20];
class Job int qty ;
{ float price ;
int JobId; bazaar()
char JobType; //function 1
public: { strcpy (type , “Electronic”) ;
~Job ( ) //Function 1 strcpy (product , “calculator”);
{ qty=10;
cout<< “Resigned” <<end1; price=225;
} }
Job ( ) //Function 2 public :
{ void Disp() //function 2
JobId=10 ; { cout<< type <<”-”<<product<<”:”
JobType =‘T” ; <<qty<< “@” << price << endl ;
} }
void TellMe( )//Function 3 };
{ void main ()
cout<<JobId<< “: ” { Bazaar B ; //statement 1
<<JobType<<end1; B. disp() ; //statement 2
} }
Job (Job &J) //Function 4
{ (i)Will statement 1 initialize all the data
JobId=J.JobId+10; members for object B with the values
JobType=J.JobType+l; given in the function 1 ? (YES OR NO).
} Justify your answer suggesting the
S)
C
Function 4 shown in the above definition Ans: No. The reason is the constructor
Ku
of class Job is called automatically, when should be defined under the public
er
nd
55 XII Computer
public members: Assign( );
A constructor to assign initial values of }
GCode,GType and GFabric with the a void display( )
word “NOT ALLOTED”and Gsize and { cout<<"\nThe Garment Code:
Gprice with 0. "<<GCode;
A function Input ()to the values of the cout<<"\nThe Garment Type:
data membersGCode, GType,Gsize and "<<GType;
GFabric and invoke the Assign() function. cout<<"\nThe Garment Size: "<<Gsize;
A function Display () which displays the cout<<"\nThe Garment Fabric:
content of all the data members for a "<<Gfabric;
garment. cout<<"\nThe Garment Price:
#include<iostream.h> "<<Gprice;
#include<string.h> }
#include<conio.h> };
#include<stdio.h> void main( )
class Garments { Garments G;
{ char GCode[21],GType[21]; G.Input( );
int Gsize; G.display( ); }
char Gfabric[21];
float Gprice; 2008 OUTSIDE DELHI:
void Assign( )
{ 2.b) Answer the questions (i) and (ii)
if(strcmp(strupr(Gfabric),"COTTON")==0 after going through the following
) program:
{ if(strcmp(strupr(GType),"TROUSER")= #include<iostream.h>
=0) #include<string.h>
Gprice=1300;
S)
class Retail
C
}
ar
int qty;
m
Gprice=1300*0.90;
Vi
“NOT ASSIGNED “and size and price with cout<<"\nThe Cloth Size: "<<size;
T
G
the data members code, type, size and cout<<"\nThe Cloth Price:
Ku
function. }
re
57 XII Computer
Constructor: A constructor is used to Ans: They will be executed
intitialize the objects of that class type automatically.
with a legal initial value.If a class has a Member function 1 will be executed at
constructor, each object of that class will the time of creation of an object of
be initialized before any use is made of class Maths. Member function 2 will
the object. be executed at the time of
(A member function with the destruction of an object of class
same name as its class is called Maths.
Constructor and it is used to initialize the
objects of that class type with a legal 2.c)Define a class Tour in C++ with the
initial value. ) description given below
Destructor: A destructor is used to 4
destroy the objects that have been Private Members:
created by a constructor. A destructor TCode of type string
destroys the values of the object being
destroyed. Constructor Destructor
Purpose: Is used to Purpose: Is used to
intitialize the objects of destroy the objects that
that class type with a have been created by a
legal initial value constructor
2.b) Answer the question (i)and (ii)after Name: The name of the Name:The name of the
going through the following class: class class preceded by a ~.
Calling: It will be Calling: It will be called
2 called automatically at automatically at the
the time of creation of time of destruction of
class Maths the object. an object.
{ char Chapter[20] Ie Implicite calling Ie Implicite calling
int Marks; Return Type: No Return Type: No
return type not even return type not even
public:
S)
void void
C
Maths() //Member
T
Function 1
(P
} Public Members:
Vi
58 XII Computer
Numof Adults *300+ NoofKids <<Kilometres;
*150 cout<<"\n\nThe Total Fare:
i.e., 2*300+ 3 *150 =1050 "<<TotalFare;
• A function EnterTour() to input }
the values of the data members };
TCode, NoofAdults, NoofKids and void main( )
Kilometers ; and invoke the { clrscr();
AssignFare() function. Tour T;
• A function ShowTour() which T.EnterTour( );
displays the content of all the T.ShowTour( );
data members for a Tour. getch();
}
Ans:
#include<conio.h> 2007 OUTSIDE DELHI:
#include<stdio.h>
#include<string.h> 2.b) Answer the questions (i) and (ii)
#include<iostream.h> after going through the following class :
class Tour 2
{ char TCode[21]; class Science
int NoofAdults,NoofKids,Kilometres; { char Topic[20] ;
float TotalFare; int Weightage ;
public: public :
Tour( ) Science ()
{ strcpy(TCode,"NULL"); //Function 1
NoofAdults=NoofKids=Kilometres=Total { strcpy (Topic, “Optics”) ;
Fare=0; Weightage =30
}
S)
cout<<”Topic Activated”;
C
void AssignFare( ) }
T
G
{ if(Kilometres>=1000) ~Science()
(P
TotalFare=NoofAdults*500+NoofKids*2
ar
//Function 2
m
50; { cout<<”Topic
Ku
TotalFare=NoofAdults*300+NoofKids*1 };
re
50;
Vi
59 XII Computer
2.c) Define a class Travel in C++ with the Travel( )
description given below : { strcpy(T_Code,"NULL");
4 No_of_Adults=No_of_Children=Distance
=
Private Members: TotalFare=0;
T_Code of type string }
No_ of_ Adults of type integer void AssignFare( )
No _of _Children of type integer {
Distance of type integer if(Distance>=1000)
TotalFare of type float TotalFare=No_of_Adults*500+No_of_Children*
250;
Public Members: else if(Distance>=500)
TotalFare=No_of_Adults*300+No_of_Children*
• A constructor to assign initial 150;
values as follows: else
TCode with the word “NULL” TotalFare=No_of_Adults*200+No_of_Children*
No _of_ Adults as 0 100;
No_ of_Children as 0 }
Distance as 0 void EnterTravel( )
TotalFare as 0 { cout<<"\nEnter the Travel Code: ";
• A function AssignFare() which gets(T_Code);
calculates and assigns the value of cout<<"\nEnter the Number of
the data member Totalfare as Adults: ";
follows cin>>No_of_Adults;
For each Adult cout<<"\nEnter the Number of
Children: ";
Fare (Rs) For Kilometers cin>>No_of_Children;
cout<<"\nEnter the Distance in
S)
500 >=1000
C
Kilometres: ";
300 <1000 & >=500
T
cin>>Distance;
G
200 <500
(P
AssignFare( );
ar
For Example:
re
class X ;
(P
ar
{ int i ; Marks=0;
m
public:
Ku
}
int j, k ;
er
nd
5,Number_of_buses as 1 }
T
G
Number_of_travellers T.ShowPlan( );
Vi
Number_of_buses 1 getch();
less than 20 }
1
Equal to or more than 20 and less than 40
2
2005 OUTSIDE DELHI:
Equal to 40 or more than 40
1.a) Differentiate between a default
3
constructer and copy constructer, giving
* A function ShowPlan() to display the3
suitable examples of each.
content of all the data members on the
Ans: A default constructor also called as
screen.
non-parameterized constructor will take
Ans:
no argument and initialize the object with
#include<iostream.h>
the predefined values in that constructor,
#include<conio.h>
Where as a copy constructor will
#include<stdio.h>
take an already created object of that
#include<string.h>
class and stores that object values into
class TravelPlan
the newly created object of that class. A
{ long PlanCode;
copy constructor takes a reference to an
char Place[21];
object of the same class as an argument.
int
Number_of_travellers,Number_of_buses;
2.b) Answer the following questions
public:
(i)and (ii) after going through the
TravelPlan( )
following class.
{ PlanCode=1001;
class Exam
strcpy(Place,"Agra");
{ int Marks;
62 XII Computer
char Subject[20]; value of Number_of_buses as per the
public: following conditions:
Exam() //Function 1 Number_of_travellers
{ strcpy(Subject,”Computer Number_of_buses 1
”); less than 20
Marks=0; 1
} Equal to or more than 20 and less than 40
Exam(char S[]) //Function 2 2
Equal to 40 or more than 40
{ strcpy(Subject,S);
3
Marks=0; }
* A function ShowTravel() to display the
Exam(int M) //Function
content of all the data members on the
3
screen.
{ strcpy(Subject,”Computer”
Ans:
);
#include<iostream.h>
Marks=M;
#include<conio.h>
}
#include<stdio.h>
Exam(char S[],int M)
#include<string.h>
//Function4
class Travel
{ Strcpy(Subject,P);
{ long TravelCode;
Marks=M;
char Place[21];
}
int No_of_travellers,No_of_buses;
};
public:
(i)Write statements in C++ that would
Travel( )
execute Function 3 and Function 4 of
{ TravelCode=201;
class Exam.
strcpy(Place,"Nainital");
(let char name[20];
No_of_travellers=5;
int X=60;
S)
No_of_buses=1;
C
strcpy(name,”COMPUTERSCIENCE”);
}
T
G
void NewTravel( )
(i) Exam A(X);
ar
cin>>TravelCode;
(ii) Exam B(name,X);
er
programming, what is
C
gets(Playtitle);
ar
invoked/called?
m
Noofscenes = N;
Vi
t(); overloading?
(P
ar
t();
Vi
~Seminar() //Function 4
C
{
G
destroyed...."; }
(P
cout<<”Vote of thanks”<<end1;
void take()
ar
}
m
};
cin>>r;
er
}
is Function 4 referred as and when does
re
void calculate()
Vi
it get invoked/called?
{ a = 3.1415*r*r; }
Answer:
void display()
{ cout<<"\nThe Radius of the Circle = Destructor, it is invoked
"<<r; as soon as the scope of the
cout<<"\nThe Area of the Circle = object gets over.
"<<a; ii)In Object Oriented Programming,
} which concept is illustrated by Function 1
}; and Function 3 together? Write an
void main() example illustrating the calls for these
{ clrscr(); functions.
Circle c1; /*Default Constructor will be Answer:
called implicitely.ie c1.r = 0.0 and c1.a = Constructor Overloading
0.0 */ (Polymorphism)
Circle c2(10.3); //Parameterized Seminar S1,S2(90);
//Constructor will be called mplicitely
Circle c3(c2);
//Copy Constructor will be called Model Paper 2 for 2008-09
implicitely
c1.take(); Batch:
c1.calculate();
c1.display(); 2.c)Answer the questions (i) and (ii) after
c2.display(); going through the following program: 2
c3.display(); class Match
getch();} {
int Time;
66 XII Computer
public: cout<<"Seminar starts
Match() //Function 1 now"<<end1;
{ }
Time=0; void Lecture() //Function 2
cout<<”Match commences”<<end1;
{
}
cout<<"Lectures in the seminar
void Details() //Function 2
on"<<end1;
{
}
cout<<”Inter Section Basketball
Match”<<end1; Seminar(int Duration)
} //Function 3
Match(int Duration) {
//Function 3 Time=Duration;
{ cout<<"Seminar starts
Time=Duration; now"<<end1;
cout<<”Another Match begins }
now”<<end1; ~Seminar( )//Function 4
} {
Match(Match &M) //Function 4 cout<<"Vote of
{
thanks"<<end1;
Time=M.Duration;
cout<<”Like Previous Match }
”<<end1; };
} i) In Object Oriented Programming,
}; what is Function 4 referred as and
i)Which category of constructor - when does it get
Function 4 belongs to and what is the invoked/called?
S)
C
Function 1 and
nd
existing object.
Vi
purpose
(P
Ans.
copy the data from one object to
er
another
re
Vi
ii) Write statements that would call (ii) Write the names of data members,
the member Functions 1 and 3 which are accessible by objects of class
A) Match M; //Function 1 type Company.
Match N(10); //Function 3 Ans
None
}; };
(P
(b) Multi Level Inheritance ii) Write names of all the member
(c) Multiple Inheritance functions accessible from Show( )
Ans. function of class Training.
(b) Multilevel Inheritance Ans
Register( )
(ii) Write the names of data members, Siteln( ). SiteOut( ).
which are accessible by objects of class Input( ), Output( )
type ShowRoom.
Ans. iii) Wr i t e name of all the members
None accessible through an object of class
Training.
(iii) Write the names of all member Ans
functions which are accessible by objects Register( ), Show( ),
of class type ShowRoom. Input( ), Output( )
Ans. iv) Is the function Output( ) accessible
Enter(), Display() inside the function SiteOut( )? Justify
your answer.
(iv) Write the names of all members, Ans
which are accessible from member No, function Output( ) is not accessible
functions of class Factory. inside the function SiteOut( ), because
Ans. FID, Address, NOE, Description, Output( ) is a member of class
Input(), Output(), Assign(), Show(), FaceToFace and SiteOut( ) is a member of
Allocate() class Online. and the classes FaceToFace
and Online are two independent
69 XII Computer
classes. InRegular( ) is a member of class Regular
and InDistance( ) is a member of class
2009 Outside Delhi: Distance, and the classes Regular and
Distance are two independent classes.
public: };
G
(P
}; { char EDName[20];
er
char BatteryType[10];
nd
re
}; void AssignRem(float);
C
SoftToys(); };
er
nd
void STDisplay(); {
}; char Regno[10],LName[20],Program[10];
class ElectronicToys:public protected:
Toys int Attendance,grade;
{ char ETName[20]; public:
int No_of_Batteries; Learner();
public: void LEntry();
ElecronicToys(); void LDisplay();
void ETEntry(); };
void ETDisplay(); class Institute:public Learner,public
}; Trainer
{ char ICode[10],IName[20];
(i)Which type of Inheritance is shown in public:
the above example? Institute();
Ans: Hierarchical Inheritance. void IEntry();
Since the sub classes are derived from a void IDisplay();
single base class(Dolls). };
(ii)How many bytes will be required by
an object of the class SoftToys ? (i)Which type of inheritance is depicted
Ans: 33 Bytes by above example ?
(Explonation: The memory will be Ans: Multiple Inheritance.
reserved as follows: Since here the class Institute is deriving
char Tcode[5]; //5 Bytes from the classes Learner and Trainer.
float Price; //4 Bytes
char STName[20]; //20 Bytes
71 XII Computer
(ii)Identify the member function(s) that int Workload;
cannot be called directly from the objects protected :
of class Institute from the following float Salary;
TEntry() void AssignSal(float);
LDisplay() public:
IEntry() Teacher();
Ans: All the above 3 member functions void TEntry();
can be called directly from the objects of void TDisplay();
class Institute. };
(iii)Write name of all member(s) class Student
accessible from member functions of { char
class institute. Admno[10],SName[20],Stream
Ans: Data Members – [10];
Trainer::Remuneration, protected:
Learner::Attendan int Attendance,Totmarks;
ce, public:
Learner::Grade, Student();
Institute::ICode, void SEntry();
Institute::IName void SDisplay();
Member functions – };
Trianer::AssignRem( ), class School:public Student,public
Trainer::TEntry( ), Teacher
Trainer::TDisplay( ), { char SCode[10],SName[20];
Learner:: LEntry( ), public:
Learner::LDisplay( ), School( );
Institute::IEntry ( ) void SchEntry();
(LDisplay can call IEntry( )) void SchDisplay();
S)
C
Institute::LDisplay( ) };
T
G
accessed through Objects of class cannot be called directly from the objects
Vi
72 XII Computer
School::SChDisplay( ) {
(iv) If class School was derived privately -----
from class Learner and privately from ------
class Trainer, then name the member }
function(s)that could be accessed class B
through Objects of class School. {
Ans: School::SChEntry( ) -----
School::SChDisplay( ) -----
}
2006 DELHI: class C:public A,protected B
{
2.a) Define Multilevel and Multiple -----
inheritance in context of Object Oriented -----
Programming. Give suitable example to }
illustrate the same2 Ans:
Multilevel Inheritance: When a 2.d) Answer the questions (i) to(iv)
subclass inherits from a class that itself based on the following code
inherits from another class, it is known as class stationary
multilevel inheritance. { char Type;
char Manufacture[10];
public:
stationary( );
void Read_sta_details( );
void Disp_sta_details( );
};
class office:public stationary
{ int no_of_types;
S)
C
class A public:
(P
{ void Read_off_details( );
ar
m
------ };
er
nd
{ char delivery_date[10];
----- public:
----- void Read_pri_details( );
} void Disp_pri_details( );
class C:protected B };
{ void main( )
----- { printer MyPrinter;
----- }
} (i) Mention the member names which are
Multiple Inheritance: When a sub class accessible by MyPrinter declared in
inherits from multiple base classes, it is main() function.
known as multiple inheritance. Ans: printer::Read_pri_details( );
printer::Disp_pri_details( );
(ii) What is the size of MyPrinter in
bytes?
Ans: 29 Bytes
(iii)Mention the names of functions
accessible from the member function
Read_pri_details() of class printer.
Ans:
stationary::Read_sta_details( )
stationary::Disp_sta_details( )
Eg: (for Multiple Inheritance) office::Read_off_details( )
class A office::Disp_off_details( )
73 XII Computer
printer::Disp_pri_details( ) 2005 DELHI:
2006 OUT SIDE DELHI: 2.d) Answer the questions (i) to(iv)
based on the following code:4
2.d)Answer the questions (i) to(iv) based class Medicine
on the following code:4 {
class furniture char Category[10];
{ char Type; char
char Mode[10]; Date_of_manufacture[10];
public: char Company[20];
furniture( ); public:
void Read_fur_details(); Medicine();
void Disp_fur_details(); void entermedicinedetails();
}; void showmedicinedetails();
class sofa:public furniture };
{ int no_of_seats; class capsule:public Medicine
float cost_sofa; {
public: protected:
void Read_sofa_details(); char capsule_name[30];
void Disp_sofa_details(); char volume_lable[20];
}; public:
class office:public sofa float Price;
{ int no_of_pieces; capsules();
char delivery_date[10]; void entercapsuledetails();
public: void showcapsuledetails();
void Read_office_details(); };
S)
}; { int Dosage_units;
T
G
{ int Use_within_days;
m
} Antibiotics();
er
nd
Medicines();
C
void enterdrugdetails();
T
G
{ { char specification[20];
er
nd
MNC( );
C
char Country[25];
T
G
}; 2
Ku
76 XII Computer
(v) Hybrid Inheritance: Hybrid (iii)Name the private member
inheritance combines two or function(s) of class Teacher.
more forms of inheritance. Ans: Teacher::Display( )
(iv)Is the member function OUT()
2001: accessible the objects of Dept?
Ans: Yes. Since it is public member
1.a) Reusability of classes is one of the function.
major properties of OOP. How is it
implemented in C++. 1999 DELHI:
2
Ans: Resuability of classes can be 2.a)What do you understand by visibility
implemented through Inheritance. Ie modes in class derivations? What are
After developing a class, if you want a these modes? 2
class which consists the features of this Ans: It is given in chapter 4, classes and
class( ie members ) and the other object as two answers. Ie Difference
features also, then instead of developing between private and protected, private
a class which consists all these features, and public.
you can inherited the existing features
(members) and you can develop new 2.c)Consider the following declarations
class consists the remaining features and answer the questions below:
using inheritance (in Object Oriented class vehicle
Programming ie in C++.) { int wheels;
protected:
2000 DELHI: int passenger;
void inputdata(int,int);
2.c)Consider the following and answer void outputdata();
S)
class heavy_vehicle:protected
T
class School
G
vehicle
(P
{ int A;
ar
protected: {
m
int diesel_petrol;
Ku
int B,C;
protected:
er
public:
nd
int load:
re
void INPUT(int);
Vi
public:
C
void OUTPUT();
T
AUTHOR();
G
};
(P
void Show();
m
{ int M;
Ku
public: };
er
void DISP(void);
re
(i)Name the base class and derived class accessible from objects
of the class QQQ. belonging to class AUTHOR.
Ans:Base class of QQQ – PPP (ii) Write the names of all the
Derived class of QQQ – RRR member functions, which are
(ii)Name the data member(s) that can be accessible from objects
accessed from function DISP(). belonging to class BRANCH.
Ans: QQQ::U , RRR::M (iii)Write the names of all the
(iii)Name the member function(s) , members which are
which can be accessed from the object of accessible from member
class RRR. functions of class AUTHOR.
Ans: QQQ::INDATA( ) (iv)How many bytes will be
QQQ::OUTPUT( ) RRR::DISP( required by an object
) belonging to class AUTHOR?
(iv) Is the member function OUT() Answer:
accessible by the objects of the class (i) None of data members are
QQQ? Ans: No. accessible from objects
belonging to class AUTHOR.
(ii) Haveit(), Giveit()
Model Paper 1 for 2008-09 (iii)Data members: Employee,
Acode, Aname, Amount
Batch: Member function: Register(),
Enter(), Display(), Haveit(),
2.f)Answer the questions (i) to (iv) based Giveit(), Start(), Show(),
on the following: (iv) 70
4
78 XII Computer
Model Paper 2 for 2008-09 iv)How many bytes will be required by
an object belonging to class SHOP?
Batch: Answer: 66
2.e) Answer the questions (i) to (iv)
based on the following: Sample Paper 1 for 2009-10
4 batch:
class CUSTOMER
{ 2.d) Answer the questions (i) to (iv)
int Cust_no; based on the following:
char Cust_Name[20]; 4
protected: class PUBLISHER
void Register(); {
public: char Pub[12];
CUSTOMER(); double Turnover;
void Status(); protected:
}; void Register();
class SALESMAN public:
{ PUBLISHER();
int Salesman_no; void Enter();
char Salesman_Name[20]; void Display();
protected: };
float Salary; class BRANCH
public: {
SALESMAN(); char CITY[20];
void Enter(); protected:
S)
}; public:
G
(P
{
Ku
void Giveit();
char Voucher_No[10];
er
};
nd
public:
Vi
PUBLISHER
SHOP(); {
void Sales_Entry(); int Acode;
void Sales_Detail(); char Aname[20];
}; float Amount;
i)Write the names of data members public:
which are accessible from objects AUTHOR();
belonging to class CUSTOMER. void Start();
Ans: None of data members are void Show();
accessible from objects belonging to class };
CUSTOMER.
ii)Write the names of all the member (i) Write the names of data members,
functions which are accessible from which are accessible from objects belong-
objects belonging to class SALESMAN. ing
Ans: Enter(), Show() to class AUTHOR.
Ans)None of data members are
iii)Write the names of all the members accessible from objects belonging to
which are accessible from member class AUTHOR.
functions of class SHOP.
Ans: Data members: Voucher_No, (ii) Write the names of all the member
Sales_Date, functions which are accessible from ob-
Salary jects
Member functions:Sales_Entry( ), belonging to class BRANCH.
Sales_Details( ), Enter (), Show( ), Ans) Haveit( ), Giveit( )
Register( ), Status( ).
79 XII Computer
(iii) Write the names of all the members Ans) None of data members are
which are accessible from member func- accessible from objects belonging to class
tions AUTHOR.
of class AUTHOR.
Ans) Data members: Employees, Acode, (ii) Write the names of all the member
Aname, functions which are accessible from
Amount objects
Member function: Register(), Enter(), belonging to class SALESMAN.
Display(), Haveit(), Giveit(), Start(), Ans) Enter(), Show()
Show(),
(iii) Write the names of all the members
(iv) How many bytes will be required by which are accessible from member
an object belonging to class AUTHOR? functions of
Ans) 70 class SHOP.
Ans) Data members: Voucher_No,
Sales_Date,
Sample Paper 2 for 2009-10 Salary
Member function : Sales_Entry(),
Batch: Sales_Detail(),
Enter(),Show(),Register(),
2.d) Answer the questions (i) to (iv)
Status()
based on the following:
4
(iv) How many bytes will be required by
class CUSTOMER
an object belonging to class SHOP?
{
Ans) 66
int Cust_no;
char Cust_Name[20];
S)
protected:
C
T
void Register();
G
(P
public:
ar
CUSTOMER();
m
Ku
void Status();
er
};
nd
class SALESMAN
re
Vi
{
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();
};
}
C
Word[I++] = Ch;
};
T
G
else
(P
{
ar
void ChangeEmail()
m
Word[I] = ‘\0’;
Ku
{
if (strcmp (Word,“this”)==0)
er
Client C;
nd
fstream F; Cl++;
re
Vi
81
XII Computer
public: Statement 2 using tellg() and seekp()
char* GetFrom( ) functions for performing the required
{return From;} task. 1
char* GetTo( )
{return To;} #include <fstream.h>
void Enter( ) class Customer
{ { long Cno;
cin>>Fno; char Name[20],Mobile[12];
gets(From); public:
gets(To); //Function to allow user to enter
//the Cno, Name,Mobile
}
void Enter( );
void Display( ) //Function to allow user to enter (modify)
{ //mobile number
cout<<Fno<<“:”<<From<<“:”<<To<<endl; void Modify( );
} //Function to return value of Cno
}; long GetCno( )
{
Ans) return Cno;
void Read ( ) }
{ };
FLIGHT F; void ChangeMobile( )
ifstream fin; {
fin.open(“FLIGHT.DAT”,ios::binary); Customer C;
//OR ifstream fin (“FLIGHT. DAT”, ios: :binary) ;
fstream F;
while(fin.read((char*)&F,sizeof(F)))
F.open(“CONTACT.DAT”,ios::binary|
S)
{
C
ios::in|ios::out);
T
if (strcmp(F. GetTo(),“Mumbai”))
G
long Cnoc;
(P
F.Display( ) ;
ar
//needs to be changed
Ku
fin.close(); // cin>>Cnoc;
er
nd
} while (F.read((char*)&C,sizeof(C)))
re
OR {
Vi
C2++; T.Show( ) ;
C
T
i=0; }
G
(P
} fin.close( );
ar
} }
m
Ku
File.close ( ) ;
m
}
er
U.show( ) ; ____________________;
(P
fin.read((char*)&U, sizeof(U))
ar
} }
Ku
fin.close( ); if (Position==-l)
er
nd
{
C
I=O;
T
fin.read((char*)&C, sizeof(C));
G
}
(P
while(!fin.eof())
ar
} {
m
Fil.close( );
Ku
if(C.WhatType()==’L’||C.WhatType()==’M’)
er
}
re
fin.read((char*)&C, sizeof(C));
Vi
}
(c) Write a function in C++ to read and }
display the detail of all the members fin.close( );
whose membership type is ‘L’ or ‘M’ }
from a binary file “CLUB.DAT”.
Assume the binary file “CLUB.DAT” DELHI : 2008:
contains objects of class CLUB,
which is defined as follows: 3 4.a)Observe the program segment
class CLUB given below carefully, and answer the
{ question that follows
int Mno; //Member Number
char Mname [20]; //Member Name class Applicant
char Type; //Member Type: L Life Member M {
//Monthly Member G Guest
long Aid ; // Applicant’s Id
public:
char Name[20] ; // Applicant’s Name
void Register( );
//Function to enter the content float Score ; // Applicant’s Score
void Display( ); public ;
//Function to display all data members void Enroll( ) ;
char WhatType( ) void Disp( ) ;
{ void MarksScore( ) ;
return Type; //Function to change Score
} long R_Aid( )
{
86
return Aid; int lowercount=0;
) while(fin)
}; {
void ScoreUpdate (long Id) fin.get(ch);
{ if(islower(ch))
fstream File ; lowercount++;
File.open (“APPLI.DAT” , ios :: binary | }
ios :: in | ios :: out) ; cout<<"\nTotal number of Lowercase
Applicant A ; alphabets in the file = "<<lowercount;
int Record = 0, Found = 0 ; getch( );
while (!Found && File.read }
( (char*)&C, sizeof(c) ) )
{ 4.c)Given a binary file PHONE.DAT,
if (Id = = A.R_Aid( ) ) containing records of the following
{ cout << “Enter new Score” ; structure type
A.MarksScore( ) ;
____________ //Statement 1 class phonlist
____________ //Statement 2 {
Found=1; char Name[20] ;
} char Address[30] ;
Record++ ; char AreaCode[5] ;
} char PhoneNo[15] ;
if (Found = = 1) public ;
cout << “Record Updated” ; void Register( ) ;
File.close( ) ; void Show( ) ;
S)
C
{ return strcmp(AreaCode,AC) ;
(P
}
ar
};
Ku
and Statement 2 to write the updated that would copy all those records
record at that position. which are having AreaCode as “DEL”
from PHONE.DAT to PHONBACK.DAT.
Solution:
Ans)
Statement 1 void TRANSFER( )
File.seekp(File.tellp( )-sizeof(A)); {
ifstream fin(“PHONE.DAT’,ios::in,ios::binary);
ofstream fout(“PHONEBACK.DAT”,
Statement 2 ios::out,ios::binary);
File.seekp(Record*sizeof(Applicant)); phonlist P;
or while(fin) // or while(!fin.eof( ))
File.write((char*)&A,sizeof(A)); {
fin.read((char*)&P,sizeof(P));
4.b) Write a function in C++ to count if(P.CheckCode(“DEL”)= = 0)
the number of lowercase alphabets fout.write((char*)&P,sizeof(P));
present in a text file “BOOK.TXT”. }
fin.close( );
Solution: fout.close( );
void LowerLetters( ) }
{
clrscr( ); OUTSIDE DELHI 2008:
ifstream fin("BOOK.TXT",ios::in);
char ch;
87 cbse
4.a)Observe the program segment Statement 2
given below carefully, and answer the File.write((char*)&C,sizeof(C));
question that follows Or
File.write((char*)&C,sizeof(Candidate));
class candidate
{
long Cid ; // Candidate’s Id 4.b)Write a function in C++ to count
char CName[20]; // Candidate’s Name the number of uppercase alphabets
float Marks ; // Candidate’s Marks present in a text file “ARTICLE.TXT”.
public ;
void Enter( ) ; Solution:
void Display( ) ; void UpperLetters( )
void MarksChange( ) ; {
//Function to change marks clrscr( );
long R_Cid( ) ifstream fin("ARTICLE.TXT",ios::in);
{ char ch;
return Cid; int uppercount=0;
} while(fin)
}; { fin.get(ch);
void MarksUpdate (long Id) if(isupper(ch))
{ uppercount++;
fstream File ; }
File.open (“CANDIDATE.DAT”, ios :: cout<<"\nTotal number of Uppercase
binary|ios::in|ios :: out) ; alphabets in the file = "<<uppercount;
Candidate C ; getch( );
S)
C
C.MarksChange( ) ;
re
Vi
int RTime( )//function to return Time Taken For example,if the content of the file
er
nd
{ DIALOGUE.TXT is
re
return TimeTaken;}
Vi
L.Assignmarks(0)
T
G
else
(P
void BPlayers( )
ar
{ L.Assignmarks (10)
m
Ku
ofstream fout(“BASKET.DAT”,ios::out|ios::binary);
nd
Game G;
re
________________;//Statement 2
Vi
while(fin) // or while(!fin.eof( ))
{ Rec++ ;
fin.read((char*)&G,sizeof(Game)); }
if(strcmp(G.GameName,”Basket Ball”)= = 0)
File.close( ) ;
fout.write((char*)&G,sizeof(G));
}
}
fin.close( );
If the function ModifyMarks ( ) is
fout.close( );
supposed to modify marks for the
}
records in the file MARKS.DAT based
on their status of the member
OUTSIDE DELHI : 2007
Checked (containg value either ‘Y’ or
‘N’).Write C++ statements for the
4.a) Observe the program segment
statement 1 and statement 2,where,
given below carefully,and answer the
statement 1 is required to position the
question that follows:
file write pointer to an appropriate
place in the file and statement 2 is to
class Labrecord
perform the write operation with the
{
modified record.
int Expno;
char Experiment[20] ;
Ans)
char Checked ;
Statement 1
int Marks ;
File.seekp(File.tellp( )-sizeof(L));
public : or
90 cbse.extramind.com
File.seekp(Rec*sizeof(L)); Write a function in C++ that would
read contents from the file
Statement 2 SPORTS.DAT and creates a file
File.write((char*)&L,sizeof(L)); named ATHLETIC.DAT copying only
or those records from SPORTS.DAT
File.write((char*)&L,sizeof(Labrecord)); where the event name is “Athletics”.
while(Fil.get(Ch)) 4.a)
ar
m
{ void main( )
Ku
if (Ch!= ‘ ‘)
er
{
nd
“COLONY.DAT”
T
G
Ans)4
(P
ar
struct COLONY
m
char Colony_Code[10] ; result will be 0 since it will loose all the old content
nd
re
int No_of_People ;
}; 4.b)Write a function to count the
number of blanks present in a text file
Write a function in C++ to update the named “PARA.TXT” .
file with a new value of No_of_People.
The value of Colony_Code and Solution:
No_of_People are read during the void BlanksCount( )
execution of the program. {
clrscr( );
Solution: ifstream fin("PARA.TXT",ios::in);
char ch;
void Update( ) int Blanks=0;
{ if(!fin)
fstream finout(“COLONY.DAT”,ios::in| { cout<<”No words at all in the file.
ios::out); So no blank spaces”;
COLONY C; exit(0);
finout.seekg(0); }
while(finout) while(fin)
{ {
finout.read((char *)&C, sizeof(C)); fin.get(ch);
cout<<”\nThe Colony Code is if(ch= =’ ‘)
“<<C.Colony_Code; Blanks++;
cout<<”\nThe Colony Name }
92 j
cout<<"\nTotal number of Blank //function to enter Book details
Spaces in the file = "<<Blanks;
getch( ); void showdetails( ) ;
//function to display Book details
}
int Rbook_no( )
{return Book_no ;}
4.c) Following is the structure of each //function to return Book_no
record in a data file named
“PRODUCT.DAT” . };
PRODUCT P; Found = 1 ;
T
G
finout.seekg(0); }
(P
ar
while(finout) else
m
Ku
while(Fin.getline(Aline,80, ‘\n’))
C
}
(P
Count++;
ar
Fin.close( );
m
Ku
}
nd
//Name of applicant
Ku
public :
re
void Enrol( )
modified record at its proper place.
{ gets(A_Rno);
gets(A_Name);
Ans)
cin >> A_Score ;
File.seekp((Recordsread-1)*sizeof(OM));
}
OR
void Status( )
File.seekp(Recordsread*sizeof(OM));
{
OR
cout << setw(12) << A_Admno ;
File.seekp(-l*sizeof(OM),ios::curr);
cout << setw(32) << A_Name ;
OR
cout << setw(3) << A_Score << endl ;
File.seekp(file.tellg()-sizeof(OM)); }
int ReturnScore( )
2.b) Write a function in C++ to count {
and display the number of lines not return A_Score;
starting with alphabet ‘A’ present in a }
text file “STORY.TXT”. };
Write a function in C++, that would
Example : read contents of file APPLY.DAT and
If the file “STORY.TXT” contains the display the details of those Students
following lines, whose A_Score is above 70.
The rose is red.
A girl is playing there. DELHI : 2004
There is a playground.
95
4.a)Assuming that a text file named more objects belonging to class
FIRST.TXT contains some text written LAUGHTER at the bottom of it.
into it, write a function named
vowelwords( ), that reads the file class LAUGHTER
FIRST.TXT and creates a new file { int Idno; // Identification number
named SECOND.TXT, to contain only char Type[5]; //LAUGHTER Type
those words from the file FIRST.TXT char Desc[255];//Description
which start with start with a lowercase public :
vowel (i.e. with ‘a’, ’e’, ’I’, ‘o’, ‘u’). For void Newentry( )
example if the file FIRST.TXT contains {
cin>>Idno;gets(Type);gets(Desc);
Carry umbrella and overcoat when }
it rains void Showonscreen( )
Then the file SECOND.TXT shall {
contain: cout<<Idno<<”:”<<Type<<endl
umbrella and overcoat it <<Desc<<endl;
}
4.b) Assuming the class Computer as };
follows:
class computer DELHI : 2002
{
char chiptype[10]; 4.a)What is the difference between
int speed; pub( ) and write( ) ?
public:
S)
char DNAME[13]; //Name of the drink from binary file and display them on
ar
{ public:
cin>>DCODE>>DNAME> void GETIT( )
>DSIZE>>DPRICE;
}
{
void showdrinks( ) cin>>ENO;
{ gets(ENAME);
cout<<DCODE<<DNAME<<DSIZE<< }
DPRICE<<endl; void SHOWIT( )
} { cout< < ENO<<ENAME<<endl;
char *getname( ) }
{return DNAME;} };
};
2009-10 MODEL PAPER 1:
1999:
4.a) Observe the program segment
Q 4 (a) Differentiate between functions given below carefully and fill the
read( ) and write( ). blanks marked as Statement 1 and
Statement2 using seekp( ) and seekg( )
Q 4 (b) Assuming the class functions for performing the required
FLOPPYBOX, write a function in C++ task. 1
to perform following:
(i) Write the objects of FLOPPYBOX to #include <fstream.h>
a binary file. class Item
(ii) Reads the objects of FLOPPYBOX
97
{ c) Write a function in C++ to search
int Ino; for a BookNo from a binary file
char Item[20]; "BOOK.DAT",assuming the binary file
public: is containing the objects of the
void Search(int ); following class. 3
//Function to search and display the
//content from a particular record number
class
void Modify(int);
//Function to modify the content of a
{
//particular record number int Bno;
}; char Title[20];
void Item::Search(int RecNo) public:
{ int RBno( )
fstream File; {return Bno;}
File.open("STOCK.DAT",ios::binary|ios::in); void Enter( )
________________ //Statement 1 {cin>>Bno;gets(Title);}
File.read((char*)this,sizeof(Item)); void Display( )
cout<<Ino<<"==>"<<Item<<endl; {cout<<Bno<<Title<<endl;}
File.close( ); };
}
void Item::Modify(int RecNo) Ans)
{ void BookSearch()
fstream File; {
File.open("STOCK.DAT",ios::binary|ios fstream FIL;
::in|ios::out); FIL.open("BOOK.DAT",ios::binary|ios::in);
BOOK B;
S)
cout>>Ino;cin.getline(Item,20);
C
File.write((char*)this,sizeof(Item));
ar
File.close( ); cin>>bn;
m
Ku
} while (FIL.read((char*)&S,sizeof(S)))
er
if (FIL.RBno()==bn)
nd
{
re
Ans)
Vi
Statement 1 S.Display();
File.seekg(RecNo*sizeof(Item)); Found++;
}
Statement 2 if (Found==0)
File.seekp(RecNo*sizeof(Item)); cout<<"Sorry! Book not
found!!!"<<endl;
b) Write a function in C++ to count the FIL.close( );
number of lines present in a text file }
"STORY.TXT". 2
2009-10 MODEL PAPER 2:
Ans)
void CountLine() 4.a) Observe the program segment
{ given below carefully and fill the
ifstream FIL("STORY.TXT"); blanks marked as Statement 1 and
int LINES=0; Statement 2 using seekg() and tellg()
char STR[80]; functions for performing the required
while (FIL.getline(STR,80)) task. 1
LINES++;
cout<<"No. of Lines:"<<LINES<<endl; #include <fstream.h>
f.close( ); class Employee
} {
int Eno;char Ename[20];
public:
98
//Function to count the total number of records void Display( )
int Countrec( ); { cout<<Rno<<Name<<endl;
}; }
int Item::Countrec( ) };
{ Ans)
fstream File; void Addnew( )
File.open("EMP.DAT",ios::binary|ios::in); {
__________________ //Statement 1 fstream FIL;
int Bytes =_______ //Statement 2 FIL.open("STUDENT.DAT",ios::binary|ios::app);
int Count = Bytes/sizeof(Item); STUD S;
File.close( ); char CH;
return Count; do
} {
Ans) S.Enter();
Statement 1 FIL.write((char*)&S,sizeof(S));
File.seekg(0,ios::end); cout<<"More(Y/N)?";cin>>CH;
}
Statement 2 while(CH!='Y');
File.tellg( ); FIL.close( );
}
b) Write a function in C++ to count the
number of alphabets present in a text 2008-09 MODEL PAPER 1:
file "NOTES.TXT". 2
Q4. (a) Observe the program
Ans) segment given below carefully and fill
S)
C
ifstream FIL("NOTES.TXT");
ar
char CH=FIL.get(); 1
nd
while (!FIL.eof())
re
Vi
{ #include <fstream.h>
if (isalpha(CH)) class Item
CALPHA++; {
CH=FIL.get( ); int Ino;char Item[20];
} public:
cout<<"No. of Alphabets:"<< void Search(int );
CALPHA<<endl; //Function to search and display the content
//from a particular record number
}
void Modify(int);
//Function to modify the content of a
c) Write a function in C++ to add new //particular record number
objects at the bottom of a binary file
"STUDENT.DAT", assuming the binary };
file is containing the objects of the void Item::Search(int RecNo)
following class. 3 {
fstream File;
class STUD File.open(“STOCK.DAT”,ios::binary|ios::in);
{ _______________ //Statement 1
int Rno; File.read((char*)this,sizeof(Item));
char Name[20]; cout<<Ino<<”==>”<<Item<<endl;
public: File.close( );
void Enter( ) }
{ cin>>Rno;gets(Name); void Item::Modify(int RecNo)
} {
99
fstream File; }
File.open(“STOCK.DAT”,ios::binary|ios };
::in|ios::out);
cout>>Ino; Answer:
cin.getline(Item,20); void BookSearch()
_________________ //Statement 2 {
File.write((char*)this,sizeof(Item)); fstream FIL;
File.close( ); FIL.open(“BOOK.DAT”,ios::binary|ios::in);
} BOOK B;
Answer: int bn,Found=0;
Statement 1 cout<<”Enter Book Num to search…”;
File.seekg(RecNo*sizeof(Item)); cin>>bn;
Statement 2
while (FIL.read((char*)&S,sizeof(S)))
File.seekp(RecNo*sizeof(Item)); if (B.RBno( )==bn)
{
B.Display( );
(b) Write a function in C++ to count
Found++;
the number of lines present in a text
}
file “STORY.TXT”. 2
if (Found==0) cout<<”Sorry! Book
not found!!!”<<endl;
Answer:
FIL.close( );
void CountLine( )
}
{
ifstream FIL(“STORY.TXT”);
2008-09 MODEL PAPER 2:
int LINES=0;
S)
C
char STR[80];
4.(a) Observe the program segment
T
G
while (FIL.getline(STR,80))
(P
cout<<”No. of Lines:”<<LINES<<endl;
Ku
}
re
task. 1
Vi
class STUD }
C
char Name[20]; }
ar
public: Ans)
m
Ku
{ cin>>Rno; 32*26*33
nd
re
gets(Name);
Vi
pointer++; { size=strlen(s);
C
} state_name=new char[size+1];
T
G
(P
cout<<endl; strcpy(state_name,s);
ar
for(I=1;I<=4;I++) }
m
Ku
--pointer; { cout<<state_name<<endl;
nd
re
} }
Vi
delete name;
(P
ar
strcat(name,b.name);
nd
}
re
#include<iostream.h>
Vi
}; #include<conio.h>
class Rectangle
void main( ) {
{ float area,len,bre;
char *temp=”Jack”; public:
Student name1(temp),name2(“Jill”), void input( )
name3 (“John”),S1,S2; { cout<<"\nEnter the length and
S1.manipulate(name1,name2); breadth: ";
S2.manipulate(S1,name3); cin>>this->len>>this->bre;
S1.display( ); }
S2.display( ); void calculate( )
} {
area=len*bre;
//Here Implicit 'this' pointer will be worked.
}
2006 Outside Delhi: void output( )
{
2.a) What is “this” pointer? Give an cout<<"\nThe Area of the
example to illustrate the use of it in Rectangle:"<<this->area;
C++. }
};
Ans: A special pointer known as this
pointer stores the address of the void main( )
103
{ Warning Line 8 : ‘j’ is assigned a
Rectangle R; value that is never used.
clrscr( ); Warning Line 8 : ‘ptr’ is assigned a
R.input( ); value that is never used.
R.calculate( ); Explanation:
R.output( ); (1)Error 1 is in Line no.5 ie (*ptr)++
getch(); Here ptr is a constant pointer ie the
} contents cann’t be modified.
(2)Error 2 is in Line no.7 ie ptr=&j;
2004: Here ptr is a constant pointer the
address in this pointer can’t be
1.d) What will be the output of the modified.
following program: (It is already pointing the address of i.)
for(;Counter<Length- 2; Counter+=2,Ptr++)
C
{ cout<<a<<’,’<<ch<<endl;
T
G
*(Ptr+Counter)=toupper(*(Ptr+Counter)); }
(P
ar
}
m
Ku
{
clrscr( ); Ans: The int *ptr=new int(5); declares
int Position=0; and creates the space for the new data
char Message[]=”Pointers Fun”; directly.
ChangeString(Message,Position); Ie The new operator reserves 2
cout<<Message<<”@”<<Position; bytes of memory from heap memory
} (free pool) and returns the address of
that memory location to a pointer
2001: variable called ptr, 5 is the initial
value to be stored in the newly
1.c) Identify the syntax error(s), if allocated memory.
any, in the following program. Also The int *ptr = new int[5];
give reason for errors. 2 initializes an array element. A
void main( ) memory space for an integer type of
{ const int i=20; array having 5 elements will be
const int* const ptr=&i; created from the heap memory (free
(*ptr)++; pool).
int j=15;
ptr=&j; 2.c) Give the output of the following
} program 4
Ans: #include<iostream.h>
Error Line 5 : Cannot modify a const object. #include<string.h>
Error Line 7 : Cannot modify a const object. class per
104
{ char name[20];
float salary; Ans)
public: void CHANGE (int A[ ], int N)
per(char *s, float a) {
{ strcpy(name,s); for(int I = 0; I<N; I++)
salary=a; {
} if (A[I]%7 = = 0)
per *GR(per &x) A [I] = A [I] /7;
{ if(x.salary>=salary) else
return &x; A[I] = A[I] * 3;
else }
return this; }
}
void display( ) (b) An array P[50] [60] is stored in the
{ cout<<”Name:“<<name<<”\n”; memory along the column with each of
cout<<”Salary:“<<salary<<”\n”; the element occupying 2 bytes, find
} out the memory location for the
}; element P[10][20], if the Base Address
void main( ) of the array is 6800. 3
{ Per P1(“REEMA”,10000), Ans)
P2(“KRISHNAN”,20000), Loc(P[I] [J]) = Base(P)+W(I+J*M)i
P3(“GEORGE”,5000); Loc(P[10][20]) = Base(P)+2(10+20*50)
per *P; Loc(P[10] [20]) = 68OO + 2(10+20*50)
P=P1.GR(P3);P->display( ); = 6800 + 2 (10+1000)
S)
= 6800 + 2020
T
G
(P
1999: = 8820
ar
#include<stdio.h> + W((i–L1)+(j–L2)*M)
nd
re
105
Hint: int S=0, C=0;
If the following is the content of the for(int I = 0; 1< N; 1++)
array for (int J = 0; J<M; J++ )
{
if (C%2 == 0)
S = S + A[I][J];
C++;
}
return S;
}
OR
OR
}
C
T
OR
G
(P
{
m
{ int S=0;
Ku
int S=0;
for (int I = 0; 1< N; I++)
er
return S; {
} if ((I+J)%2 == 0)
OR S = S + A[I][J];
}
int SKIPSUM(int A[][3], int N, int M) return S;
{ }
int I,J, S=O;
for (I = 0; 1 < N; 1++)
{ OUTSIDE DELHI 2010:
if (I%2)
//OR (1%2 !=0 ) OR (I%2 == 1) 3. (a) Write a function REASSIGNO in
J = l; C++, which accepts an array of
else integers and its size as parameters
J = 0; and divide all those array elements by
for ( ; J<M; J = J+2) 5 which are divisible by 5 and multiply
S = S + A[I][J]; other array elements by 2. 3
}
return S;
}
OR
int SKIPSUM(int A[][3], int N, int M)
{
106
Address of T[10][40] = BaseAddress +
4[ (10 - 1) +(40 - l)x 90]
= 7200+4[9 + 39 x 90]
= 7200+4[9 + 3510]
= 7200+4 x 3519
= 7200+14076
Content of the array after calling = 21276
REASSIGNO function
(d) 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 two-
dimensional array starting from B[0]
[0]. 2
Ans)
Hint: If the following is the content
void REASSIGN (int Arr[ ], int Size) of the array:
{
for (int i=0;i<Size;i++)
if (Arr[i]%5==0)
Arr[i]/=5;
else
Arr[i]*=2;
}
OR
S)
C
{
(P
Arr[i]%5 ? Arr[i]/=5 :
er
Arr[i] *= 2;
nd
} Ans.
re
Vi
OR
C
{ int Sum=0;
ar
if ((I+J)%2==0)
nd
re
Sum+=B [I][J] ;
Vi
return Sum;
} Ans)
OR void SORTPOINTS(Game G[], int N)
int ALTERSUM(int B[ ][5],int N,int M) {
{ Game Temp;
int Sum=0; for (int I = 0; I<N-l; I++)
for (int I=0;1<N;1++) for (int J = 0; J<N-I-l; J++)
for (int J=0;J<M;J++) if(G[J].Points < G[J+l].Points)
{ {
if ((I%2==0 && J%2=0)||(1%2!=0 Temp = G[J];
&& J%2!=0)) G[J] = G[J+l];
Sum+=B [I][J] ; G[J+l] = Temp;
} }
return Sum; }
}
(b) An array S[40][30] is stored in the
DELHI 2009: memory along the column with each of
the element occupying 4 bytes, find
3. (a) Write a function SORTPOINTS( ) out the base address and address of
in C++ to sort an array of structure element S[20][15], if an element S[15]
Game in descending order of Points [10] is stored at the memory location
using Bubble Sort. 3 7200. 4
108 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
Ans)
Loc(S[I][J]) = Base(S)+W(I+J*N)
Loc(S[15][10]) =
Base(S)+4(15+10*40)
Base(S) = 7200-4*415
Base(S) = 7200-1660
Base(S) = 5540
Loc(S[20][15]) =
Base(S)+4(20+15*40)
Loc(S[20][15])
= 5540 + 4(20+15*40)
= 5540 + 4(20+600)
= 5540 + 4*620
= 5540 + 2480
= 8020
OR Ans)
= 5540
T
A[I][N-l] = Temp;
G
(P
Address of S[20][15] }
ar
= 5540 + 4 x 620 OR
er
= 8020 {
Vi
OR int Temp, I;
for(I=O; I<4; I++)
Address of Sri] [j] along the column = {
Base Address + W [( i - L1) + (j - L2) * M] Temp = A[I][0];
Address of S[15)[10] = A[I][0] = A[I][3];
BaseAddress + 4[(15 - 1)+(10-1) x 40] A[I][3] = Temp;
7200= Base Address + 4 [374] }
Base Address = 7200 - 4 x 374 }
= 7200 - 1496
= 5704 OUTSIDE DELHI 2009:
Address of 5[20)[15]
= 5704 + 4 [(20 - 1) + (15 - 1) x 40] 3. (a) Write a function SORTSCORE( )
= 5704 + 4 x 579 in C++ to sort an array of structure
= 5704 + 2316 Examinee in descending order of Score
= 8020 using Bubble Sort. 3
Address of T[i][j]
=BaseAddress + W [(i - L1) + (j - L2) * M]
Address of T[25] [10] =
BaseAddress + 4[(25 - 0)+(10 - 0)*50]
9800 = Base Address + 4 [525]
Base Address = 9800 - 4 * 525
= 9800 - 21.00
= 7700
Address of T[30][15]
=7700 + 4 [(30 - 0) + (15 - 0) x 50]
S)
= 7700 + 4 x 780
C
= 7700 + 3120
T
G
(P
= 10820
ar
OR
m
Ku
Ans)
er
Ans)
Loc(T[I][J]) = Base(T)+W(I+J*N)
110
Then the function should rearrange
the array as
10,12, 8, 7, 6, 1, 5, 2, 4
Solution:
void receive(int A[ ], int size)
{
int temp;
for(i=0,j=size-1;i<size/2;i++,j--)
{
temp=A[i];
A[i]=A[j];
A[j]=temp;
}
} //end of receive function.
}
m
OR where,
Ku
er
}
(P
ar
where, }
m
Ku
i , j = Index value of the unknown element accepts an integer array and its size
x , y = Index value of the known element as arguments and swap the elements
of every even location with its
Address of Array[3][6] following odd location.
= Address of Array[30][10]+ 4 [(3 - 30)
+(6 -10) * 40] Example :
= 9000 + 4 [-27 -160] If an array of nine elements initially
= 9000 - 4 x 187 contains the elements as
= 9000 -748 2,4,1,6,5,7,9,23,10
= 8252 then the function should rearrange
the array as
3.d)Write a function in C++ to print 4,2,6,1,7,5,23,9,10
the product of each column of a two
dimensional array passed as the void SwapArray(int A[ ], int N)
arguments of the function. {
Example : If the two dimensional int i,j,temp;
array contains
/* cout<<”\nThe elements before doing the desired
alterations…”;
for(i=0;i<N;i++)
cout<<A[i]<<’\t’; */
for(i=0;i<N-1;i+=2)
{
112
temp=A[i]; = 8152+3898
A[i]=A[i+1]; =12050
A[i+1]=temp;
} 3.d)Write a function in C++ to print
the product of each row of a two
/* cout<<”\nThe elements after completed the dimensional array passed as the
desired alterations…”;
for(i=0;i<N;i++) arguments of the function
cout<<A[i]<<’\t’; */
Example: if the two imensional array
} contains
for(i=0;i<r;i++)
C
for(i=0;i<r;i++)
ar
B = 10000-2050
Ku
B[i]=B[i]*A[i][j];
er
B = 7950 for(i=0;i<r;i++)
nd
re
=B + W ( (I-Lr) + R(J-Lc ) )
ar
1000=B+832
B =1000-832 Example : If an array of five elements
B =168 initially contains the elements
as 3, 4, 5, 16, 9
Therefore Address of then the function should rearrange
Array[2][3]=168+8*((2-0)+20(3-0)) content of the array as
=168+8*(2+20*3) 6, 2, 10, 8, 18
=168+8*62
=168+496 Solution:
=664
void accept(int a[ ],int size)
3.d)Write a function in C++ which {
accepts a 2D array of integers and its for (int i=0;i<size;i++)
size as arguments and displays the {
elements which lie on diagonals. if (a[i]%2= =0)
[Assuming the 2D Array to be a square a[i]=a[i]/2;
matrix with odd dimension i.e., 3x3, else
5x5 ,7x7 etc…] a[i]=a[i]*2;
cout<<a[i]<<’,’;
Example : if the array content is }
5 4 3 }
6 7 8
114
3.b)An array Arr[15][20] is stored in for(int j=0;j<size;j++)
the memory along the row with each if (i= = size/2)
element occupying 4 bytes. Find out cout<<a[i][j]<<’\t’;
the Base address of the location Arr[3] cout<<"\n Middle Column:";
[2], if the location Arr[5][2] is stored at for (i=0;i<size;i++)
the address 1500. for(j=0;j<size;j++)
if(j= =size/2)
Solution: cout<<a[i][j]<<’\t’;
Given Data: Arr[15][20] W=4 }
B=? R=15 C=20 Lr = 0 Lc = 0
Address of Arr[3][2] = ? DELHI 2006:
Address of Arr[5][2] = 1500.
3.a)Write function in C++ which
Address of an element (I,J) in row accepts an integer array and size as
major = B+W(C(I-Lr)+(J-Lc )) arguments and assign values into a
Therefore, 2D array of integers in the following
1500 = B+4(20(5-0)+(2-0)) format :
1500 = B+4(20*5+2)
1500 = B+4*102 If the array is 1, 2, 3, 4, 5, 6
1500 = B+408
B =1500-408
B=1092 The resultant 2D array is given below
Address of Arr[3][2]
=1092+4(20*3+2) 1 2 3 4 5 6
S)
=1092+4(62) 1 2 3 4 5 0
C
=1092+248 1 2 3 4 0 0
T
G
(P
=1340. 1 2 3 0 0 0
ar
1 2 0 0 0 0
m
Ku
Assumption 1 : LBR=LBC=0 1 2 3 4 5 6
C
T
G
(P
1000 = BA + 8 (7 × 30 + 5)
m
Ku
= BA + 1720
nd
re
BA = 1000 – 1720 1 0 0
Vi
= -720 1 2 0
1 2 3
Therefore,Base Address = - 720
Solution:
Thus, Address of MAT[20][5] = -720 +
8 ( 5 × 30 + 20) void input (int a[ ],int size)
= -720 + 8 × 170 {
= -720 + 1360 int b[size] [size];
= 640 for (int i=0;i.<size;i++)
{
Assumption 2 : LBR=LBC=1 for (int j=0;j<size;j++)
{
Therefore if(( i<j)
1000 = BA + 8 [(7-1) × 30 +(5-1)] b[i][j]=0;
= BA + 8[6 × 30 + 4] else
= BA + 8 ×184 b[i][j]=a[j];
= BA + 1472 cout<<b[i][j]<<’\t’;
BA = 1000 – 1472 }
= -472 cout<<endl;
}
Therefore,Base Address = - 472 }
OR
116
Therefore,Base Address = 896
const int R = 100, C = 100; Thus, Address of MAT[10][5]
void Arrayconvert(int A1D[ ], int N) = 896 + 4 ( 10 (10-1) + (5-1))
{ = 896+376
int A2D[R][C]={0}; = 1272
for(int I = 0; I<N; I++)
for (int J = 0; J <=I; J++)
A2D[I][J] = A1D[J]; DELHI 2005:
}
3.a)Write a function in C++ which
3.b)An array MAT[20][10] is stored in accepts an integer array and its size
the memory along the row with each as arguments and exchanges the
element occupying 4 bytes of the values of first half side elements with
memory. Find out the Base address the second half side elements of the
and the address of element MAT[10][5] array.
, if the location MAT[3][7] is stored at Example :
the address 1000.
If an array of 8 elements initial content as
Ans) 2, 4, 1, 6, 7, 9, 23, 10
Where
C
{
(P
for(i=0,j=size/2;j<size;i++,j++)
Ku
= 10 (given) {
nd
temp=a[i];
re
a[i]=a[j];
Therefore a[j]=temp;
}
(Assumption 1: LBR = LBC = 0) }
OR
MAT[3][7]=100 = BA + 4 (10 (3-0) + (7-0))
= BA + 148 void Exchange (int A [ ], int N)
BA = 1000 – 148 = 852 {
for (int I=0;I<N/2;I++)
Therefore,Base Address = 852 {
Thus, Address of MAT[10][5] = 852 + 4 int Temp=A[I];
( 10 (10-0) + (5-0)) A[I]=A[N/2+I];
= 852+420 A[N/2+I]=Temp;
= 1272 }
OR }
OR
(Assumption 2: LBR = LBC = 1)
void Exchange(int A[], int N)
MAT[3][7]=1000 = BA + 4 (10 (3-1) + (7-1)) {
= BA + 104 int M=(N%2==0)?N:N+l;
BA = 1000 – 104 for (int I=0; I<M/2; I++)
= 896 {
int Temp=A[I];
117
A[I]=A[M/2+I]; Solution:
A[M/2+I]-Temp; void Sum(int A[ ][ ],int R,int C)
} {
} int i,j,S=0;
for(i=0;i<R;i++)
3.b)An array Arr[15][35] is stored in for(j=0;j<C;j++)
the memory along the row with each of if(A[i][j]%2= = 0 ||A[i][j]%3= = 0)
its element occupying 4 bytes . Find S=S+A[i][j];
out the Base address and the address cout<<”\nThe Sum of all the values
of element Arr[2][5] , if the location which are divisible by 2 or 3 in
Arr[5][10] is stored at the address the array = “<<S;
4000. }
OUTSIDE DEHI 2005:
=3376
er
Ans)
nd
OR
re
Vi
118
void Exchange(int A[],int N) divisible by 3 or divisible by 5 present
{ in a 2D array passed as the argument
int M=(N%2=0)?N:N+l; of the function.
for (int I=0;I<M/2;I++)
{ Ans)
int Temp=A[I]; void Sum(int A[ ][ ],int R,int C)
A[I]=A[M/2+I]; { int S=0,i,j;
A[M/2+I]=Temp; for(i=0;i<R;i++)
} for(j=0;j<C;j++)
} if((a[i][j]%3= =0)||(a[i][j]%5= =0))
S=S+A[i][j];
3.b)An array Arr[35][15] is stored in cout<<" nThe Sum of all the values
the memory along the row with each of which are divisible by 3 or 5 in
its element occupying 4 bytes . Find the array = “<<S;
out the Base address and the address }
of element Arr[20][5] , if the location
Arr[2][2] is stored at the address 3000. DELHI 2004:
Base(Arr) =2872
(P
ar
Example :
m
Ku
LOC(Arr[20][5])
er
=2872+4*(300+5)
re
OR Solution:
Ans)
C
elements A[1],A[2],…A[N] is in
T
G
int n,int Z[ ])
m
{
er
subarray A[1],A[2],…,A[K-1].
re
mn=m+n;
Vi
Output:
C
D1=D1+MATRIX[i][j];
T
G
D2=D2+MATRIX[i][j];
m
Ku
return 0; if (A[I]<B[J])
T
G
}
(P
C[K++]=A[I++];
ar
else if (A[I]>B[J])
m
Ku
SumD1+=M[I][I];SumD2+=M[N-I-1][I]; {
T
G
}
(P
<<SumD2<<endl; SumR+=M[C][R];
Vi
} cout<<SumR<<endl;
}
MODEL PAPER 2 FOR 2009-10: }
Ans)
C
T
W=2 {
ar
N=40
Ku
M=30 C[i]=2*A[i]+3*B[i];
er
}
nd
Loc(S[15][5])=5500
re
}
C
else
T
G
cout<<“stack Empty”;
ar
}
m
Ku
void Stack::Display( )
er
{
nd
re
Ans.
S)
C
T
G
(P
ar
m
Ku
er
nd
re
OR
Vi
Ans)
#include <iostream.h>
#include <conio.h>
struct NODE
{
char City[20];
NODE *Next;
};
class Queue
{
NODE *Rear,*Front;
puplic:
Queue( )
{
Rear=NULL;Front=NULL;
128
} }
void Qinsert( ); }
void Qdelete( ); void main( )
void Qdisplay( ); {
~Queue( ); Queue QU;
}; char Ch;
void Queue::Qinsert( ) do
{ {
NODE *Temp; :
Temp=new NODE; :
cout<<”Data:”; } while (Ch!=’Q’);
gets (Temp->City); }
Temp->Next=NULL;
if (Rear==NULL) (e) Evaluate the following postfix
{ notation of expression: 2
Rear=Temp; (Show status of Stack after each operation)
Front=Temp; True, False, NOT, OR, False, True, OR, AND
}
else
{
Rear–>Next=Temp;
Rear=Temp;
}
}
S)
void Queue::Qdelete( )
C
{
T
G
(P
if (Front!=NULL)
ar
{
m
Ku
NODE *Temp=Front;
er
cout<<Front->City<<”Deleted \n”; OR
nd
re
Front=Front->Next;
Vi
delete Temp;
if (Front==NULL)
Rear=NULL;
}
else
cout<<”Queue Empty..”;
}
Queue:: Qdisplay( )
{
NODE *Temp=Front;
while (Temp!=NULL)
{
cout<<Temp->City<<endl;
Temp=Temp->Next;
}
}
Queue:: ~Queue( )//Destructor Function
{
while (Front!=NULL)
{
NODE *Temp=Front;
Front=Front->Next; delete Temp;
129
}
void QUEINS( ); //Function to insert a node
void QUEDEL( ); //Function to de1ete a
node
void QUEDISP( );//Function to disp1ay nodes
~Queue( ); //Destructor to de1ete a11 nodes
};
void Queue::QUEINS( )
{
Node *Temp;
Temp = new Node;
cin>>Temp->PId;
gets(Temp->Pname);
//Or cin>>Temp->Pname;
//cin.get1ine(Temp->Pname);
Temp->Next = NULL;
if (Rear = = NULL)
{
Front = Temp;
Rear = Temp;
}
e1se
{
Rear->Next = Temp;
Rear = Temp;
S)
}
C
T
}
G
(P
OR
ar
m
Ku
er
nd
{
Vi
Ans)
class Queue
{
Node *Front, *Rear;
public:
QUEUE( )
//Constructor to initialize Front and Rear
{
Front = NULL;
Rear = NULL;
}
void QUEINS( );
//Function to insert a node
void QUEDEL( );
S)
C
void QUEDISP( );
G
(P
~Queue();
m
OR
Ku
};
nd
re
Vi
void Queue::QUEDEL( )
{
if (Front!=NULL)
{
NODE *Temp=Front;
cout<<Front->Itemno<<” “;
cout<<Front->Itemname<<”Deleted“;
Front=Front->Link;
delete Temp;
if (Front NULL)
Rear=NULL;
}
else
cout<<”Queue Empty..”;
}
OR
A + B * (C – D) / E
Ans)
DELHI 2008:
A + B * (C - D) / E
= (A+ ( (B* (C-D) ) / E) )
3.c) Write a function in C++ to insert
an element into a dynamically
allocated Queue where each node
contains a name (of type string) as
S)
C
data.
T
G
(P
struct THENODE
re
Vi
{
char Name[20];
THENODE *Link;
};
Solution:
struct THENODE
{
char Name[20];
THENODE *Link;
OR };
class Queue
{
THENODE *front,*rear;
public:
Queue( )
{
front = rear = NULL;
}
void Insert( );
void Delete( );
132
void Display( );
};
void Queue::Insert( )
{
THENODE *ptr;
ptr=new THENODE;
if(ptr= = NULL)
{
cout<<”\nNo memory to create a
new node….”;
exit(1);
}
cout<<”\nEnter the name….”;
gets(ptrName);
ptrLink=NULL;
if(rear= = NULL)
front=rear=ptr;
else
{
rearLink=ptr;
rear=ptr;
}
}
S)
4, 10, 5, +, *, 15, 3, /, -
m
Ku
er
nd
re
Vi
133
{ front=rear=NULL; }
void Insert( );
void Delete( );
void Display( );
};
void Queue::Delete( )
{
MYNODE *temp;
if(front= = NULL)
cout<<”Queue Underflow”;
else
{
cout<<”\nThe content of the
element to delete: “<<frontNUM;
temp=front;
front=frontLink;
delete temp;
}
}
Ans)
ar
struct MYNODE
{
float NUM;
MYNODE * Link;
};
Solution:
struct MYNODE
{ DELHI : 2007
float NUM;
MYNODE *Link; 3.c)Write a function in C++ to delete a
}; node containing Book’s information,
class Queue from a dynamically allocated Stack
{ of Books implemented with the help of
MYNODE *front,*rear; the following structure.
public: struct Book
Queue( ) {
134
int BNo ;
char BName[20] ;
Book *Next ;
};
Solution:
struct Book
{
int BNo ;
char BName[20] ;
Book *Next ;
};
class Stack
{
Book *Top;
public:
Stack( )
{
Top = NULL;
OUTSIDE DELHI : 2007
}
void Push( );
3.c) Write a function in C++ to delete
void Pop( );
a node containing customer’s
void Display( );
information, from a dynamically
S)
};
allocated Queue
C
of Customers
void Stack::Pop( )
T
G
{
following structure:
ar
Book *Temp;
m
Ku
cout<<”Stack Underflow…”;
nd
{
re
else
Vi
int CNo ;
{
char CName[20] ;
cout<<”\nThe Book number of the
Customer *Link ;
element to delete: “<<TopBNo;
};
cout<<”\nThe Book name of the
element to delete: “<<TopBName;
Solution:
Temp=Top;
Top=TopNext;
struct Customer
delete Temp;
{
}
int CNo ;
}
char CName[20] ;
Customer *Link ;
3.e)Evaluate the following postfix
};
notation of expression : 2
class Queue
25 8 3 - / 6 * 10 +
{
Customer *front,*rear;
public:
Queue( )
{
front=rear=NULL;
}
void Insert( );
void Delete( );
135
void Display( ); rear = - 1 ;
}; }
void Queue::Delete( ) void add( );
{ //to add an element into the queue
Customer *Temp; void remove( );
if(front= =NULL) //to remove an element from the queue
cout<<”Queue Underflow. No void Delete(int ITEM( );
//to delete all elements which are equal to
element to delete”; ITEM
else };
{
cout<<”\n The customer number for the Complete the class with all function
element to delete”<<frontCNo;
cout<<”\n The customer name for the
definitions for a circular array Queue.
element to delete”<<frontCName; Use another queue to transfer data
Temp=front; temporarily.
front = frontLink;
delete Temp; Solution:
}
} void queue::add( )
{
3.e) Evaluate the following postfix if((front= = 0 && rear = = 9) | |
notation of expression : 2 (front= =rear+1)
15 3 2 + / 7 + 2. * cout<<”\nQueue Overflow”;
else if (rear= = -1)
Ans) {
S)
front=rear=0;
C
T
cin>>data[rear];
(P
ar
}
m
Ku
{
nd
re
rear=0;
Vi
} void queue::add( )
OR {
int item;
void queue::add( ) if((front==0 && rear==9) ||
{ front==rear+1)
if ( (rear + 1) % 10 != front ) cout<<”\nQueue overflow error”;
{ else
if (rear == -1 ) {
front = rear = 0 ; cout<<”\nEnter an item to add : “;
else cin>>item;
rear = (rear + 1) %10; if(front==-1)
cin>>data[rear]; {
} front=0;rear=0;
else }
else
S)
} rear=rear+1;
T
G
{ rear=0;
m
data[rear]=item;
Ku
if (front != -1)
er
{ }
nd
if(front==rear) OR
front=rear=-1;
else void queue::remove( )
front = (front+1)%10; {
} if((front==-1 )
else cout<<”\nQueue Underflow Error”;
cout<<”Queue empty ! Underflow Error!!\n”; else
} {
OR int item=data[front];
if(front==rear)
void queue::add( ) front=rear=-1;
{ else if(front==9)
if ( (rear + 1) % 10 != front ) front=0;
//Ignoring –1 initial values else
{ front=front+1;
rear = (rear + 1) %10; cout<<”\nDeleted item is : “<<item;
cin>>data[rear]; }
} }
else
cout<<”Queue full !! Overflow Error !!\n”; 3.d) Write a function in C++ to
} perform a PUSH operation on a
void queue::remove() dynamically allocated stack containing
{ real number.
137
struct Node 3.e) Write the equivalent infix
{ expression for
float Number ; a, b, AND, a, c, AND, OR.
Node *Link ;
}; Ans) a, b, AND, a, c, AND, OR
class STACK (a AND b), (a AND c), OR
{ (a AND b) OR (a AND c)
Node *Top ;
public :
STACK( )
{
Top = NULL;
}
void PUSH( ) ;
void POP( ) ;
~STACK( ) ;
};
Solution:
struct Node
{
float Number ; OUTSIDE DELHI : 2006
S)
Node *Link ;
C
}; 3.c) Introduction
T
G
(P
class STACK
ar
{ class stack
m
Ku
Node *Top ; {
er
{ public :
Top = NULL; stack( )
} {
void PUSH( ) ; top = - 1;
void POP( ) ; }
~STACK( ) ; void push( ) ;
}; //to push an element into the stack
void STACK::PUSH( ) void pop( ) ;
//to pop an element from the stack
{ Node *Temp;
Temp=new Node; void Delete(int ITEM) ;
//To delete all elements which are
if(Temp= =NULL) //equal to ITEM.
{ };
cout<<”\nNo memory to create the Complete the class with all function
node…”; definitions. Use another stack to
exit(1); transfer data temporarily.
}
cout<<”\nEnter the Number to be Solution:
inserted: “;
cin>>TempNumber; void stack::push( )
TempLink=Top; {
Top=Temp; if(top>=9)
} cout<<”Stack Overflow…”;
138
else { char Name[20];
{ NODE *Link;
top++; };
cout<<”\nEnter the element to be
inserted…”; Solution:
cin>>data[top]; class Queue
} {
} NODE *front,*rear;
void stack::pop( ) public:
{ Queue( )
if(top= =-1) {
cout<<”\nStack Underflow”; front = rear = NULL;
else }
{ void Insert( );
cout<<”\nThe element to be void Delete( );
deleted = “<<data[top]; void Display( );
top--; };
} void Queue::Insert( )
} {
void stack::Delete(int ITEM) NODE *ptr;
{ ptr=new NODE;
//Dear children, try to complete this function. if(ptr= = NULL)
{
cout<<”\nNo memory to create a
S)
new node….”;
C
} exit(1);
T
G
OR
(P
}
ar
void stack::push( )
Ku
gets(ptrName);
{ int n;
er
ptrLink=NULL;
nd
cout<<”Enter a value”;cin>>n;
re
if(rear= = NULL)
Vi
if (top==10) front=rear=ptr;
cout<<”Stack Overflow”; else
else {
data[++top]=n; rearLink=ptr;
} rear=ptr;
void stack::pop( ) }
{ }
if (top==-1)
cout<<”Stack Underflow”; 3.e) Write the equivalent infix
else expression for 10, 3, *, 7, 1, --,*, 23, +
cout<<data[top--];
} Solution:
10, 3, *, 7, 1, - , *, 23, +
void stack::Delete(int ITEM); This is in Postfix form
//Ignore this part (ie Operator will come after the operand(s));.
class STACK
{
Node *Top ;
public :
STACK( )
{Top = Null ;}
S)
void PUSH( ) ;
C
void POP( ) ;
T
G
(P
~STACK( ) ;
ar
};
m
Ku
er
Solution:
nd
re
Vi
struct Node
{
int X,Y ;
Node *Link ;
};
class STACK
{
Node *Top ;
public :
STACK( )
{ Top = NULL;
}
void PUSH( ) ;
void POP( ) ;
~STACK( ) ;
};
void STACK::PUSH( )
{
Node *Temp;
Temp=new Node;
if(Temp= =NULL)
{
140
OUTSIDE DELHI : 2005
S)
struct Node
re
Vi
{
float U, V ;
Node *Link ;
};
class QUEUE
{
Node *Rear, *Front ;
public :
QUEUE( )
{
Rear = NULL;
Front = NULL;
}
void INSERT( ) ;
void DELETE( ) ;
~ QUEUE( ) ;
};
Solution:
void Queue::DELETE( )
OR {
141
NODE *temp;
if(front= = NULL)
cout<<”\nQueue Underflow”;
else
{ cout<<”\nThe value of U of the
element to delete: “<<FrontU;
cout<<”\nThe value of V of the
element to delete: “<<FrontV;
temp=Front;
Front=FrontLink;
delete temp;
}
}
Ans)
S)
C
T
G
(P
ar
m
Ku
er
nd
re
Vi
142
3.e)Define member functions queins( )
to insert nodes and quedel ( ) to delete
nodes of the linked list implemented
class queue, where each node has the
following structure:
struct node
{
char name[20] ;
int age ;
node *Link ;
};
class queue
{
2004: node *rear, *front ;
public :
3.d) Obtain the postfix notation for the queue( )
following infix notation of expression { rear = NULL; front = NULL} ;
showing the contents of the stack and void queins( ) ;
postfix expression formed after each void quedel( ) ;
step of conversion : };
(P—Q)/(R*(S—T)+U)
Ans) ((P-Q)/((R*(S-T))+U)) Solution:
S Symbol Stack Expression Y
S)
No Scanned
void queue::queins( )
C
{
T
G
(P
1 ( ( node *ptr;
ar
2 ( ( ( ptr=new node;
m
Ku
3 P ( ( P if(ptr= = NULL)
er
4 - ( (- P {
nd
5 Q ( (- P Q
re
6 ) ( P Q -
7 / ( / P Q - new node….”;
8 ( ( / ( P Q - exit(1);
9 ( ( / ( ( P Q - }
10 R ( / ( ( P Q - R cout<<”\nEnter the name….”;
11 * ( / ( ( * P Q - R gets(ptrname);
12 ( ( / ( ( * ( P Q - R
cout<<”\nEnter the age…”;
13 S ( / ( ( * ( P Q - R S
14 - ( / ( ( * ( - P Q - R S
cin>>ptrage;
15 T ( / ( ( * ( - P Q - R S T ptrLink=NULL;
16 ) ( / ( ( * P Q - R S T if(rear= = NULL)
- front=rear=ptr;
17 ) (/ ( P Q - R S T else
- *
{
18 + (/ ( + P Q - R S T
- * rearLink=ptr;
19 U (/ ( + P Q - R S T rear=ptr;
- * U }
20 ) (/ P Q - R S T }
- * U + void queue::quedel( )
21 ) P Q - R S T
{
- * U + /
node *temp;
if(front= = NULL)
Postfix Form: PQ-RST-*U+/
cout<<”Queue Underflow”;
else
143
{ NODE *ptr;
cout<<”\nThe name of the ptr=new NODE;
element to delete: “<<frontname; if(ptr= = NULL)
cout<<”\nThe age of the element to {
delete: “<<frontage; cout<<”\nNo memory to create a
temp=front; new node….”;
front=frontLink; exit(1);
delete temp; }
} cout<<”\nEnter the Ticket
} Number….”;
cin>>ptrTicketno;
DELHI : 2003 cout<<”\nEnter the Passenger
Name..”;
3.c) Evaluate the following postfix gets(ptrPName);
expression using a stack and show the ptrNext=NULL;
contents of stack after execution of if(rear= = NULL)
each operation: front=rear=ptr;
20, 45, +, 20, 10, -, 15, +, * else
{
Ans) Children, Try this answer as an rearNext=ptr;
assignment. rear=ptr;
}
3.e)Consider the following portion of a }
program, which implements
S)
class Stack
nd
re
onto STACK and adding a right STACK, and release the memory.
er
empty.
Algorithm: struct City
Suppose X is an arithmetic expression { long Cpin ;
written in infix notation. This char CName[20] ;
algorithm finds the equivalent postfix City *Next ;
expression Y. };
1. Push “(“ onto STACK, and add “)” to
the end of X. class Stack
2. Scan X from left to right and {
REPEAT Steps 3 to 6 for each element City *Top;
of X UNTIL the STACK is empty. public:
3. If an operand is encountered, add Stack( ) { Top = NULL; }
it to Y. void Push( );
4. If a left parenthesis is encountered, void Pop( );
push it onto STACK. void Display( );
5. If an operator is encountered, then: };
(a) Repeatedly pop from STACK and
add to Y each operator(on the top of void Stack::PUSH( )
STACK) which has the same { City *Temp;
precedence as or higher precedence Temp=new City;
than operator. if(Temp= =NULL)
(b) Add operator to STACK. {
145
cout<<”\nNo memory to create class Queue
the node…”; {
exit(1); NODE *front,*rear;
} public:
cout<<”\nEnter the City Pin Code Queue( )
to be inserted: “; {
cin>>TempCpin; front = rear = NULL;
cout<<”\nEnter the City Name to }
be inserted: “; void Insert( );
gets(TempCName); void Delete( );
TempNext=Top; void Display( );
Top=Temp; };
} void Queue::Insert( )
void Stack::POP( ) {
{ NODE *ptr;
City *Temp; ptr=new NODE;
if( Top= = NULL) if(ptr= = NULL)
cout<<”Stack Underflow…”; {
else cout<<”\nNo memory to
{ create a new node….”;
cout<<”\nThe City Pin Code for exit(1);
the element to delete: “<<TopCpin; }
cout<<”\nThe City name of the element
to delete: “<<TopCName;
cout<<”\nEnter the Number….”;
Temp=Top; cin>>ptrNumber;
S)
Top=TopNext; ptrLink=NULL;
C
if(rear= = NULL)
T
delete Temp;
G
(P
} front=rear=ptr;
ar
else
m
}
Ku
{
er
rearLink=ptr;
nd
DELHI : 2000
re
rear=ptr;
Vi
cout<<”Queue Underflow”;
C
else Temp=Top;
T
G
Top=TopNext;
(P
{
delete Temp;
ar
}
Ku
temp=front; }
nd
front=frontnext;
re
Vi
Ans)
C
T
G
(P
struct NODE
ar
m
{
Ku
float Data;
er
nd
NODE *Link;
re
Vi
};
class STACK
{
NODE *Top;
public:
STACK( );
void Push();
void Pop();
void Display();
~STACK();
};
void STACK::Push()
{
NODE *Temp;
Temp=new NODE;
cin>>Temp->Data;
Temp->Link=Top;
Top=Temp;
}
148
True, False, AND, True, True, NOT, OR, {
AND 2 char Name[20];
NODE *Link;
Ans) };
class QUEUE
{
NODE *R,*F;
public:
QUEUE();
void Insert();
void Delete();
};
void QUEUE::Insert()
{ NODE *Temp;
Temp=new NODE;
gets(Temp->Name);
Temp->Link=NULL;
if (Rear==NULL)
{
Rear=Temp;
Front=Temp;
}
else
{
S)
Rear->Link=Temp;
C
Rear=Temp;
T
G
(P
}
ar
}
m
Ku
er
postfix
re
notation of expression: 2
Vi
20,30,+,50,40,-,*
struct NODE
149
True, False, AND, True, True, NOT, OR,
AND
Ans)
numbers. 4
m
Ku
Ans)
er
nd
re
struct NODE
Vi
{ float Data;
NODE *Link;
};
class STACK
{ NODE *Top;
public:
STACK();
void Push();
void Pop();
};
void STACK::Push()
{ NODE *Temp;
Temp=new NODE;
cin>>Temp->Data;
Temp->Link=Top;
Top=Temp;
11.DATA BASE CONCEPTS
}
DELHI 2010:
Table: Item
OR
Ku
Table: Item
Delhi 2008:
DELHI 2009:
5.a) Differentiate between Candidate
5.(a)What are candidate keys in a key and Primary key in context of
table? Give a suitable example of RDBMS.
candidate keys in a table. 2
Ans:
Ans A table may have more than one
such attribute/group of attribute that
151
Candidate Key: All attribute identifies a row in a relation) are
combinations inside a relation that Candidate Keys as they are candidates
can serve primary key are Candidate for the primary key position.)
Keys as they are candidates for the
primary key position. Outside Delhi 2007:
create tables and other database Ans: The SQL DDL(Data Definition
nd
re
Relation 2: Instructor
m
Ans)
Ku
er
InstructorName Subject
nd
P.Pavan Electronics
Cardinality: Number of rows in a
The Cartesian product of these two table
relations, Student X Instructor, will
yield a relation that have a degree of
5(3+2:sum of degrees of Student and
Instructor) and a cardinality 6 (3 X 2: MODEL PAPER 2 FOR 2009-10:
Product of cardinalities of two
relations). 5.a) What do you understand by
Primary Key & Candidate Keys? 2
The resulting relation is as follows:
Ans)
Stude Studen Ho Instructo Subject An attribute or set attributes which
nt t st r are used to identify a tuple uniquely is
Numb Name ele Name known as Primary Key. If a table has
er r more than one such attributes which
1 Ravi Y K.Suman Computer identify a tuple uniquely than all such
Science attributes are known as Candidate
1 Ravi Y P.Pavan Electronics Keys.
2 Robert N K.Suman Computer
Science
2 Robert N P.Pavan Electronics
3 Raheem Y K.Suman Computer
154
Q5.(a) What do you understand
by Degree and Cardinality of a table?2
Answer:
Degree of a table is total number of
attributes.
Cardinality of a table is total number
of rows.
Ans.
nd
DELHI 2010:
re
FROM Store;
T
G
(P
WHERE ItemNo=2004;
nd
re
Ans. RATE*QTY
Vi
880
156
GARMENT table. (Display FCODE of
each GARMENT along with highest
and lowest price)
Ans SELECT FCODE, MAX (PRICE),
MIN(PRICE) FROM GARMENT GROUP
BY FCODE;
F04
C
T
G
(P
7
nd
OR Name acture
C
r
T
Powder
m
LAUNCHDATE<= ’20-JUN-08’
Ku
all the dresses which are made up of SH06 Shampoo XYZ 120
Vi
GROUP BY Manufacturer;
er
Ans:
nd
159
Ans: Update Item set ND08 ND02 P 16/j,Moore New
Dhingra Enclave Delhi
Price=Price+1000 KO19 MU15 A P Roy 2A,Central Kolkata
/avenue
(v)SELECT DISTINCT City FROM MU32 ND02 S mittal P 245, AB Mumbai
Colony
Customer.
ND48 MU50 B P jain 13,Block New
Ans: City d,a,viha Delhi
Delhi
Mumbai (i)To display the names of all
Bangalore consignors from Mumbai.
(vi)SELECT ItemName, MAX(Price), Ans: Select CnorName from Consignor
Count(*) FROM Item GROUP BY where city=”Mumbai”;
ItemName;
Ans: ItemName Max(Price) Count(*) (ii)To display the cneeID, cnorName,
Personal Computer 37000 3 cnorAddress, CneeName,
Laptop 57000 2
CneeAddress for every Consignee.
(vii)SELECT CustomerName, Ans: Select CneeId, CnorName,
Manufacturer FROM Item, Customer CnorAddress, CneeName,
WHERE CneeAddress from
Item.Item_Id=Customer.Item_Id; Consignor,Consignee where
Ans: CustomerName ManufacturerName Consignor.CnorId=Consignee.CnorId;
N.Roy PQR
H.Singh XYZ (iii)To display the consignee details in
R.Pandey COMP
C.Sharma PQR
ascending order of CneeName.
K.Agarwal ABC Ans: Select * from Consignee Orderby
S)
CneeName Asc;
C
Laptop 5500000
re
CONSIGNEE;
Outside Delhi 2007:
Ans:
CneeCity
5.b) Consider the following tables
Consignor and Consignee. Write SQL Mumbai
command for the statements(i)to(iv) New Delhi
And give outputs for the SQL quries (v) Kolkata
to ( viii). 6
(vi) SELECT A.CnorName A, B.CneeName
B FROM Consignor A, Consignee B
TABLE : CONSIGNOR
WHERE A.CnorID=B.CnorID AND
B.CneeCity=’Mumbai’;
CnorI CnorNam CnorAddress City
Ans)
D e
ND01 R singhal 24,ABC Enclave New Delhi
ND02 Amit 123,Palm Avenue New Delhi
Kumar
MU15 R Kohil 5/A,South,Street Mumbai
MU50 S Kaur 27-K,Westend Mumbai
(vii)SELECT CneeName,CneeAddress
FROM Consignee WHERE CneeCity
TABLE : CONSIGNEE Not IN (‘Mumbai’, ‘Kolkata’);
Ans:
CneeI CnorID CneeNa CneeAddre CneeCit
D me ss y CneeName CneeAddress
MU05 ND01 Rahul 5,Park Mumbai P Dhingra 16/J,Moore Enclave
Kishore Avenue
160
B P Jain 13,Block D,A Vihar
(iii)To display the sender details in
(viii) SELECT CneeID, CneeName ascending order of SenderName.
FROM Consignee WHERE CnorID =
‘MU15’ OR CnorID = ‘ND01’; Ans: Select * from Sender order by
SenderName;
Ans: CneeID CneeName
MU05 Rahul Kishore (iv)To display number of Recipients
KO19 A P Roy from each city.
R.Jain H.Singh
T
0
G
(P
S.Jha P.K.Swamy
ar
TABLE :RECIPIENT
m
Ku
(vii)SELECT RecName,RecAddress
er
v)Select FL_NO,NO_FLIGHTS,
AIRLINES from FLIGHTS, FARES
Where STARTING = “DELHI” AND
FLIGHTS.FL_NO = FARES.FL_NO
Ans:
TABLE:FARES
Ans: 7
C
T
G
(P
DELHI 2006:
ar
m
Ku
(i) Display FL_NO and NO_FLIGHTS and give outputs for SQL queries (v) to
from “KANPUR” TO “BANGALORE” (vi) :
from the table FLIGHTS. TABLE: DOCTOR
Ans: Select FL_NO, NO_FLIGHTS
from FLIGHTS where
Starting=”KANPUR” AND
ENDING=”BANGALORE”
EMPLOYEES
Doctor.Id=Salary.Id
Ku
er
nd
DELHI 2005:
163
(iii) To display the Firstname,
Lastname, and Total Salary of all
managers from the tables, where Total
Salary is calculated as Salary+Benifts.
Ans: Select
Firstname,Lastname,Salary+Benefits
from Employees, Empsalary where
Designation=”Manager” and
Employees.EmpId=EmpSalary.EmpId
Peter 28000
T
G
(P
ar
Ans: 4
nd
164
(iv) To display the minimum salary
among managers and Clerks from the
tables DESIG.
Ans:
SELECT MIN(SALARY), DESIGNATION
FROM DESIG WHERE
DESIGNATION IN ('Manager'.'Clerk')
GROUP BY DESIGNATION;
OR
SELECT MIN(SALARY), DESIGNATION
FROM DESIG WHERE
DESIGNATION= ‘Manager’ OR
DESIGNATION='Clerk' GROUP BY
DESIGNATION;
TABLE:ISSUED
OR
SELECT MIN(SALARY) FROM DESIG
WHERE DESIGNATION=
‘Manager’ OR DESIGNATION='Clerk';
OR
SELECT MIN(SALARY) FROM DESIG
WHERE DESIGNATION IN
(‘Manager’,‘Clerk’);
FROM WORKERS, DESIG WHERE (b)To show Book name, Author name
C
Manila 70000
nd
re
165
(g) To insert a new row in the table
Issued having the following data:
“F0002”,4
Ans: insert into Issued
values(“F0002”,4)
and NEWONES.
re
TABLE: INTERIORS
Ans: Select Count(*) from Interiors
Where Type=”Double Bed”
Game2 or both.
C
(b) To select all the information of Ans: Select Name From Sports Where
T
G
(d) To list all names of teachers with (iii) Display the names of the students
date of admission in ascending order. who have same game for both game1
Ans: Select Name from Teacher Order and game2
By Dateofjoining Asc Ans: Select Name From Sports Where
Game1=Game2
(e) To display Teacher's Name,
Department, and Salary of female (iv) Display the games taken up by the
teachers students, whose name starts with ‘A’.
Ans: Select Name,Department,Salary Ans: Select Game1,Game2 From
from Teacher Where Sex=”F” Sports Where Name Like “A%”
(f)To count the number of items whose (v) Add a new column named ‘marks’.
salary is less than 10000 Ans: Alter Table Sports Add Marks
Ans: Select Count(*) from Teacher Number(5);
Where Salary<10000
(g) To insert a new record in the (vi) Assign a value 200 for marks for
Teacher table with the following data: all those who are getting grade ‘B’ or
8,”Mersha”,”Computer”, ‘A’ in both Game1 and Game2.
(1/1/2000),12000,”M”.
167
Ans: (Children, Try This Answer as an (f) Give the output of the following
assignment) SQL statements:
(vii) Arrange the whole table in the (i) select COUNT (distinct
alphabetical order of name. SPORTS)from CLUB;
Ans: Select * from Sports Order By Ans: 4
Name
(ii) select MIN(AGE) from CLUB where
2000 : SEX =”F”;
Ans: 34
5. Write SQL commands for the (b) to
(e) and write the outputs for (g) on (iii) select AVG(PAY) fromCLUB where
thse basis of table CLUB. SPORTS = “KARATE”;
Ans: 1100
TABLE: CLUB
(iv) select SUM(PAY) from CLUB where
DATAOFAPP>{31/01/98};
Ans: 7800
TABLE:COACHES
S)
C
T
G
(P
ar
m
Ku
168
TEACHER
(c) To list names of female teacher who (b) To select all the information of
are in math department. patients of all cardiology department.
Ans: select name from teacher where Ans: Select all from Hospital where
sex=’female’ and department=’maths’; department=”Cardiology”
d) To list names of all teacher with (c) To list the names of female patients
their date of joining in ascending who are in ent department.
Ans:select name from Hospital where
S)
order.
C
by dateofjoing;
(d) To list names of all patients with
ar
m
(g) To insert a new row in the teacher (e) To display patients name, charges,
table with the following data: age, for only female patients.
9, “raja’, 26, “computer”, {13/5/95 }, Ans: Select Name,Charges,age from
2300, “M”. Hospital where sex=”F”
Ans: Insert into Teacher
values(9,”raja”,26, (f) To count the number of patients
”computer”, {13/05/95},2300,”M”); with age
1998: <30.
Ans: Select count(*) from hospitals
5. Write SQL commands for (b) to (g) where age<30
and write the outputs for (h) on the
basis of table HOSPITAL. (g) To insert the new row in the
hospital table with the following data:
11, “aftab”, 24, “surgery”, {25/2/98},
300, “M”.
Ans: insert into Hospital values(11,
“aftab”, 24, “surgery”, {25/02/98},
300, “M”)
MODEL PAPER 1 FOR 2009-10: (iii) To display the coach's name and
ACodes in ascending order of ACode
5.a)Consider the following tables from the table COACH
ACTIVITY and COACH and answer (b) Ans) SELECT Name, Acode FROM
and (c) parts of this question: COACH ORDER BY Acode;
S)
order of ParticipantsNum.
m
Ku
WHERE SchduleDate<'01-Jan-2004'
nd
re
ORDER BY ParticipantsNum;
Vi
(ii)SELECT MAX(ScheduleDate),
MIN(ScheduleDate) FROM ACTIVITY;
Ans) 19-Mar-2004 12-Dec-2003
(iii) SELECT Name,ActivityName
FROM ACTIVITY A,COACH C WHERE
A.Acode= C.Acode AND
A.ParticipantsNum = 10;
Ans) Ravinder Discuss Throw
b) Write SQL commands for the and give outputs for SQL queries (v) to
nd
flowing statements: 4
re
(viii) 6
Vi
ORDER BY ParticipantsNum;
C
v)SELECT COUNT(DISTINCT
Answer:
ar
Answer: GAMES;
nd
(ii)
re
172
v)SELECT COUNT(DISTINCT Number) (a) X+XY=X
FROM GAMES; (b)X(X+Y)+X
Answer: 2
(9) Third distributive Law: X+ Y=X+Y
(vi)SELECT MAX(ScheduleDate),
MIN(ScheduleDate) FROM GAMES; (10) Demorgan’s Theorems
Answer: 19-Mar-2004 12-Dec-2003 (a)
(b)
(vii)SELECT SUM(PrizeMoney) FROM
GAMES; DELHI 2010:
Answer: 59000
6. (a)Verify the following algebraically2
(viii) SELECT DISTINCT Gcode FROM (A’+B’).(A +B)=A’.B+A.B’
PLAYER;
Answer: 101 Ans. LHS
103 (A’ +B’ ) . (A+B)
108 = A’.A + A’.B + A.B’ + B’.B
= 0 + A’.B + A.B’+ 0
= A’.B + A.B’
13. Boolean Algebra = RHS (Verified)
0 + X = X,
T
G
1 + X = 1,
(P
0.X = 0,
ar
m
1.X = X
Ku
er
nd
(a)X +X = X
(b)X.X = X
(5)Commutative Law:
(a) X+Y =Y+X
(b)X.Y=Y.X
Ans.
OR
L.H.S.
X’.Y + X.Y’
= (X’.Y+X) (X’.Y+Y’)
= (X’+X).(Y+X).(X’+Y’).(Y+Y’)
174
(c) Write the POS form of a Boolean
function H, which is represented in a
truth table as follows: 1
Ans)
OR
T
G
175
(b) Write the equivalent Boolean
Expression for the following Logic
S)
Circuit: 2
C
T
G
(P
ar
m
Ku
er
nd
re
Vi
Ans)
176
OR
OR
Vi
re
nd
er
Ku
177
m
ar
(P
G
T
C
S)
OR
OR
OR
2008 Delhi:
Ans)
Ans)
Canonical Product of sum form (POS): (b) Draw a Logical Circuit Diagram for
T
G
X’.(Y’+Z)
ar
m
Ku
Ans)
er
nd
re
Vi
Ans)
Ans)
F(X, Y, Z) = p (1, 3, 6, 7)
OR
F=(X+Y+Z’)(X+Y’+Z’)(X’+Y’+Z)(X’+Y’+Z’)
Ans)
Ans)
F=A.B’+C’.D
S)
C
T
G
(P
Ans)
OR
2007 Delhi:
6 (a) State Distributive law and verify d) Reduce the following Boolean
the same using truth table. 2 expression using K – Map : 2
Ans) F(U, V, W, Z) = ∑(0,1,2,3,4,10,11)
S)
C
T
G
(P
ar
m
Ku
er
nd
re
Vi
Ans)
180
OR
2006 Delhi:
(A+C)’.(A+B)’.(B+C)’ (a) A (B + C) = A B + A C
C
T
(b) A + (B C) = (A + B) (A + C)
G
(P
(P+Q’).(P+R)
Ku
OR
er
nd
(P+Q’+R).(P+Q’+R’).(P+Q+R)
re
Vi
181
OR
X.(X+Y)=X
OR
X+X’.Y=X+Y
OR
OR
er
nd
re
Vi
OR
OR
Ans)
Absorption Law: OR
X+X.Y=X
182
Algebraic Verification:
X+X.Y =X
X.1+X.Y =X
X.(1+Y) =X
X.1 =X
X =X
OR
X.(X+Y) =X
XX+X.Y =X
X.1+X.Y =X
X.(1+Y) =X
X.1 =X
X =X
Ans)
OR
(X+Y'+Z)(X'+Y+Z).(X'+Y'+Z)(X'+Y'+Z')
X+X’. Y =X+Y
(X+X’)(X+Y) =X+Y
(d) Reduce the following Boolean
1.(X+Y) =X+Y
expression using K – Map : 3
X+Y =X+Y
F(A, B, C, D,) =
OR
∑(0,1,2,3,4,5,10,11,15)
S)
X(X’+Y) =X.Y
C
XX’+X.Y =X.Y
T
G
(P
0+X.Y =X.Y
ar
X.Y =X.Y
m
Ku
Ans)
U.V’+U’.V+U’.V
2005 Delhi:
(c) Write the POS form of a Boolean
Function F, Which is represented by 6.(a) State and verify Associative law
the following truth table: 1 in Boolean Algebra. 2
Ans)
183
Ans)
OR
C
Ans)
Ans)
184
(b) Give the following truth table,
derive a sum of product (SOP) and
Product of Sum (POS) Form of
Boolean expression from it:
OR
F(a,b,c,d) =
∑(0,1,2,4,5,7,8,9,10,11,14)
d)Draw the logic circuit for a Half
Adder using NAND gates Only. (Out
S)
C
OR of Syllabus now)
T
G
(P
ar
2003:
m
Ku
er
truth table.
F(U,V,W,Z,)=
∑(0,2,3,4,7,9,10,13,14,15)
2002:
2004:
6. (a) State the Distributive law and
6.(a) State and prove the Absorption
verify the law using Truth table.1
law algebraically.
185
(b) Prove XY + YZ + Y’Z =XY + Z , (f) Derive the expression for a Full a
algebraically. 2 Adder (Out of syllabus now).
(c
) Obtain the simplified form, of a 2000:
Boolean expression using Karnaugh
map. 2 6. (a)State Absorption Laws. Verify
F(w,x,y,z)=∑(2,3,6,10,11,14) one of the Absorption Laws using a
truth table.
(d) Represent the Boolean expression
(X+Y)(Y+Z)(X+Z) with help of NOR (b) Prove
gates only. 1 X’.Y+Y’.Z=X’.Y.Z+X’.Y’.Z’+X.Y’.Z+X’.Y’.Z
algebraically.
(e) Given the following truth table,
write the product of sums form of the (c) Obtain simplified form for a
function. boolean expression
F(x,y,z,w)= ∑ (1,3,4,5,7,9,11,12,13,15)
using Karnaugh Map.
Principle.
Vi
(c)If F(a,b,c,d) =
Π (0,1,3,4,5,7,8,9,11,12,13,15),
Obtain the simplified form using K-map.
What if the output if (i) both inputs (d) Minimise F(w,x,y,z) using
are FALSE(0) (ii) one is FALSE and Karnaugh map.
the other is TRUE. F ( w,x,y,z) = Σ (0,4,8,12)
186
(e) Draw the logic circuit for a half-
adder. (Out of syllabus now)
1998:
S)
C
T
truth tables.
Ku
187
(b)Write the equivalent Boolean
Expression for the following Logic
Circuit 2
Ans)
F(U,V,W) = (U+V+W’).(U+V’+W’).
(U’+V+W’)
X+X’.Y = X+Y
L.H.S. = X+X’.Y
(X+X’).
(X+Y)
= 1.(X+Y)
= X+Y
= R.H.S
188
Other Important Paper: c) Write the POS form of a Boolean
function F, which is represented in a
6. (a) State and verify Distributive law truth table as follows: 1
in Boolean Algebra. 2
F(U,V,W) =
F(A,B,C,D)=
(U+V+W').(U+V'+W').(U'+V+W')
Π (1,3,4,5,7,9,11,12,13,14)
d) Reduce the following Boolean
MODEL PAPER 1 2009-10:
Expression using K-Map: 3
F(A,B,C,D)=Σ(0,1,2,4,5,6,8,10)
6.a) State and verify Demorgan's Laws
S)
algebraically. 2
C
Ans)
T
G
(P
Ans)
ar
(X+Y)' = X'.Y'
m
Ku
Verification
er
(X+Y)'.(X+Y) = X'.Y'.(X+Y)
nd
re
0 = X'.Y'.X + X'.Y'.Y
Vi
b)Write the equivalent Boolean 7. (a) What was the role of ARPANET
Expression for the following Logic in the Computer Network? 1
Circuit 2
Ans. The first computer network was
Ans) F(U,V)=U'.V+U.V' jointly designed by The Advanced-
Research Projects Agency (ARPA) and
c) Write the SOP form of a Boolean Department of Defence (DoD) of
function G, which is represented in a United States in 1969 and was called
truth table as follows: 1 ARPANET. It was an experimental
project, which connected a few
computers from some of the reputed
universities of USA and DoD.
ARPANET allowed access to computer
resource sharing projects. This
ARPANET was handed over to Defence
Communication Agency (DCA) for
further development.
(i) bps
(P
(ii) abps
ar
m
(iii) gbps
Ku
er
(iv) kbps
nd
Ans)
re
Vi
Ans. (ii)abps
F(P,Q,R) = P'.Q'R'+P'.Q'R+P'.Q.R+P.Q'.R
(c) What is the difference between
d)Reduce the following Boolean Trojan Horse and Virus in terms of
Expression using K-Map: 3 computers? 1
F(U,V,W,Z)= Π (0,1,2,4,5,6,8,10)
Ans) Ans.
Ans. Firewall
OR
S)
C
T
G
(P
ar
m
Ku
Ans.
OR
191
Any diagrammatic representation with resource sharing projects. This
valid justification ARPANET was handed over to Defence
Communication Agency (DCA) for
(e4) The NGO is planning to connect further development.
its International office situated in
Mumbai, which out of the following (b) Which of the following is not a unit
wired communication link, you will for data transfer rate? 1
suggest for a very high speed (i) mbps
connectivity? 1 (ii) kbps
(i) Telephone Analog Line (iii) sbps
(ii) Optical Fiber (iv) gbps
(iii) Ethernet Cable
Ans. (iii) sbps
Ans. (ii) Optical Fiber
(c) What is the difference between
(f)Write the full forms of the Virus and Worms in the computers?1
following:1
(f1) GNU Ans.
(f2) XML
Virus: Virus is a malicious program
Ans (f1) GNU’s not Unix that damages data and files and
(f2) eXtensible Markup Language causes harm to computer system.
(g) Write one advantage of each for Worms: Worms disrupt services and
S)
freely and liberally licensed because of (d) What term do we use for a
er
change. and improve its design and used to block unauthorized access
Vi
Ans.
(i) A Repeater should be placed when
the distance between any two
connecting buildings exceeds 70 m.
(ii) Every building will need one Hub /
Switch, to send signals to all of the
workstations connected to it
Ans.
(f1) FILE TRANSFER PROTOCOL
(f2) FREE SOFTWARE FOUNDATION
Ans.
Internet explorer
Firefox
Netscape
Chrome
Opera
Safari
OR any other Web Browser
DELHI 2009:
193
TCP/IP OR HTTP
7. (a) What is difference between Star
Topology and Bus Topology of (d) Name two switching techniques
network? 1 used to transfer data between two
terminals(computers).1
Ans)
Ans Message Switching and Packet
Bus Topology: It is characterised by Switching
common transmission medium shared OR
by all the connected hosts, managed Circuit Switching and Message
by dedicated nodes. It offers Switching
simultaneous flow of data and control. OR
Circuit Switching and Packet
Star Topology: It is characterised by Switching
central switching node
(communication controller) and (e) Freshminds University of India is
unique path (point to point link) for starting its first campus in Ana Nagar
each host. It is easy to add and of South India with its center
remove additional hosts by upgrading admission office in Kolkata. The
the centralised node. university has 3 major blocks
comprising of Office Block, Science
Block and Commerce Block in the 5
KM area Campus. As a network
expert, you need to suggest the
S)
Ans
(i) Global System for Mobile
Communication
(ii) Code Division Multiple Access
computers: 1
Ku
(ii) SWITCH
re
(iii) GATEWAY
Ans SWITCH
195
(ii) Advanced Research Projects Agency
Network
OR
T
G
(P
Switching
m
Ku
er
196
the buildings to connect all the (iii) File Transfer Protocol
computers : 1 (iv) Transfer Control Protocol/Internet
(i) GATEWAY Protocol
(ii) MODEM
(iii) SWITCH 3) How is Coaxial cable different from
Optical Fibre? 1m
Ans SWITCH
Ans)
(E4) Suggest the most suitable (very
high speed) service to provide data Coaxial Cable: Comparatively Slow,
connectivity between Admission Economic, convenient to lay down,
Building located in Delhi and the used in Bus topology of networks
campus located in Par am pur from Optical Fibre: Very fast, expensive,
the following options: 1 reliable, no interference
_ Telephone line
_ Fixed-Line Dial-up connection
_ Co-axial Cable Network 4) “Bias methodologies” is planning to
_ GSM expand their network in India, starting
_ Leased line with three cities in India to build
_ Satellite Connection infrastructure for research and
development of their chemical
Ans products. The company has planned
Satellite Connection to setup their main office in
OR Pondicherry – at three different
S)
Ans)
Unit
er
nd
Ans)
re
Vi
Ans)
Company has its corporate unit in connecting each of the following office
ar
units:
Ku
Ans)
Vi
4m
m
Ans)
Ku
Ans)
following devices?
Vi
Switch/Hub
Modem
Telephone
OUT SIDE DELHI 2007:
Ans)
Switch / Hub 1) What is the significance of Cyber
law? 1m
3) Which of the following
communication medium, you will Ans)
suggest to be produced by the
company for connecting their offices in Cyber law encompasses a wide variety
New Delhi for very effective and fast of political and legal issues related
communication? to the Internet and other
Telephone Cable communications technology, including
Optical Fibre intellectual property, privacy, freedom
Ethernet Cable of expression, and jurisdiction.
OR
Ans) Optical Fibre Restricting unauthorized access to
user accounts. Promoting,
4) Suggest a cable/writing layout for coordinating and controlling e-
connecting the company’s local offices business.
located in New Delhi. Also, suggest an
201
2) Expand the following terms with Approximate distance between these
respect to networking: 2m offices as per network survey team is
i) XML ii) WWW as follows
iii) WLL iv) TCP/IP
Ans)
Coimbatore Office 50
C
Association “is planning to start their the following set of their offices:
er
offices in four major cities in India to Head Office and Tech Office
nd
re
Ans)
Switch / Hub
Wireless
ar
1m
er
Ans)
nd
re
4) UNIVERSITY OF
CORRESPONDENCE in Allahabad is
setting up the network between its
different wings. There are 4 wings
named as Science (S), Journalism (J),
ARTS (A) and Home Science (H).
OR
Distances between various wings are
given below:
Number of Computers
Optical Fiber/Bus Topology
Wireless Wing A 150
203
Wing S 10
Wing J 05 (i) XML Extensible Markup Language
Wing H 50 (ii) GSM Global System for Mobile
(iii) SMS Short Messaging Service
{Message/Messaging both acceptable}
i) Suggest a suitable Topology for
(iv) MAN Metropolitan Area Network
networking the computer of all wings.
1m
3) Difference between Hackers and
Ans)
Crackers? 1
Star or Bus or any other valid
topology or diagram.
Ans)
ii) Name the wing where the Server to
Hackers: Computer enthusiasts who
be installed. Justify your answer. 1m
enjoy learning about computer
Ans)
systems and get into other
Wing A, because maximum number of
system/network for gaining more
computers are located at Wing A.
knowledge or may find flaws in the
system for rectification purposes.
iii) Suggest the placement of
Hub/Switch in the network. 1m
Crackers: Malicious programmers
Ans)
who break into secure systems for
Hub/Switch in all the wings.
stealing and corrupting/spoiling data.
OR
Correct diagram depicting placement
4) INDIAN PUBLIC SCHOOL in
of Hub/Switch in all the wings.
Darjeeling is setting up the network
S)
C
wings. 1m
Ku
HOSTEL (H).
Ans)
er
nd
2) Expand the following terms: 2m ii) Name the wing where the server to
i) XML ii) GSM be installed. Justify your answer. 1m
iii) SMS iv) MAN
Ans)
Ans)
204
Wing S the network is specified. All the
as it has the maximum number of computers packets are stored in the main
OR memory instead of disk. As a result
WingA accessing time of packets is reduced.
as it is placed in the Admin Wing (for security reasons)
Ans)
Inside all the four wings
DELHI 2005:
C
1m
1) What is the difference between
ar
Ans)
m
Ans)
to the Internet and other
communications technology, including
Message switching: The saurce
intellectual property, privacy, freedom
computer sends data (message) to the
of expression, and jurisdiction.
switching office, which stores data in a
buffer. It then looks for a free link
4) The Great Brain Organization has
to another switching office and sends
set up its new Branch at Srinagar for
data to that office. This process
its office and web based activities .It
continues until data is delivered to the
has 4 Wings of buildings as shown in
destination computer. This type of
the diagram:
switching technique is also known as
‘store and forward’ switching.
205
Center to center distances between Telephone Link (Most Suitable answer 2)
various blocks OR
Microwave
Wing X to Wing Z 50 m OR
Wing Z to Wing Y 70 m Radio Link/Radio Wave
Wing Y to Wing X 125 m OR
Wing Y to Wing U 80 m Satellite Link
Wing X to Wing U 175 m OR
Wing Z to Wing U 90 m WAN
Ans)
ar
Ans) Wing Y as it has largest number 3) What is the difference between XML
Vi
Ans)
OR
C
Microwave
T
G
(P
OR
ar
OR
er
OR
Vi
207
2) Write an advantage and a
disadvantage of using optical fibre 3) Write the two advantages and two
cables? 1m disadvantages of BUS Topology in
network? 2
3) Write one advantage and one
disadvantage of the following 4) What is the difference between LAN
topologies in network: 2m and WAN? 1m
i)STAR Topology
ii)BUS Topology
DELHI 1999:
4) What is the difference between MAN
and WAN? 1m 1) What is a bridge? 1m
2) What is the purpose of using FTP?1
DELHI 2002:
3) Give two advantages and
1) What is a Modem? 1m disadvantages of following network
topologies: 2m
2) Write the following abbreviations in i)BUS ii)Tree
their full form. 1m
i) FTP ii) WAN 4) What is the difference between WAN
iii) WWW and MAN. 1m
topologies in a Network. 1m
er
i)MOSAIC ii)Usenet
Vi
Ans)
The complaint has to be lodged with
the Police under IT Act.
the network.
T
G
(P
ar
Ans)
209
the maximum computers in the
network.
Ans)
Ans)
(P
ar
m
of
C
Ans)
211
e2) Suggest the most suitable place
(i.e. building) to house the server of
this organization with a suitable
reason.
Ans)
Ans)
S)
C
(i)Raj Building
T
G
(P
each block
Vi
Ans)
e4) The organisation is planning to
link its sale counter situated in
various parts of the same city, which
type of network out of LAN, MAN or
WAN will be formed? Justify your
answer.
Ans)
Ans)
212
Freeware, the name derived from experimental project, which connected
words "free" and"software". It is a a few computers of some of the
computer software that is available for reputed universities of USA and DoD.
use at no cost or for an optional fee. ARPANET allowed access and use of
Freeware is generally proprietary computer resource sharing projects.
software available at zero price, and is Later Defence Data Network (DDN)
not free software. The author usually was born in 1983.
restricts one or more rights to copy,
distribute, and make derivative works b)Expand the following terminologies:1
of the software. (i) CDMA (ii) GSM
Shareware is usually offered as a trial
version with certain features only Ans)
available after the license is
purchased, or as a full version, but for Code Division Multiple Access
a trial period. Once the trial period Global System for Mobile Communication
has passed the program may stop
running until a license is purchased. c)Give two major reasons to have
Shareware is often offered without network security. 1
support, updates, or help menus,
which only become available with the Ans)
purchase of a license. The words "free
trial" or "trial version" are indicative of Two major reasons to have Network
shareware. Security are
(i) Secrecy: Keeping information
S)
users.
G
(P
Ans)
Ans)
S)
e1) Suggest a cable layout of that between B and C are quite large,
ar
Layout 1:
214
In both the layouts, a hub/switch Bandwidth is the capability of a
each would be needed in all the medium to transmit an amount of
blocks, to interconnect the group of information over a distance.
cables from the different computers in Bandwidth of a medium is generally
each block measured in bits per second (bps) or
more commonly in kilobits per second
(kbps)
Ans)
Ans)
MODEL PAPER 2 FOR 2008-09: e)Ravya Industries has set up its new
center at Kaka Nagar for its office and
7.a)Define the term Bandwidth. Give web based activities. The company
unit of Bandwidth. 1 compound has 4 buildings as shown
in the diagram below:
Ans)
215
Ans)
Ans)
(i)Raj Building
(ii)In both the layouts, a hub/switch
each would be needed in all the
buildings, to interconnect the group of
S)
each block
G
(P
ar
m
Ans)
NETWORKS
FULL FORMS
e2) Suggest the most suitable place
(i.e. building) to house the server of TCP/IP – Transmission Control
this organisation with a suitable Protocol / Internet Protocol
reason. 1 LAN – Local Area Network
216
MAN – Metropolitan Area Network (Txd – Transmit, Rxd – Receive,
WAN – Wide Area Network RTS – Request to Send
Modem – Modulation(tor)/ CD – Carrier Detect,
Demodulation(tor) DSR – Data Set Ready,
URL – Uniform Resource Location CTS – Clear to Send
FTP – File Transfer Protocol DTR – Data Terminal Ready)
HTTP – Hyper Text Transfer Protocol RJ45 – Registered Jack – 45
PPP – Point to Point Protocol BNC – Bayone – Neill –
GSM – Global System for Mobile Concelman
CDMA – Code Division Multiple AUI – Attachment Unit Interface
Access SNA – Systems Network
WLL(WiLL)–Wireless in Local Loop Architecture
SMS – Short Message Service VFIR – Very Fast Infrared
WWW – World Wide Web URI – Uniform Resource Identifier
HTML – Hyper Text Markup URN – Uniform Resource Name
Language MIME – Mail and Multipurpose
XML – eXtensible Markup Internet Mail Extensions
Language POP – Post Office Protocol
NFS – Network File System SMTP – Simple Mail Transfer
Protocol
ARPANET – Advanced Research NNTP – Network News Transfer
Projects Agency Protocol
NSFnet – National Science Foundation HTTP – Hyper Text Transfer
NIU – Network Interface Unit Protocol
S)