Class XII Computer Science: HOTS (High Order Thinking Skill)
Class XII Computer Science: HOTS (High Order Thinking Skill)
Computer Science
CHAPTER WISE
HOTS (High Order Thinking Skill)
QUESTIONS
BASED
ON
CBSE PATTERN
Prepared by: PGTs (Computer Science)
-2-
Question 1. REVISION TOUR C++, OOPs Concepts & POINTERS
Q2>How many times will the following program will print “examination”? 1
#include<iostream.h>
void main( )
{
while(1)
{
cout<<”examination”
}
}
-3-
{
int x,y=1;
if((x=y)!=0)
cout<<x<<" "<<y;
getch();
}
Program 2
# include<iostream.h>
# include <conio.h>
void main()
{
int x,y=0;
if((x=y=1)==1)
cout<<x<<" "<<y;
getch();
}
Q.1 What is the difference between the constructor and normal function?
Q.2 What is the similarity between class and the constructor? (HOTS)/Bright Student
-4-
void display()
{ cout<<statename<<endl;}
void replace(state&a, state &b)
{size=a.size+b.size;
delete statename;
statename=new char[size+1];
strcpy(statename, a.statename);
strcat(statename,b.statename);
}
};
void main()
{ clrscr();
char *temp="Delhi";
state state1(temp), state2("Mumbai"), state3("Nagpur"), s1,s2;
s1.replace(state1,state2);
s2.replace(s1,state3);
s1.display();
s2.display();
getch();
}
Q.4 What is the difference between nesting or containership and inheritance? Explain with example?
Q.5 What will be the output of the program?
#include<iostream.h>
class base
{ public:
void display()
{
cout<<"It is a base class "<<endl;
}
};
class derived: public base
-5-
{
public:
void display()
{ cout<<"It is a derived class "<<endl;}
};
main()
{
derived ob1;
ob1.display();
}
Q.8
Class testmeout
{ int rollno;
public:
~testmeout() //Function 1
{ cout<<rollno<<” is Leaving examination hall”<<endl;
}
testmeout() //Function 2
{ rollno=1;
-6-
cout<<rollno<<” is appearing for examination “<<endl;
}
testmeout(int n, char name[]) //Function 3
{ rollno=n;
cout<<name<<” is in examination hall”<<endl;
}
testmeout(testmeout & t);//function 4
void mywork() //Function 5
{ cout<<rollno<<” is attempting questions “<<endl;
}
};
i) In object oriented programming, what is Function 1 referred as and when does it get invoked?
ii) In object oriented programming, what is Function 2 referred as and when does it get invoked?
iii) In object oriented programming, what is Function 3 referred as and when does it get invoked?
iv) Write a statement so that function 3 gets executed?
Complete the definition of function 4
v) What will be the output of the above code if its main function definition is as given below (assumed the
definition of Function 4 is completed ) :
main()
{testmeout ob1;
ob1.mywork();
}
vi) Which feature of object oriented programming is demonstrated using Function 2, Function 3 and Function 4
in the above class testmeout?
vii) What is the scope of data member (rollno) of class testmeout? What does the scope of data members depend
upon?
Q. 2. Suppose an array P containing float is arranged in ascending order. Write a user defined function in C++
to search for one float from P with the help of binary search method. The function should return an integer 0 to
show absence of the number and integer 1 ti show presence of the number in the array. The function should have
the parameters as (1) an array (2) the number DATA to be searched (3) number of element N.
Q. 3 Write a function in C++ which accepts an integer array and its size as arguments / parameters and
assign the elements into a two dimensional array of integers in the following format :
If the array is 1, 2,3,4,5,6 If the array is 1,2,3
-7-
The resultant 2D array is given below The resultant 2D array is
1 2 3 4 5 6 given below
1 2 3 4 5 0 1 2 3
1 2 3 4 0 0 1 2 0
1 2 3 0 0 0 1 0 0
1 2 0 0 0 0
1 0 0 0 0 0
Q-4 Write a function in C++ to perform a PUSH operations on a dynamically allocated stack containing real
number? Given node as :
struct Node
{
float data;
Node * next;
};
Q-5 Each node of a STACK containing the following information, in addition to required pointer field:
Roll no. of the student
Age of the student.
Gve the structure of node for the linked stack in question.
TOP is a pointer to the topmost node of the STACK. Write the following function:
PUSH() – TO push a node in to the stack which is allocated dynamically.
POP() – Te remove a node from the stack and to release the memory.
Q.6 Write a function MAX in C++ which will return the Largest number stored in a two dimensional array of
Integers.
Q.7 Write a function in c++ which accepts a 2D array of integers and its size as arguments and displays the
elements which lies on diagonals.
[ Assuming the2D array to be a square matrix with odd dimensions , i.e 3x3, 5x5,7x7, etc ]
Q.8 Write a function in C++ which accepts a 2D array of integers and its size as arguments and displays the
elements of the middle row and the elements of middle column.
Example if the array content is
354
769
218
Output through the function should be:
Middle row: 769 Middle column: 5 6 1
-8-
Q. 9. Declare a stack using array that contains int type numbers and define pop and push function using C++
Syntax.
Q.10. Define functionstackpush( ) to insert nodes and stack pops ( ) to delete nodes . for a linked list
implemented stack having the following structure for each node
struct Node
{
Char name [ 20 ]
Int age ;
Node * link ;
};
Class stuck {
Node * top ;
Public
Stack ( ) { top = null ;} ;
Void stackpush ( );
Void stack pop ( ) ;
}
Q3. Write a c++ program ,which initializes a string variable to the content.”Time is a grat teacher but
unfortunately it kills all its pupils.Berlioz”and output the string one character at a time to the disk file
OUT.TXT .You have to include all the header files required.
-9-
clrscr()
char filename[13];
cout<<”Enter Filename:”;
cin.getline(filename,13);
ifstream in(filename);
if(!in)
{cout<<”Cannot open input file!\n”;
return (0)
}
Char str[255];
While(in)
{in.getline(str,255);
Cout<<str<<”\n”;
}
in.close();
return 0;
}
Q.3. What do you understand by the terms Cardinality and Degree of the table?
Q.5. Write a query on the customers table whose output will exclude all customers with a rating <=100,
unless they are located in Shimla.
Q.6. Write a query that selects all orders except those zeros or NULLs in the amount field.
Q.8. Write a command that puts the following values, in their given order, into the salesman table:
cust-name-Manisha, city-Manali, comm.- NULL, cust-num-1901.
- 10 -
Q.12. Write some features of SQL?
Table : Book
Book_id Book name Author_name Publisher Price Type Quantity
C0001 Fast Cook Lata Kapoor EPB 355 Cookery 5
William
F0001 The Tears Hopkins First Publi. 650 Fiction 20
Brain &
T0001 My First c++ Brooke FPB 350 Text 10
C++ Brain
T0002 works A.W. Rossaine TDH 350 Text 15
F0002 Thunderbolts Anna Roberts First Publ. 750 Fiction 50
Table : issued
Book_Id Quantity Issued
T0001 4
C0001 5
F0001 2
Q.18.
TABLE: GRADUATE
S.NO NAME STIPEND SUBJECT AVERAGE DIV.
1 KARAN 400 PHYSICS 68 I
2 DIWAKAR 450 COMP. Sc. 68 I
- 11 -
3 DIVYA 300 CHEMISTRY 62 I
4 REKHA 350 PHYSICS 63 I
5 ARJUN 500 MATHS 70 I
6 SABINA 400 CEHMISTRY 55 II
7 JOHN 250 PHYSICS 64 I
8 ROBERT 450 MATHS 68 I
9 RUBINA 500 COMP. Sc. 62 I
10 VIKAS 400 MATHS 57 II
(a) List the names of those students who have obtained DIV I sorted by NAME.
(b) Display a report, listing NAME, STIPEND, SUBJECT and amount of stipend received in a year
assuming that the STIPEND is paid every month.
(c.) To count the number of students who are either PHYSICS or COMPUTER SC graduates.
(d) To insert a new row in the GRADUATE table:
11,”KAJOL”, 300, “COMP. SC.”, 75, 1
(e) Give the output of following sql statement based on table GRADUATE:
(i) Select MIN(AVERAGE) from GRADUATE where SUBJECT=”PHYSICS”;
(ii) Select SUM(STIPEND) from GRADUATE WHERE div=2;
(iii) Select AVG(STIPEND) from GRADUATE where AVERAGE>=65;
(iv) Select COUNT(distinct SUBDJECT) from GRADUATE;
Assume that there is one more table GUIDE in the database as shown below:
Table: GUIDE
MAINAREA ADVISOR
PHYSICS VINOD
COMPUTER SC ALOK
CHEMISTRY RAJAN
MATHEMATICS MAHESH
- 12 -
Write the SQL commands for the following :
(i) To show firstname,lastname,address and city of all employees living in paris
(ii) To display the content of Employees table in descending order of Firstname.
(iii) To display the firstname,lastname and total salary of all managers from the tables Employee and
empsalary , where total salary is calculated as salary+benefits.
(iv) To display the maximum salary among managers and clerks from the table Empsalary.
(v) Give the Output of following SQL commands:
(i) Select firstname,salary from employees ,empsalary where designation = ‘Salesman’ and
Employees.empid=Empsalary.empid;
(ii) Select count(distinct designation) from empsalary;
(iii) Select designation, sum(salary) from empsalary group by designation having count(*) >2;
(iv) Select sum(benefits) from empsalary where designation =’Clerk’;
Boolean Algebra
- 13 -
Communication and Network Concepts
Q.8 What is the differences between POP3 and IMAP Mail Server?
- 14 -