Computer Science 2007
Class - X Duration : 3 Hrs. Maximum Marks: 70 ______________________________________________________________________
Q.No.1
a) What is abstract class? How is it different from concrete class? 2
b) Find the error(s) if any from the following and underline them:
struct emp;
{
int id;
char name[20];
private:
getemp(void);
showemp(void)
}
main()
{
do
{
cout<<in<<loop;
counter++;
}while(1) 2
c) What do you understood by constructor and destructor function in classes? How are these functions different from other member functions? 2
d) Find the output of the following program segment:
#include<iostream.h>
class student
{ private:
static int count;
int rollno, marks;
public:
void enter(int r,int m)
{rollno=r; marks=m; count++;
}
void show(void)
{ cout<<endl<<"Roll Number:"<<rollno<<endl;
cout<<"Marks:"<<marks<<endl;
}
static void showcount(void)
{ cout<<"Count="<<count<<endl;
}
};
int student::count=0;
void main(void)
{
student obj1,obj2,obj3;
obj1.enter(1001,99); student::showcount();
obj2.enter(1002,88); student::showcount();
obj3.enter(1003,100); student::showcount();
obj1.show(); obj2.show(); obj3.show();
} 3
e) Consider the following class declaration and answer the questions it followed :
class SmallObj
{
private:
int some,more;
void err_1(){cout<<”error”;}
public:
void Xdata(int d) {some=d; more=d++;}
void Ydata(void) { cout<<some<<” “ <<more;}
};
i) Write the name that specifies the above class
ii) Write the data of the class with their scope.
iii) Write all member functions of the class with their access scope.
iv) Indicate the member function of the SmallObj that sets data. 4
f) Find the output of the following program segment:
#include<iostream.h>
struct pixel { int c,r;};
void display(pixel p)
{ cout<<”Column=”<<p.c<<”Row=”<<p.r<<endl;
}
void main(void)
{ pixel x={40,50},y,z;
z=x; x.c+=10;
y=z; y.c+=10;
y.r+=20;
z.c-=15;
display(x); display(z);
}
2
Q.No2
a) Consider the following declarations and answer the questions given below:
class vehicle
{ int wheels;
protected:
int passenger;
public:
void input(int,int);
void output(void); };
class heavy_vechile:protected vehicle
{ int diesel_petrol;
protected:
int load;
public:
void readdata(int,int);
void writedata(void);
};
class bus:private heavy_vehicle
{ char make[20];
public:
void fetchdata(char);
void displaydata(void);
};
i) Name the base class and derived class of the class heavy_vehicle.
ii) Name the data members that can be accessed from function displaydata().
iii) Name the data members that can be accessed by an object of bus class out side its class definition.
iv) Is the member function output() accessible to the objects of heavy_vehicle class
4
b) What is the output of the following program segment:
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
main()
{
char * name="IntRAneT";
for(int x=0;x<strlen(name);x++)
if(islower(name[x]))
name[x]=toupper(name[x]);
else
if(isupper(name[x]))
if(x%2==0)
name[x]=tolower(name[x]);
else
name[x]=name[x-1];
cout<<name;
} 3
c) Write a menu driven program to simulate following operations on matrix using OOPs concept.
1. Accept a matrix
2. Do the transpose
3. Show the transpose
3
Q.No.3
a) Differentiate between the following:
i) ifstream class and ofstream class
ii) tellg() and seekg() functions 2
b) Assuming a binary file FUN.DAT is containing objects belonging to a class laughter (as defined below). Write a user defined function in C++ to add more objects belonging to class Laughter at the end of the file.
class Laughter
{ int Idno;
char Type[5];
Char desc[255];
public:
void Newentry()
{cin>>Idno; gets(Type);gets(desc); }
void shwoscreen(void)
{cout<<Idno<<Type<<desc; }
}; 3
Q.No.4
a) An Array X[20][20] is stored in the memory with each element requiring 4 bytes of storage. If the address of X[10][12] is 2596, find out the memory location X[12][14] for row major arrangement. 4
b) Assume an array S containing elements of structure student is required to be arranged in descending order of marks. Write a C++ function to arrange the same with the help of bubble sort. The array and its size is required to be passed as parameters to the function. Definition of the structure student is as follows:
struct student { int rollno;
char name[20];
float marks;
}; 4
c) Evaluate the following postfix expression using a stack and show the contents of stack after execution of each operation
5,11,+,6,8,+,12,*,+ 2
d) Convert the following arithmetic expression to Polish and reverse Polish notation:
((A+B)-((C+D)*E/F)*G) 2
e) Give the necessary declaration of a linked list implemented queue containing float type elements. Also write a user defined function in C++ to add a float type number in the queue. 4
Q.No.5
a) What is relation? Define degree of relation. 2
b) Given the following LAB relation: Write SQL command for the questions (A) to (D) and give the output of (E).
LAB
No ItemName CostPerItem Quantity Dateofpurchase Warranty Operational
1 Computer 60000 9 21/5/96 2 7
2 Printer 15000 3 21/5/97 4 2
3 Scanner 18000 1 29/8/98 3 1
4 Camera 21000 2 13/10/96 1 1
5 Hub 8000 1 31/10/99 2 1
6 UPS 5000 5 21/5/96 1 4
7 Plotter 25000 2 11/1/2000 2 5
A) To select the ItemName,which are within the Warranty period till present date.
B) To select the ItemName purchased after 31/10/97.
C) To list the ItemName in ascending order of the date of purchase where quantity is more than 3.
D) To display ItemName, CostPerItem, and Quantity.
E) Give the output of the following SQL commands:
i) select min(DISTINCT Quantity) from LAB;
ii) select min(Warranty) from LAB;
iii) select sum(CostPerItem) from Lab;
iv) select ItemName from LAB where sysdate-DateofPurchase>1; 6
Q.No.6
a) State and verify absorption Law. 2
b) Verify the following algebraically:
2
c) Show how AND and OR gates can be built from NAND gates only? 2
d) Obtain the simplified form of Boolean expression using K-map:
F(X,Y,Z,W)=?(1,3,4,5,7,9,11,13,15) 2
Q.No.7
a) Write a short note on Firewall and cookies. 2
b) Write the full form of
1) WAIS
2) XML 1
c) What is EDGE? 1
d) Infoline organization has to set up its new center at Bangalore for its web and office based activities. It has four building as shown in the diagram below:
Center to center distances between various buildings
Marketing to Service 150 m
Service to Admin 200m
Admin to Designing 25m
Marketing to Designing 170m
Service to Designing 220m
Marketing to Admin 190m
Number of computers in each building
Marketing 75
Service 50
Admin 200
Designing 50
i) Suggest the cable layout of connections between the buildings so as to have centralized administration on all.
ii) Suggest the most suitable place to host the server of this organization with a suitable reason.
iii) Suggest the placement of following devices with justification:
1) Repeater
2) Hub/Switch
iv) The organization is planning to link its offices situated in the city without compromising on bandwidth and speed. Suggest the suitable cable and network device(s) with justification.
4