D.A.V.
Public School,Sector-14,Gurgaon
PreBoard Examination -2018-19
Class: XII Subject : Computer Science M.Marks:70
Note:
1. All questions are compulsory
2. Programming Language is C++
3. Few questions have internal choices.
Q1 A What is a function prototype ? How it is helpful ? Explain with some suitable example 2
B Write the names of header files required to execute the following program segment 2
Void main() { char yourstory[80] ;
gets(yourstory);
if(isalpha(yourstory[0])
cout<<”You have a wonderful idea about computer programming”;
else
cout.write(yourstory,5);
}
C Rewrite the following program after removing syntax error(s) if any in the following program, segment 2
void main( )
int A[10];
A=[3,2,5,4,7,9,10];
for( p = 0; p<=6; p++)
{ if(A[p]%2=0)
int S = S+A[p]; }
cout<<S; }
D Write the output of the following program segment ( assume all necessary header files are included ) 2
void repch(char s[])
{
for (int i=0;s[i]!='\0';i++)
{
if(((i%2)!=0) &&(s[i]!=s[i+1]))
{ s[i]='@'; }
else if (s[i]==s[i+1])
{
s[i+1]='!'; i++; }
}}
void main()
{
char str[]="SUCCESS";
cout<<”Original String”<<str
repch(str);
cout<<"Changed String"<<str;
}
E Find out the output of the following program segment 3
void main( )
{
int Ar[ ] = { 6 , 3 , 8 , 10 , 4 , 6 , 7} ;
int *Ptr = Ar , I ;
cout<<++*Ptr++ << '@' ;
I = Ar[3] - Ar[2] ;
cout<<++*(Ptr+I)<<'@'<<"\n" ;
cout<<++I + *Ptr++ << '@' ;
cout<<*Ptr++ <<'@'<< '\n' ;
for( ; I >=0 ; I -=2)
cout<<Ar[I] << '@' ;
}
F Observe the following program segment and find out which option(s) is/are the correct choice. Also find out 2
the maximum and minimum value assigned to ‘Go’
void main()
{ int X [4] ={100,75,10,125};
int Go = random(2)+2;
for (inti = Go; i< 4; i++)
cout<<X[i]<<”$$”; }
i. 100$$75 ii. 75$$10$$125$$ iii. 75$$10$$ iv.10$$125$
Q2 A Answer the questions (i) and (ii) after going through the following class : 2
class Exam
{
int Rollno;
char Cname[25];
float Marks ;
public :
Exam( ) //Function 1
{
Rollno = 0 ;
Cname=””;
Marks=0.0; }
Exam(int Rno, char candname) //Function 2
{
Rollno = Rno ;
strcpy(Cname,candname); }
~Exam( ) //Function 3
{
cout << “Result will be intimated shortly” << endl ;
}
void Display( )
//Func
tion 4
{
cout << “Roll no :”<<Rollno;
cout<<”Name :” <<Cname;
cout <<” Marks:”<<Marks;
}};
(i)Which OOP concept does Function 1 and Function 2 implement.Explain?
(ii)What is Function 3 called? When will it be invoked?
OR
Write any two differences between Constructor and Destructor with reference to Object Oriented Programming
B What do you mean by Data Hiding ? What is the significance of Data hinding 2
C Define a class Candidate in C++ with the following specification : 4
Private Members :
A data members Rno(Registration Number) type long
A data member Cname of type string
A data members Agg_marks (Aggregate Marks) of type float
A data members Grade of type char
A member function setGrade () to find the grade as per the aggregate marks
obtained by the student. Equivalent aggregate marks range and the respective grade as shown
below.
Aggregate Marks Grade
>=80 A
Less than 80 and >=65 B
Less than 65 and >=50 C
Less than 50 D
Public members:
Aconstructor to assign default values to data members:
Rno=0,Cname=”N.A”,Agg_marks=0.0
A function Getdata () to allow users to enter values for Rno. Cname, Agg_marks and call
function setGrade () to find the grade.
A function dispResult( ) to allow user to view the content of all the data members.
D Given the following class definition answer the question that is follow: 4
class University
{
char name [20];
protected :
char vc[20];
public :
void estd();
void inputdata();
void outputdata();
}
class College : protected University
{ int regno;
protected
char principal()
public :
int no_of_students;
void readdata();
void dispdata ( );
};
class Department : public College
char name[20];
char HOD[20];
public :
void fetchdata(int);
void displaydata( ); }
i). Name the base class and derived class of college.
ii) Name the data member(s) that can be accessed from function displaydata().
iii)What type of inheritance is depicted in the above class definition?
iv) Write the function names which is directly accessible from the object of Department Class
Q3 A Write a user defined function in C++ AddSum(int x[][4] , int row, int col) to find out and display the sum of 2
all those elements which are ending with 5.
Example
25 4 10
2 5 35
So the result of this problem is : 65
B Write a user defined function ExtraElement(int a[] , int b[] , int n ) to find and display that extra element in 3
first array A. Array a contains all the element of array b but also contains one more element. ( Restriction
Array elements are not in any order )
Array A is : 14,21,45,67,78,89,6,56
Array B is : 78,67,14,45,6,56,89
So the extra element is : 21
OR
Write a user defined function REVERSE(int a[] ,int n ) which accepts an array of integer of size N and
reverse the placement of its elements in array.
Example
Array A : 10,20,30,40,50 so resultant array : 50,40,30,20,10
C An array A[30][40] is stored in the memory with each element occupies 4 bytes of storage. If the base 3
addresss of A is 4300. Find the address of A[15][10] , if the contents are stored along the row.
D Write a function in C++ to delete a node containing student information, from a dynamically allocated stack 4
of students implemented with the help of following structure
Struct student { int Admno ; char studentName, student *next; };
OR
Write the definition of a member function insert_player() for a class queue in C++, to add a player in a
statically allocated queue of players. Consider the following class definitions
Struct player { int pno ; char playerName[30]; }
const int size = 10;
class queue{
player Ar[size];
int front, rear;
Public:
Queue() { front = rear = -1 }
Void insert_player() ;
Void remove_player() ;
Void display() ; }
E Convert the following infix expression into its equivalent postfix expression using stack 2
Exp = ( A-B) + C/D*E
OR
Evaluate the following postfix expression using stack
470,5,4,^,25,/,6,*
Q4 A Write a finction LineCount( ) in c++ that read a text file “YourText.txt” and count total number of lowercase 2
alphabets present in this file.
OR
Write a function reverseDisplay( ) in C++ that read a text file “Test.txt” file and rervese all those words that
start with any “Vowel” and print them on the screen.
B Write a function SearchDestination() in C++ that search and display the details of all those trains whose 3
destination is “Dehli” from the binary file”Trains.dat”. Assuming that the binary file contains the object of
following class
Class Trains { int trno ; char destination[30]; float fare;
Public:
Char * retDest () { return destination ; }
Void input ( ) ; // member function to read data from keyboard
Void output( ) ; // member function to show data on the screen
}
OR
Write a function in C++ to add one more object at the bottom of a binaryfile “DAV.dat” . Assuming the
binryfile is containing the object of following class
Classs student { int admno , char name[30]; char address[80];
Public:
Void input() { cin>>admno>>name>>address ; }
Void output() {cout<<admno<<name<<address ;}
}
c What is the function of seekg() in file handing? 1
Q5 A What is cartesian product ? Explain with some suitable example 1
B A table Passenger has 4 row and 5 columns. What is the degree and cardinality of this table 1
C Observe the following tables carefully and write SQL queries for (i) to (iv) and find output for SQL queries 6
(V) to ( VIII)
Table : Student
Admno Fees Name Stream Class Gender TrainerID
101 1205 Samriddhi Science 12A F 10
102 1250 Manan Singh Commerce 12B M 20
103 950 Swapnil Humanities 11A M 10
104 750 Diksha Singh Science 12A F 30
105 1450 Dhirendra Science 10a M 40
Table : Trainer
TrainerID TrainerName Game Name
10 Rakesh Kumar Judo
20 Mayank Sharma Boxing
30 Vikas Sharma VolleyBall
40 Deepak Rawat Sketing
i) Display the details of all female students in ascending order ( according to stream )
ii) Display details of student name, stream, class and trainer name from the above tables
iii) Show the list of all the students whose name start with alphbet ‘A’
iv) Display the details of all those students who is taking training in Boxing
v) SELECT * FROM STUDENT WHERE GENDER =’m’
vi) SELECT DISTINCT(STREAM) FROM STUDENT
vii) SELECT MAX(FEES) ,STREAM FROM STUDENT GROUP BY STREAM
viii) SELECT MIN(FEES) FROM STUDENT WHERE NAME LIKE ‘%pi% AND GENDER =’F’
Q6 A State and verify Associative law using Truth Table 2
B Draw a logic circuit for the following Boolean Expression ABC’+A’B+B’C 2
C Write the SOP form of a Boolean function F, which is represented in a truth table as follows 1
A B C F
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 0
D Obtain a simplified form for a Boolean expression using K-map: 3
F (U, V, W, Z) = II (0, 1, 3, 5, 6, 7, 15)
Q7 A Ujjwal Wants to install a wireless network in his office. Explain the advantage and disadvantage of Guided 1
medium and Unguided medium
B Write the full forms of the following terms used in Network and Mobile communications 2
i) CDMA ii) HTTPS iii) XML iv) URL
C Arun opened his Email and found that his inbox was full with thousands of unwanted emails. It took around 2 2
hours to delete all these unwanted emails and find the relevant ones. What may be the cause of his receiving
so many unsolicited email. What can arun do to prevent his happening in near future
D DAVschool Chander Nagar is setting up the network between its different wings of school campus. 4
1. Senior wing 2. Junior Wing 3. Admin Block 3. Hostel
Distance between these wings are as follows
Senior Wing to Junior wing 150
Junior wing to Admin Block 120
Admin Block to Hostel 100
Hostel to Senior wing 60
Senior wing to Admin Block 80
Number of computers in Each wing
Senior wing 150
Junior Wing 100
Admin Block 160
Hostel 50
i) Suggect the best wired medium and draw the cable layout to effectively connect various wings of
the campus
ii) Name the most suitable wing to host the server. Justify your answer
iii) Suggest device/software and its placement that would provide data security the whole school
iv) Suggest a device and the protocol that shell be needed to provide wireless internet access to all the
smartphone/laptops of the campus of DAV school