12th Standard CBSE Syllabus & Materials
12th Standard CBSE
CBSE 12th Economics Government Budget and the Economy Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Interface Python with MySQL - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Database Concept - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Data Communication - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Data Structures - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Functions - New Previous year Question Papers Study Material - QB365 Set A

Published on: 15/09/2018
Term Test
Download CBSE Class 12th Standard CBSE Computer Science question papers, sample papers, important questions, and previous year solved papers in PDF format. Get free study materials, NCERT solutions, and exam preparation resources for Class 12th Standard CBSE Computer Science
Questions + Answers key
Take MCQ Computer Science Test

1.
Find the output of the following program:
#include<iostream.h>
#include<conio.h>
struct score
{
int Year;
float Topper;
};
void Change(score *s,int x=20)
{
s->Topper+(s->Topper+25)-x;
s->Year++;
}
void main()
{
clrscr();
score Arr[]={{2007,100},{2008,95}};
score*point=Arr;
Change(point,50);
cout<<Arr[0],Year<<'#'<<Arr[0].Topper<<endl;
Change(++point);
cout<<point->Year<<'#'<<point->Topper<<endl;
getch();
}
2.
Rewrite the corrected code for the following program. Underline each correction.
#include<iostream.h>
structure Supergym
{
int membernumber;
char membername[20];
char membertype[]="hig";
};
void main()
{
Supergym person1,person2;
cin<<"Member Number:";
cin>>pereson1.membernumber;
cout<<"Member Name:";
cin>>person1.membername;
person1.membertype="MIG";
person2=person1;
cin<<"Member Number:"<<person2.membernumber;
cin<<"Member Name:"<<person2.membername;
cin<<"Member Type:"<<person2.membertype;
}
3.
Find the output of the following program:
#include<iostream.h>
struct Dress
{
int size,cost,Tax,Total_cost;
};
void change(Dress &S,int Flag=1)
{
if(Flag==1)
S.cost+=20;
S.Total_Cost=S.cost+S.cost*S.Tax/100;
}
void main()
{
Dress S1={40,580,8},S2={34,550,10};
change(S1);
cout<<S1.size<<' , '<<S1.cost<<','<<S2.Total_Cost<<endl;
change(S2,2);
cout<<S2.size<<','<<S2.cost<<','<<S2.Total_Cost<<endl;
}
4.
Study the following program and select the possible output from it.
#include<iostream.h>
#include<stdlib.h>
const int LIMIT = 4;
void main()
{
randomize();
int Points;
Points=100+random(LIMIT);
for(int P=Points; P>=100; P--)
cout<<P<<"#";
cout<<endl;
}
i) 103#102#101#100# ii) 100#101#102#103#
iii) 100#101#102#103#104# iv) 104#103#102#101#100#
5.
Read the following C++ code carefully and find out, which out of the given option(i) to (iv) are the expected correct outputs of it.Also write the maximum and minimum value that can be assigned to the variable Taker used in the code.
void main()
{
int GuessMe[4]={100,50,200,20};
int Taker=random(2)+2;
for (int Chance=0; Chance<Taker: Chance++)
cout<<GuessMe[Chance]<<"#";
}
i) 100# ii) 50#200# iii) 100#50#200# iv) 100#50#
6.
Obtain the output of the following c++ program, which will appear on the screen after its execution.
important Note
All the desired header files are already included in the code, which are required to run the code.
class Player
{
int Score, Level;
char Game;
public:
Player(char GGame='A')
{
Score=0;
Level=1;
Game-=GGame;
}
void Start(int SC);
void Next();
void Disp()
{
cout<<Game<<"@";
cout<<Level<<end1;
cout<<Score<<end1;
}
};
void main()
{
Player P, Q('B');
P.Disp();
Q.Disp();
Q.start(75);
Q.Next();
P.start(120);
Q.Disp();
P.Disp();
}
void Player::Next()
{
Game=(Game=='A')?'B':'A':
}
void Player::Start(int SC)
{
Score += SC;
if(Score>=100)
Level=3;
else if(Score>=50)
Level=2;
else
Level=1;
}
7.
Observe the following C++ code carefully and obtain the output, which will appear on the screen after execution of it.
#include
class Aroundus
{
int Place,Humidity,Temp;
public:
Arounds(int p = 2)
{
Place = P;
Humanity = 60;
Temp = 20;
}
void Hot(int T)
{
Temp += T;
}
void Humid(int H)
{
Humidity += H;
}
void JustSee()
{
cout<
};
void main()
{
Aroundus A, B(5);
A.Hot(10);
A.JustSee();
B.Humid(15);
B.Hot(2);
B.JustSee();
A.Humid(5);
A,justSee();
}
8.
Answer the questions (i) and (ii) after going through the following program:
#include<iostream.h>
#include<string.h>
class Bazar
{
char Type [ 20 ] ;
char Product [ 20 ] ;
int Qty ;
float Price ;
Bazar ( ) / / Function 1
{
strcpy ( Type , "electronic" ) ;
strcpy ( Product , "calculator" ) ;
Qty = 10 ;
Price = 225 ;
}
public:
void disp ( )
{
count<<Type<<"-"<<Product<<":" ;
count<<Qty<<"@<<Price<<endl ;
}
void main ( )
{
Bazar B; / /Statement 1
B.disp ( ) ; / /Statement 1
}
(i) Will Statement 1 initialise all the data members for object B with the values given in the function 1? (Yes or No). Justify your answer suggesting the corrections to be made in the above code.
(ii) What shall be the possible output when the program gets executed? (assuming, if required the suggested corrections are made in the program).
9.
Find the output of the following program:
#include<iostream.h>
void main()
{
long NUM=1234543;
int F=0; S=0;
do
{
int Rem = NUM;
if(Rem%2 I=0)
F +=Rem;
else
S +=Rem
NUM /=10;
} while(NUM>0);
cout<<F-S;
}
10.
What is the significance of (::) scope resolution operator?
11.
Write the output of the following program.
Void main()
{
int x=5, y=5;
cout<<x--;
cout<<",";
cout<<--x;
cout<<",";
cout<<y--<<","<<--y;
}
12.
Find the output of the following program.
#include<iostream>
void main()
{
int x=5, y;
y=x++ + ++x;
cout<<++y<<" "<<y++;
}
13.
Consider the Following C++ code:
class Data
{
int num;
public:
data(int n)
{
num =n;
}
void show()
{
cout<<"Data Number: "<<num<<end1;
}
};
class Database : public Data
{
char name[12];
int d;
public:
---------------------- //fill in the blanks/
void d show()
{
cout<<"Database Name: "<<name;
cout<<"\ndatabase value: "<<d;
}
};
void main()
{
Database d("SQL",10);
d.show();
d.dshow();
getch();
}
(I) Name the type of inheritance illustrated in the above c++ code.
(ii) Fill in the blanks to define a constructor for the derived class assigning values of the data passedfrom main() and to assign a data 15 to base class construtor data number
(iii) Write the output of the above c++ code
14.
identify the syntax error(),if any
class ABC
{
int x = 100;
float y;
ABC()
{
y = 5;
}
~()
{ }
void main()
{
ABC a1,a2;
}
15.
Answer the questions (i) to (iii) based on the following code:
class Stationary
{
char Type;
char Manufacturer[10];
public:
stationary();
void Read_sta_details();
void Disp_sta_details();
};
class office : public stationary
{
int no_of_types;
float cost_of_sta;
public:
void Read_off_details();
void Disp_off_details();
};
class printer : private office
{
int no_of_user;
char delivery_details[10];
public:
void Read_pri_details();
void Disp_pri_details();
};
void main()
{
printer MyPrinter;
}
(i)Mention the member names, which are accessible by MyPrinter declared in main() function.
(ii) What is the size of MyPrinter in bytes?
(iii) Mention the names of functions accessible from the member function Read_pri_details() of class printer.
16.
Answer the questions (i) to (iv) based on the following code:
class Dolls
{
char DCode[5];
protected:
float Price;
void CalPrice(float);
public:
Dolls();
void DInput();
void DShow();
};
class SoftDolls : public Dolls
{
char SDName[20];
float Weight;
public:
SoftDolls();
void SDInput();
void SDShow();
};
class ElectronicDolls : publicDolls
{
char EDname[20];
char BatteryType[10];
int Batteries;
public:
ElectronicDolls();
void EDInput();
void EDShow();
};
(i) Which type of Inheritance is depicted by the above example?
(ii) How many bytes will be required by an object of the class ElectronicDolls?
(iii) Write name of all the data members accessible from member function of class of SoftDolls.
(iv) Write name of all the member functions accessible by an object of the class ElectronicDolls.
17.
Suppose we have following C++ program:
#include<iostream.h>
#include<conio.h>
class A
{
public:
A(){cout<<"A";}
\(\sim \)A(){cout<<"\(\sim \)Aโโโโโโโ";}
};
class B
{
public:
B(){cout<<"B";}
\(\sim \)Bโโโโโโโ(){cout<<"\(\sim \)"B"โโโโโโโ;}
};
class C
{
public:
C(){cout<<"C";}
\(\sim \)Cโโโโโโโ(){cout<<"\(\sim \)"C"โโโโโโโ;}
private:
B a; A b;
};
class D
{
public:
D(){cout<<"D";}
\(\sim \)Dโโโโโโโ(){cout<<"\(\sim \)"D"โโโโโโโ;}
};
class E : public C
{
public:
E(){cout<<"E";}
\(\sim \)Eโโโโโโโ(){cout<<"\(\sim \)"E"โโโโโโโ;}
private:
D d; B b;
};
void main()
{
E e;
cout<<end l;
getch();
}
Assume that the program compiles and runs correctly, what does it print out?
18.
Write a program using three functions to calculate the volume of a cube, a cylinder, and a rectangular box.The function names should be the same.
19.
To show the working of function returning object.
20.
Observe the following C++ code and write the name(s) of the header file(s),which will be essentially required to run it in a C++ compiler.
void main()
{
int Number;
cin>>Number;
if(abs(Number)==Number);
cout<<"Positive"<<endl;
}
21.
Observe the following C++ code and write the name(s) of the header file(s), which will be essentially required to run it in a C++ compiler.
void main()
{
char Text[20],C;
cin>>Text;
C=tolower(Text[0]);
cout<<c<<"is the first char of"<<Text<<endl;
}
22.
How many times is the loop executed?
int i=0, j=0;
do
{
i=j;
}
while(j<5);
23.
What is the effect of absence of break in switch-case statement?
24.
Name the features by which classes acquier the properties of other classes.
25.
Which function is called during each function call in the program given below?
int sum(int); //Function[I]
float sum(float); //Function[II]
double sum(double); //Function[III}
void main()
{
int x=20;
int a=sum(x); //call1
float b=sum(x); //call2
double c=sum(x); //call3
getch();
}
26.
Is this possible to declare two functions with same name and same argument but different return type in C++?
27.
When do you think function overloading be used?
28.
Give the output of the following program:
int a=44;
cout<<a++<<"\t"<<a<<"\n"<<++a;
cout<<endl<<a<<endl;
1.
Output
2008#75
2009#100
2.
#include<iostream.h>
#include<string.h>
struct Supergym
{
int membernumber ;
char membername[20];
char membertype[4];
};
void main()
{
Supergym person1,person2;
cout<<"Member Number:";
cin>>pereson1.membernumber;
cout<<"Member Name:";
cin>>person1.membername;
strcpy(person1.membertype,"MIG");
person2=person1;
cout<<"Member Number:"<<person2.membernumber;
cout<<"Member Name:"<<person2.membername;
cout<<"Member Type:"<<person2.membertype;
}
3.
Output
40,600,0
34,550,605
4.
i) 103#102#101#100#
5.
Correct output for the given code would be option iii) and iv).
Minimum value of variable Taker=2
Maximum value of variable Taker=3
6.
A@1
0
A@2
75
A@3
120
7.
2:30&60%
5:22&75%
2:30&65%
8.
(i) No. Since, the default constructor Bazar ( ) is declared inside private section, it cannot initialise Correction needed is:
The constructor Bazar ( ) should be declared inside public section.
(ii) Output
Electronic-calculator : 10@225
9.
2
10.
Member functions can be defined within the class definition or separately using scope resolution operator(::), Scope resolution operator specifies that the scope of the function is restricted to the class_name.
#include<iostream.h>
class Box
{
double length;
double breadth;
double height;
public:
double getVolume(void);
};
double Box :: getVolume(void)
{
return length*breadth*height;
}
11.
The output is 5, 3, 4, 4
12.
The output is
14 12
13.
(i) Single inheritance.
(ii) database(char na[12], int value);
{
strcpy(name,na);
d=value;
}
(iii) output
Data number:15
Database Name:SQL
Database Value:10
14.
class ABC
{
int x = 100; //Data member cannot
float y; //be initialised within a class ABC
ABC()
{
y = 5;
}
~() //Name of destructor mising
{ }
void main()
{ //Missing semicolon(;) at the class end
ABC a1,a2;
}
15.
(i) Data members: None
member functions: Read_pri_details(), Disp_pri_details().
(ii) 29 Bytes
(iii) Member functions: Read_sta_details(), Disp_sta_details(), Read_off_details(),
Disp_off_details(), Disp_pri_details().
16.
(i) Hierarchical Inheritance.
(ii) 41 Bytes
(iii) Price, SDName, Weight
(iv) DInput(), DShow(), EDInput(), EDShow().
17.
BACDBE
\(\sim E\sim B\sim D\sim C\sim A\sim B\)
18.
#include<iostream.h>
#include<conio.h>
int volume(int a);
double volume(float r, int h);
int volume(int 1, int b, int h);
void main()
{
int a, l, b, h;
float r:
clrscr();
cout<<"Enter the side of cube ";
cin>>a;
cout<<"Enter the radius and height of cylinder ";
cin>>r>>h;
cout<<"\nEnter the side of rectangular cube\n";
cin>>l>>b>>h;
cout<<"Volume of cube="<<volume(a);
cout<<"\nVolume of cylinder="<<volume(r,h);
cout<<"\nVolume of rectangular cube="<<volume(l,b,h);
getch();
}
int volume(int a)
{
return(a*a*a);
}
double volume(float r, int h)
{
return(3.1461*r*r*h);
}
int volume (int l, int b, int h)
{
return(l*b*h);
}
Output
Enter the side of cube 2
Enter the radius and height of cylinder 2 3
Enter the side of rectangular cube
3 4 5
Volume of cube=8
Volume of cylinder=62.922
Volume of rectangular cube=60
19.
Output
Enter the first time in hh mm ss format
12 30 55
Enter the second time in hh mm ss format
8 10 45
First time is
HOURS 12
MINUTES 30
SECONDS 55
Second time is
HOURS 8
MINUTES 10
SECONDS 45
Resultant time is
HOURS 20
MINUTES 41
SECONDS 40
20.
( )
iostream.h ----> cin,cout
math.h -------> abs()
21.
( )
iostream.h ---> cout,cin
ctype.h -----> tolower()
22.
( )
Infinite loop because the value of i and j is always equal to zero.
23.
( )
In switch -case statement, when a match is found, the statement sequence associated with that case is executed until a break statement or the end of switch statement is reached. So, if break statement is missing, then the statement sequence is executed until the end of the switch-case statement is reached.
24.
( )
Inheritance is the feature by which classes acquire the properties of other classes.
25.
( )
Call 1,2 and 3 will invoke only function [I] because controls with match only function [I] at each
time.It is being called.And each time return value will ba an integer that can be assigned to a
higher data type easily.
26.
( )
No,it is not possible to declare two functions with same name and same argument but different
return type in C++,because the control will be confused at the time of calling which of these function will be executed first.
27.
( )
Function overloading is used when a function is required to perform for alternatives argument
types and there is a define way of optimising the function for the argument type.In such kind of
case,function overloading should be used.
28.
( )
The output is as
45 45
45
46
12th Standard CBSE Syllabus & Materials
12th Standard CBSE
CBSE 12th Computer Science Python Revision Tour I - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Planning Important Questions And Answers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Business Environment Important Questions And Answers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Principles of Management Important Questions And Answers Study Material - QB365 Set A
CBSE 12th Standard CBSE Subjects
CBSE Standards