Anda di halaman 1dari 7

Jaspal Kaur Public School

PREBOARD 2012 2013


COMPUTER SCIENCE [CODE083]
CLASS XII
Max Time : 3 hours

Max Marks : 70

1.
(a) What is the difference between Procedural Programming and Object Oriented Programming? Give an example in
C++ to illustrate the difference between them.
2
(b) Write the names of the header file(s) needed to include in the following program:

void main()
{
char St[] = Test;
int i = 0;
while(St[i]!= \0)
cout<<tolower(St[i++]);
}
(c) Rewrite the following program after removing any syntactical errors. Underline each correction.

#include<iostream.h>
void main()
{
int *P,N[5];
N={5,10,15,20,25};
P=&N;
for(I = 0; I<5; I++)
{ cout>>*P>>endl;
P++;
}
}
(d) Find the output of the following program:

#include<iostream.h>
#include<string.h>
#include<ctype.h>
void main()
{
char Str[] = Pre Board 2011;
int i=0;
strrev(Str);
while(Str[i]!=\0)
{
if (isdigit(Str[i]))
Str[i]++;
else if (isupper(Str[i]))
Str[i] = Str[strlen(Str) i - 1];
else if (!isalnum(Str[i]))
Str[i] = #;
i++;
}
cout<<Str<<endl;
}
(e) Find the output of the following program:

#include<iostream.h>
void main()
{
int Arr[] = {12,23,34,45};
int *P = Arr, I,J;
-1-

for(I = 1; I<=4; I++)


{
*P += *P%2;
for(J=1; J<=I; J++)
cout<<Arr[J-1];
P++;
cout<<endl;
}
}
(f) Study the following program and select the possible output(s) from the options (a) to (d) following it. Justify
your answer.
2

#include<iostream.h>
#include<stdlib.h>
void main()
{ randomize();
int N = random(4)
switch(N)
{ case 1: cout<<
case 2: cout<<
case 3: cout<<
case 4: cout<<
}
}

2.

+ 1;
One;
Two; break;
Three<<endl;
Four;

(a)

OneTwoThree

(c)

(b)

ThreeFour

(d)

Two
Three
Two

(a) Differentiate between a constructor and a destructor? When do they get executed? Give a suitable example in
C++ to illustrate the difference.
2
(b)

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

class Stock
{
int Ino;
char IName[20];
public:
Stock()
{ cout<<Stock Created<<endl; }

};

//Function 1

void Assign(int N, char S[])


{ Ino = N; strcpy(IName, S); }

//Function 2

void ShowStock()
{ cout<<Ino << IName <<endl; }

//Function 3

~Stock()
{ cout<<Stock Over<<end1; }

//Function 4

(i) Write Statement 1, Statement 2, and Statement 3 to execute Function 1, Function 2 and
Function 3 respectively, in the following code:

void main()
{
____________
____________
____________
}

//Statement 1
//Statement 2
//Statement 3

(ii) What will be the output of the execution for the above code written in main( ) ?
-2-

(c) Define a class Trophy in C++ with following description:


Private Members
TId
//Data member for Trophy Id
Category
//Data member for Trophy Category
Price
//Data member for Trophy Price

Public Members
AssignCatg() //A function to Assign Category of a Trophy Based upon its Price
as follows:
Price
<=1000
>10000

Category
Regular
Premium

EnterDetails() //A function to enter value of TId and


//Price and invoke AssignCatg()
ShowDetails() //A function to display all data members
RCatg()
//A function to return Category

(d) Answer the questions (i) to (iv) based on the following:

class Appliances
{ char Make[20];
protected:
float Price;
public:
void A_Enter( );
void A_Display( );
};
class Electronic : public Appliances
{ char Brand[20];
public:
void E_Enter ( );
void E_Display( );
};
class Kitchen : public Electronic
{
char Category[20];
public:
void K_Enter( );
void K_Display( );
};
i.)

Which type of Inheritance is shown in the above example?

ii)

Write names of all the members accessible from K_Enter( ) function of class Kitchen.

iii)

Write name of all the members accessible through an object of class Kitchen.

iv)

What will be the size of objects of classes Appliances, Electronic and Kitchen respectively?

3.
(a) Write function definition for ShiftRight(int A[], int N ) in C++ which shifts every element of the array
one location to its right, such that the last element is shifted to the location of the first element, the first to the
second and so on. For example if an array of 5 integers as follows is passed to the function:
2
5

10

15

20

25

Then the function should rearrange the array as


25 5 10 15 20
-3-

(b) An array A[-36][-514] is stored in the memory along the row with each of the element occupying 2 bytes,
find the address of element A[4][10], if an element A[0][5] is stored at the memory location 10000.
3
(c) Write function definition for QREMOVE() in C++ to display and delete an element from a dynamically allocated
Queue containing integers.
4
(d) Write function definition for RotateLeft() in C++ which takes a two dimensional integer array of size 3 x 3 as its
parameter and rearranges the array by rotating it anticlockwise.
i.e. By placing reverse order first row content in the first column, reverse order of second row content in the
second column and reverse order of third row content in the third column.
3
Example: If the two dimensional array contains
5
2
1
3
9
6
10
12
8
The function call should rearrange the array as
1
6
8
2
9
12
5
3
10
(e) Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for the
conversion
2
(A B) * C + D / E
4.(a)

Given the following code in C++ answer questions (i) and (ii) that follow:

