Class XII Computer Science Practice Questions
Class XII Computer Science Practice Questions
Class XII Computer Science Practice Questions
1. What is recursive function? Specify the conditions when you can not create recursive
function? 2
2. Name the Header file(s) that shall be needed for successful compilation of the following
C++ code?
void main()
{
char st[20];
cin.getline(st,15);
if(islower(st[0])
cout<<”Starts with alphabet”;
else
cout<<strlen(st);
} 2
3. Rewrite the following program after removing syntactical error(s) if any. Underline
each correction.
#include<iostream.h>
#define SIZE =10
VOID Main()
{
int a[SIZE]={1,2,3,4,5};
float x=2;
SIZE=5;
for(int i=0; i<SIZE ; i++)
cout<<a[i]%x;
} 2
4 In the following program, find the correct possible output(s) from the options:
#include<stdlib.h>
#include<iostream.h>
void main()
{
randomize();
char Area[][10]={“NORTH”,”SOUTH”,”EAST”,”WEST”};
int ToGo;
for(int I=0;I<3;I++)
{
ToGo=random(3)+1;
cout<<Area[ToGo]<<”:”;
}
}
pdfMachine
A pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, if you can print from a windows application you can use pdfMachine.
Get yours now!
a) SOUTH:EAST:SOUTH:
b) NORTH:SOUTH:NORTH:
c) SOUTH:EAST:WEST:
d) WEST:EAST:EAST: 2
5. class data
{
int num ;
public:
data ( int n )
{ num = n ;
}
void show ( )
{ cout << n <<endl;
}};
class database : public data
{
char name[12];
data d ;
public :
________________________
};
Fill in the blanks to define a constructor for the derived class assigning values of
the data passed from main ( ) and to assign a data 15 of base class constructor data n.2
6. Define a class named Publisher in C++ with the following descriptions :
Private members
Id long
title 40 char
author 40 char
price , stockqty double
stockvalue double
valcal() A function to find price*stockqty with double as return type
Public members
a constructor function to initialize price , stockqty and stockvalue as 0
Enter() function to input the idnumber , title and author
Takestock() function to increment stockqty by N(where N is passed as argument to this
function) and call the function valcal() to update the stockvalue().
sale() function to decrease the stockqty by N (where N is sale quantity passed to this
function as argument) and also call the function valcal() to update the stockvalue
outdata() function to display all the data members on the screen. 4
pdfMachine
A pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, if you can print from a windows application you can use pdfMachine.
Get yours now!
void main()
{ int a[ ] = { 2,4,6,8,10 };
change(a,5);
for(int i =0; i<5; i++) cout<<a[i]<<” “; }
void change(int *b, int n)
{ int i ;
for( i =0; i<n; i++)
*(b+i) = *(b+i)+5; } 2
8. Give the output of the following program segment.
#include<iostream.h>
void POINTER(int *N, int j)
{ for(int i=1; i<j; i++)
*(N+i-1)=*(N+i)+1; }
void main( )
{ int a[ ]={ 12 , 19 , 20}, b[ ]={24, 13, 11}, c[ ]={ 5, 8,9};
POINTER (a,3);
POINTER (b,3);
POINTER(c,3);
for(int i=0;i<3;i++)
cout<<a[i]<<"@";
cout<<endl;
for(i=0;i<3;i++)
cout<<b[i]<<"*";
cout<<endl;
for(i=0;i<3;i++)
cout<<c[i]<<'#’;
cout<<endl; } 3
11. Consider the following declarations and answer the questions given
below: 4
class Mydata
{ protected:
pdfMachine
A pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, if you can print from a windows application you can use pdfMachine.
Get yours now!
int data;
public:
void Get_mydata(int);
void Manip_mydata(int);
void Show_mydata(int);
Mydata( );
~Mydata( );
};
class Personal_data
{
protected:
int data1;
public:
void Get_personaldata(int);
void Show_personaldata(int);
Personal_data1( );
~Personal_data1( );
};
class Person: public Mydata, Personal_data
{
public:
void Show_person(void);
Person( );
~Person( );
};
i) How many bytes will be required by an object belonging to class Person?
ii) Which type of inheritance is depicted in the above example?
iii) List the data members that can be accessed by the member function Show_person( ).
iv) What is the order of constructor execution at the time of creating an object of class
Person?
13. There are four railway tracks at a place. It is desired to design a logic circuit, which
can give a signal when three or more trains pass together at any given time.
14. Given the following truth table, write the sum-of-product form of the
function F(x, y, z). 1
X Y Z F
0 0 0 0
0 0 1 1
0 1 0 1
pdfMachine
A pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, if you can print from a windows application you can use pdfMachine.
Get yours now!
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
15.Compare packet switching and message switching. 1
16. Expand the following terminologies: i) WAIS ii) NFS 1
17. What is web Portal ? Name any one. 1
18.What do you understand by network security? 1
20.A company in Qatar has 4 wings of buildings as shown in the diagram: (4)
W1
W2
W4
W3
23.What do you mean by constraint? What is the similarity and dissimilarity between
primary key and unique constraint? 2
24. Study the following tables TOUR and ACCOMODATION and write SQL commands
for the questions (i) to (iv) and give outputs for SQL queries (v) to (viii). 6
Table : TOUR
SNO NAME STD JAIPUR BARMER POCKET
STUNO
1 B01 Aamir XII LB MB 2000
2 B02 Salman XII MB UB 2500
3 B03 Akshay XI LB LB 2000
4 B04 Ranveer XI UB UB 1500
5 G01 Shilpa XII LB LB 2500
6 G02 Preeti XII MB UB 1500
7 G03 Rani XI UB MB 3500
Table : ACCOMODATION
STUNO ROOMNO
FLOOR FOOD
B01 201 II Veg
B02 201 II N Veg
B03 202 II N Veg
B04 202 II Veg
G01 402 IV Veg
G02 402 IV N Veg
G03 403 IV Veg
Note : In Stuno B stands for Boys and G stands for Girls
JAIPUR refers Train to JAIPUR and BARMER refers Train to BARMER
LB – Lower Berth, MB – Middle Berth, UB – Upper Berth
i. Display the details of student who got lower berth in both Jaipur and Barmer
train.
ii. Display the name of students whose food choice is Veg.
iii. Update the food type as N Veg for girls students.
pdfMachine
A pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, if you can print from a windows application you can use pdfMachine.
Get yours now!
iv. Display the sum of pocket money of the students standard wise.
v. select tour.stuno, name, roomno from tour, accomodation where
accomodation.stuno = tour.stuno;
vi. select count(pocket), sum (pocket) from tour, accomodation where tour.stuno
= accomodation.stuno AND food ='Veg';
vii. select distinct roomno from accommodation;
viii. select max(pocket), min(pocket) from tour group by std;
pdfMachine
A pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, if you can print from a windows application you can use pdfMachine.
Get yours now!