Académique Documents
Professionnel Documents
Culture Documents
CLASS-12
COMPUTER SCIENCE
3) Write any two differences between Constructor and Destructor. Write the
function headers for constructor and destructor of a class Member.
5) (b) Observe the following C++ code and answer the questions
(i) and (ii):
class Traveller
{
long PNR;
char TName[20];
public:
Traveller() //Function1
{cout<<"Ready"<<endl;}
void Book(long P,char N[]) //Function2
{PNR= P; strcpy(TName, N);}
void Print() //Function3
{cout<<PNR << TName<<endl;}
~Traveller() //Function 4
{cout<<"Booking cancelled!"<<endl;}
};
(i) Fill in the blank statements in Line1 and Line2 to execute Function2 and
Function 3 respectively in the following code:
void main{)
{
Traveller T;
_____________ //Line 1
_____________ //Line 2
}//Stops here
(ii) Which function will be executed at}//Stops here? What is this function
referred as?
6) Define a class named ADMISSION in C++ with the following
descriptions:
Private members:
AD_NO integer (Ranges 10 - 2000)
NAME Array of characters (String)
CLASS Character
FEES Float
PublicMembers:
Function Read_Data ( ) to read an object of ADMISSION type
Function Display( ) to display the details of an object
Function Draw-Nos ( ) to choose 2 students randomly. And display the
details. Use random function to generate admission nos. to match with
AD_NO.
7) Answer the questions (I) and (ii) after going through the following class:
Class Exam
{ int year;
Public:
Exam(int y) {year=y;} //Constructor 1
Exam(Exam & t); //Constructor 2
};
i. Create an object, such that it invokes Constructor
ii. Write complete definition for Constructor
Write the following programs in the practical file
S.NO PROGRAMS
1. WAP to find length of the string and compare the two strings.
2. WAP to search a record and compare it with previous record.
3. WAP to print two-digit numbers in 2D array.
4. WAP to print the report card of a student by inputting marks of three different
subjects.
5. WAP to print the record of two different students.
6. WAP to input the element in an array and sort or search the element in it.
7. WAP to add and display record in a file.
8. WAP to declare a class employee and display employee, number, name and salary.
9. WAP to enter and display text in file.
10. WAP to input a text and count number of vowels, words or digit in it.