#include <fstream.h>
class Library
{
int BNo;
//Book Number
int Status;
//Book Status
public:
Book(){BNo = 0; Status = 0;}
void Transact(int S)
{ S = Status;}
void Show(); //Function to display Library Details
int RStat(){return Status;}
int RBNo() { return BNo; }
};
void Issue(int N)
//N stands for BookNumber to issue
{ fstream File;
File.open(BOOK.DAT,ios::binary|ios::in|ios::out);
int Found=0,Issued = 0;
Library L;
while (!Found && File.read((char*)&L,sizeof(L)))
{
if (L.RBNo()== N)
{ Found=1;
if(L.RStat() == 1)
cout<<Book Already Issued<<endl;
else
{
L.Transact(1);
__________________ //Statement 1
__________________ //Statement 2
Found=2;
}
}
}
if (!Found) cout<<Book does not exist<<endl;
File.close();
}
-4-

(i) Write Statement 1 to place the file pointer at proper place to update the record (object) in the file after the
changes as done in Transact() function.
(ii)
Write Statement 2 to store the updated record (object) for the book issued into the file BOOK.DAT.
(b) Write function definition for End_t( ) in C++ to read a text file NOTES.TXT and display its contents in
uppercase.
2
Example:
If the content of the file NOTES.TXT is as follows:
Keep smiling always
The function End_t() should display the following:
KEEP SMILING ALWAYS
(c) Write function definition for TotPrice( ) in C++ to read and display the Total Price of all the Gadgets from a
binary file GADGET.DAT which contains objects of the following class.
3
class Gadget
{ int Id;
char Name[20];
float Price;
public:
void Input();
//Function to enter the details
void Show();
//Function to display the details
float RPrice(){return Price;}.
};
5. (a) Differentiate between DDL and DML commands of SQL with suitable examples.

(b) Consider the following tables BUS and PASSENGER. Write SQL commands for the statements (c1) to (c4)
and give outputs for SQL queries (d1) to (d4)
Table: BUS
BNO START
V101 DELHI
V102 DELHI
V103 DELHI
V104 JAIPUR
V105 SHIMLA

END
SHIMLA
AGRA
JAIPUR
AGRA
MANALI

FARE
1500
1200
1500
1500
1200

Table: PASSENGER
PNO PNAME
AGE
GENDER BNO
P101 R K SHARMA 45
MALE
V102
P102 A KUMAR
32
MALE
V104
P103 M SINGH
21
FEMALE V101
P104 A K ROY
47
MALE
V104
P105 A SINHA
56
FEMALE V102
P106 R SAHAY
19
MALE
V102
(c1)
To display PNAME, AGE and GENDER of all MALE passengers from table PASSENGER.
(c2)
(c3)
(c4)

To display the details of all the PASSENGERs in ascending order of AGE within GENDER in
ascending order from table PASSENGER.
To display individually the total number of MALE and FEMALE PASSENGERs using a single
SQL query.
To display PNAMEs and their corresponding FAREs for all PASSENGERs travelling to AGRA
from the tables BUS and PASSENGER.

(d1)

SELECT PNAME, GENDER FROM PASSENGER WHERE AGE BETWEEN 45 AND 50;

(d2)

SELECT COUNT(DISTINCT BNO) FROM PASSENGER;

(d3)

SELECT START, END, FARE FROM BUS WHERE END IN (AGRA, JAIPUR);

(d4)

SELECT MAX(FARE) FROM BUS WHERE START = DELHI;


-5-

6. (a) State and verify Distributive Laws using truth table.

(b) Draw the Logic Circuit for the following Boolean Expression:
Y.Z + X.Y

(c) Derive a Canonical SOP expression for a Boolean function F, represented by the following truth table:

A
0
0
0
0
1
1
1
1

B
0
0
1
1
0
0
1
1

C
0
1
0
1
0
1
0
1

F(A,B,C)
1
0
1
0
0
1
1
0

(d) Reduce the following Boolean Expression to its simplest form using K-Map:
F(W,X,Y,Z)=(2,3,4,5,6,7,8,9,10,13,14,15)

7.a) Differentiate between Message switching and Packet switching.

b)

Expand the following abbreviations:


1
(i) CDMA
(ii) SMTP
c) Write one advantage and one disadvantage of BUS topology and STAR topology.

d)

Differentiate between Twisted Pair and Coaxial Cables used in wired networking.

e)Hitech Serivces Ltd. is planning to connect its Delhi office with its branch at Mumbai. The Delhi branch of the
company is spread across an area of approximately 50x100 square metres, consisting of 3 departments
Administration, Accounts and Sales.
You need to suggest the network plan according to E1 to E4, to the company, keeping in mind the distances
and other given parameters
Mumbai Branch

Delhi Branch

Accounts

Administration
Sales
Shortest distances between various locations:
Administration to Accounts
Accounts to Sales
Administration to Sales
Delhi Branch to Mumbai Branch

50 m
20 m
40 m
1700 Km

Number of Computers installed at various locations are as follows:


Administration
Accounts
Sales
Mumbai Branch

110
35
30
85

E1) Suggest the placement of switches and repeaters inside the Delhi Branch, to connect the different
departments computers with proper justification.
E2) Suggest the cable layout among the various departments inside the Delhi branch for connecting the
departments computers.
E3) Suggest a networking device and its placement needed to be installed to control inbound and outbound data
traffic and protect the network against unauthorized access and threats, inside the Delhi branch.
-6-

E4) Suggest the most suitable wireless media to provide secure, fast and reliable data connectivity between Delhi
Branch and the Mumbai Branch out of the following:
(a) Satellite Link
(b) Infrared
(c) Bluetooth
(d) Wi-Fi
a) Categorise the following as client side and server side scripting language:
JSP, VB Script, Java Script, ASP

b) Differentiate between Freeware and Shareware, giving suitable examples.


1

-7-

Anda mungkin juga menyukai