CBSE (Science) Class 12CBSE
Account
It's free!

User



Login
Register


      Forgot password?
Share
Notifications

View all notifications
Books Shortlist
Your shortlist is empty

Question Paper Solutions - Computer Science (C++) 2016 - 2017 CBSE (Science) Class 12

SubjectComputer Science (C++)
Year2016 - 2017 (March)

Marks: 70
[12]1
[2]1.1

Write the type of C++ tokens (keywords and user-defined identifiers) from the following:

1) new

2) While

3) case

4) Num_2

Chapter: [6] Object Oriented Programming in C++
Concept: Concept of Object Oriented Programming in C++
[1]1.2

Anil typed the following C++ code and during compilation, he found three errors as follows :

1) Function strlen should have a prototype

2) Undefined symbol cout

3) Undefined symbol endl

On asking, his teacher told him to include necessary header files in the code. Write the names of the header files, which Anil needs to include, for successful compilation and execution of the following code:

void main()
{
    char Txt[] = "Welcome";
    for(int C= 0; C<strlen(Txt); C++)
       Txt[C] = Txt[C]+ 1;
    cout<<Txt<<endl;
}
Chapter: [6] Object Oriented Programming in C++
Concept: Header File - fstream.h
[2]1.3

Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.

Note: Assume all required header files are already being included in the program.

void main()
{
     cout<<"Enter an Alphabet:" ;
     cin>>CB ;
     switch(CH)
     case 'A' · cout<<"Ant"; Break ;
     case 'B' · cout<<"Bear"; Break;
}
Chapter: [6] Object Oriented Programming in C++
Concept: Concept of Object Oriented Programming in C++
[2]1.4

Find and write the output of the. following C++ program code

Note : Assume au· required header files are already included in the program.

#define Diff(N1,N2) ((N1>N2)?Nl-N2:N2-N1)
void main()
{
    int A,B,NUM[] = {10,23,14,54,32};
    for(int CNT =4; CNT > 0; CNT--)
    {
        A=NUM[CNT];
        B=NUM[CNT-1];
        cout<<Diff(A,B)<< '#';
    }
}
Chapter: [6] Object Oriented Programming in C++
Concept: Advantages of Object Oriented Programming Over Earlier Programming Methodologies in C++
[3]1.5

Find and write the output of the following C++ program code :
Note : Assume all required header files are already being included in the program.

void main()
{
     int *Point, Score[]={100,95,150 , 75 , 65, 120};
     Point = Score;
     for(int L = 0; L<6; L++)
     {
         if((*Poi nt)%10==0)
            *Point /= 2;
         else
            *Point -= 2;
         if((*Point) %5==0)
            *Point /= 5;
         Point++;
      }
      for(int L = 5; L>=O; L--)
          cout<<Score[L]<<"*";
}
Chapter: [6] Object Oriented Programming in C++
Concept: Pointers and Arrays - Array of Pointers, Pointer to an Array (1 Dimensional Array), Function Returning a Pointer, Reference Variables and Use of Alias
[2]1.6

Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the maximum values that can be assigned to each of the variables N and M

Note:

  • Assume all the .required header files are already being included in the code.
  • The function random(n) generates an integer between 0 and n-1
void main()
{
    randomize() ;
    int N=random(3), M=random(4);
    int DOCK[3][3] = {{1,2,3},{2,3,4}, {3,4,5}};
    for(int R=O; R<N; R++)
   {
       for(int C = 0; C< M; C++)
·        cout<<DOCK[R][C]<<" ";
       cout<<endl;
    }
}
1)
2)
3)
4)
Chapter: [6] Object Oriented Programming in C++
Concept: Member of a Class - Data Members and Member Functions (Methods)
[12]2
[2]2.1

Differentiate between protected .and private me~bers of a class. in context of Object Oriented Programming. Also, give a suitable example illustrating accessibility/non-accessibility of each using a class and an object in C++.

Chapter: [6] Object Oriented Programming in C++
Concept: Using Private and Public Visibility Modes, Default Visibility Mode (Private)
[2]2.2

Observe the following C++ code and answer the questions (i) and (ii).

Note: Assume all necessary files are included

class TEST
{
    long TCode ;
    char TTitle[20];
    float Score;
public:
    TEST()      //Member Function 1
    {
         TCode=100;strcpy(TTit1e,"FIRST Test"); Score=O;
    };
    TEST(TEST &T)    //Member Function 2
    {
         TCode=E.TCode+1;
         strcpy(TTitle , T.TTitle);
         Score=T.Score;
     }
};

void main()
{
   __________    //Statement 1
   __________    //Statement 2
}

1) Which Object-Oriented Programming feature is illustrated by the Member Function 1 and the Member Function 2 together in the class TEST?

2) Write Statement 1 and Statement 2 to execute Member Function 1 and Member Function 2 respectively.

Chapter: [6] Object Oriented Programming in C++
Concept: Member of a Class - Data Members and Member Functions (Methods)
[4]2.3

Write the definition of a class BOX 1n C++ with the following description

Private Members

- BoxNumber //data member of integer type

- Side           // data member of float type

- Area          // data member of float type

- ExecArea ()  // Member function to calculate and assign Area as Side * Side

Public Members

- GetBox()   // function to allow user to enter values of BoxNumber and Side. Also, this

                  // function should call ExecArea () to calculate Area

- Showbox ()  //  A function to display BoxNumber , Side and Area

Chapter: [6] Object Oriented Programming in C++
Concept: Using Private and Public Visibility Modes, Default Visibility Mode (Private)
[4]2.4

Answer the questions (i) to (iv) based on the following:

class First
{
    int X1;
protected:
    float X2;
public:
    First();
    void Enter1(); void Display1;
};

class Second: private First
{
    int Y1;
protected:
    float Y2;
public:
    Second();
    void Enter2();
    void Display();
};

class Third : public Second
{
    int Z1;
public:
    Third{);
    void Enter3();
    void Display{);
};

void main()
{
    Third T;  //Statement 1·
    __________;  // Statement 2
}

1) Which type of Inheritance out of the following is illustrated in the above example?

Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance

2) Write the names of all the member functions, which are directly accessible by the object T of class Third as declared in main() function.

3) Write Statement 2 to call function Display() of class Second from the object T of class Third

4) What will be the order of execution of the constructors, when the object T of class Third is declared inside main()?

Chapter: [6] Object Oriented Programming in C++
Concept: Inheritance in C++
[14]3
[3]3.1

Write the definition of a function AddUp(int Arr[], int N) in C++, in which all even positions (i.e., 0,2,4, ... ) of the array should be added with the content of the element in the next position and odd positions (i.e., 1,3,5, ... ) elements should be incremented by 10

Example: if the array Arr contains

23 30 45 10 15 25

Then the array should become

53 40 55 20 40 35

Note:

  • The function should only alter the content in the same array.
  • The function should not copy the altered content in another array.
  • The function should not display the altered content of the array.
  • Assuming, the Number of elements in the array are Even.
Chapter: [6] Object Oriented Programming in C++
Concept: Pointers and Arrays - Array of Pointers, Pointer to an Array (1 Dimensional Array), Function Returning a Pointer, Reference Variables and Use of Alias
[2]3.2

Write a definition for a function SUMMIDCOL(int MATRIX [10], int N, int M) in C++, which finds the sum of the middle column's elements of the MATRIX (Assuming N represents a number of rows and M represents the number of columns, which is an odd integer). 
Example: If the content of array MATRIX having N as 5 and M as 3 is as follows

1 2 1
2 1 4
3 4 5
4 5 3
5 3 2

The function should calculate the sum and display the following :

Sum of Middle Column: 15

Chapter: [6] Object Oriented Programming in C++
Concept: Pointers and Arrays - Array of Pointers, Pointer to an Array (1 Dimensional Array), Function Returning a Pointer, Reference Variables and Use of Alias
[3]3.3

ARR[15] ft:20] is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 4 .bytes. Find the .address of the element ARR[5)[15], if the element ARR[lO] [5] is stored at the memory location 35000.

Chapter: [7] Data Structures
Concept: One and Two Dimensional Arrays - Sequential Allocation and Address Calculation
[4]3.4

Write the definition of a member function PUSHGIFT() for a class STACK in C++, to add a GIFT in a dynamically allocated stack of GIFTs considering the following code is already written as a part of the program

struct GIFT
{
    int GCODE;           //Gift Code
    char GDESC[20];      //Gift Description
    GIFT *Link;
};
class STACK
{
    Gift *TOP;
public:
    STACK(){TOP=NULL;}
    void PUSHGIFT{);
    void POPGIFT();
    ~STACK();
};
Chapter: [6] Object Oriented Programming in C++
Concept: Member of a Class - Data Members and Member Functions (Methods)
[2]3.5

Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion:

X-( Y+Z )/U * V

Chapter: [7] Data Structures
Concept: Operations on Stack (PUSH and POP) and Its Implementation in C++
[6]4
[3]4.1

Polina Raj has used a text editing software to type some text in an article. After saving the article as MYNOTES.TXT, she realised that she has wrongly typed alphabet K in place of alphabet C everywhere in the article.

Write a function definition for PURETEXT() in C++ that would display the corrected version of the entire article of the file MYNOTES.TXT with all the alphabets "K" to be displayed as an alphabet "C" on screen.

Note: Assuming that MYNOTES.TXT does not contain any c alphabet otherwise

Example:

If Polina has stored the following content in the file MYNOTES.TXT

I OWN A KUTE LITTLE KAR

I KARE FOR IT AS MY KHILD

The function PURETEXT() should display the following content

I OWN A CUTE LITTLE CAR

I CARE FOR IT AS MY CHILD.

Chapter: [6] Object Oriented Programming in C++
Concept: Function Call by Reference
[2]4.2

Write a definition for function COUNTPICS() in C++ to read each object of a binary file PHOTOS.DAT, find and display the total number of PHOTOS of type PORTRAIT. Assume that the file PHOTOS.DAT is created with the help of objects of class PHOTOS, which is defined below :

class PHOTOS
{
   int PCODE ;
   char PTYPE[20]; //Photo Type as "PORTRAIT" ,"NATURE"
public:
   void ENTER()
   {
       cin>>PCODE;gets(PTYPE);
   }
   void SHOWCASE()
   {
       cout<<PCODE<<":" <<PTYPE<<endl;
   }
   char *GETPTYPE(){return PTYPE;}
};
Chapter: [6] Object Oriented Programming in C++
Concept: Binary File in C++ :- Creation of File, Writing Data into File, Searching for Required Data from File, Appending Data to a File, Insertion of Data in Sorted File, Deletion of Data from File, Modification of Data in a File
[1]4.3

Find the output of the following C++ code considering that the binary file CLIENTS.DAT exists on the hard disk with a data of 200 clients:

class CLIENTS
{
    int CCode; char CName[20];
public:
    void REGISTER(); void DISPLAY();
};

void main()
{
    £stream File;
    File.open("CLIENTS.DAT", ios::binary|ios::in);
    CLIENTS C;
    File.seekg(6*sizeof(C));
    File.read((char*)&C, sizeof(C));
    cout<<"Client Number: "<<File.tellg()/sizeof(C) + 1;
    File.seekg(0 , ios :: end) ;
    cout<<"of"<<File.tellg(}/sizeof(C)<<endl;
    File.close();
}
Chapter: [6] Object Oriented Programming in C++
Concept: Binary File in C++ :- Creation of File, Writing Data into File, Searching for Required Data from File, Appending Data to a File, Insertion of Data in Sorted File, Deletion of Data from File, Modification of Data in a File
[8]5
[2]5.1

Observe the following table MEMBER carefully and write the name of the RDBMS operation out of (i) SELECTION (ii) PROJECTION (iii) UNION (iv) CARTESIAN PRODUCT, which has been used to produce the output as shown in RESULT. Also, find the Degree and Cardinality of the RESULT :

MEMBER

NO MNAME STREAM
M001 JAYA SCIENCE
M002 ADITYA HUMANITIES
M003 HANSRAJ SCIENCE
M004 SHIVAK COMMERCE

RESULT

NO MNAME STREAM
M002 ADI'l'YA HUMANITIES
Chapter: [3] Python - Databases and SQL
Concept: Structured Query Language Advantages of Using SQL
[4]5.2

Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables.

DVD

DCODE DTITLE DTYPE
F101 Henry Martin Folk
C102 Dhrupad Classical
C101 The Planets Classical
F102 Universal Soldier Folk
R102 A day in life Rock

MEMBER

MID NAME DCODE ISSUEDATE
101 AGAM SINGH R102 2017-11-30
103 ARTH JOSEPH F102 2016-12-13
102 NISHA HANS C101 2017-07- 24

1) To display all details from the table MEMBER in descending order of ISSUEDATE

2) To display the DCODE and DTITLE of all Folk Type DVDs from the table DVD.

3) To display the DTYPE and number of DVDs in each DTYPE from the table DVD.

4) To display all NAME and ISSUEDATE of those members from the table. MEMBER who have DVDs issued (i.e., ISSUEDATE) in the year 2017

5) SELECT MIN(ISSUEDATE) FROM MEMBER

6) SELECT DISTINCT DTYPE FROM DVD;

7) SELECT D.DCODE, NAME, DTITLE FROM DVD D, MEMBER M WHERE D.DCODE=M.DCODE;

8) SELECT DTITLE FROM DVD WHERE DTYPE NOT IN ("Folk", "Classical" ) ;

Chapter: [3] Python - Databases and SQL
Concept: Structured Query Language Advantages of Using SQL
[8]6
[2]6.1

State DeMorgan's Laws of Boolean Algebra and verify them using a truth table.

Chapter: [4] Python - Boolean Algebra
Concept: DeMorgan’S Law/Theorem and Their Applications
[2]6.2

Draw the Logic Circuit of the following Boolean Expression using only NOR Gates

(A+B).(C+D)

Chapter: [9] C++ Boolean Algebra
Concept: Application of Boolean Logic - Digital Electronic Circuit Design Using Basic Logic Gates (NOT, AND, OR, NAND, NOR)
[1]6.3

Derive a Canonical POS expression for a Boolean function G, represented by the following truth table:

X Y Z G(X, Y, Z)
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 1

 

Chapter: [4] Python - Boolean Algebra
Concept: Obtaining Sum of Product (SOP) and Product of Sum (POS) Form the Truth Table
[3]6.4

Reduce the following Boolean Expression to its simplest form using K-Map:

`E (U, V, Z, W) = sum (2, 3 , 6, 8, 9, 10, 11 , 12 , 13 )`

Chapter: [1] Boolean Algebra
Concept: Use of Karnaugh Map for Minimization of Boolean Expressions (Up to 4 Variables)
[10]7
[2]7.1

Differentiate between communication using Optical Fiber and Ethernet Cable in context of the wired medium of communication technologies.

Chapter: [5] Python - Communication Technologies
Concept: Optical Fiber
[2]7.2

Janish Khanna used a pen drive to copy files from his friend's laptop to his office computer. Soon his computer started abnormal functioning. Sometimes it would restart by itself and sometimes it would stop different applications running on it. Which of the following options out ·of (i) to (iv), would have caused the malfunctioning of the computer? Justify the reason for your chosen option:

1) Computer Virus

2)Spain Mail

3) Computer Bacteria

4) Trojan Horse

Chapter: [10] Networking and Open Source Software
Concept: Threats and Prevention from Viruses, Worms, Trojan Horse, Spam
[2]7.3

Ms Raveena Sen is an IT expert and a freelancer. She recently used her skills to access the Admin password for the network server of Super Dooper Technology Ltd. and provided confidential data of the organization to its CEO, informing him about the vulnerability of their network security. Out of the following options (i) to (iv), which one most appropriately defines Ms Sen?

Justify the reason for your chosen option :
1) Hacker

2) Cracker

3) Operator

4) Network Admin

Chapter: [5] Python - Communication Technologies
Concept: Cyber Crimes
[4]7.4

Hi-Standard Tech Traj.ning Ltd. is a Mumbai based organization which is expanding its office set-up to Chennai. At Chennai office compound, they are planning to have 3 different blocks for Admin, Training and Accounts related activities. Each block has a number of computers, which are required to be connected in a network for communication, data and resource sharing.

As a network consultant, you have to suggest the best network related solutions for them for issues/problems raised by them in (i) to (iv), as per the distances between various blocks/locations and other given parameters.

Shortest differences between various blocks/locations:

Admin Block to Accounts Block 300 Metres
Accounts Block to Training Block 150 Metres
Admin Block to Training Block 200 Metres
MUMBAI Head Office to CHENNAI Office 1300 Km

The number of computers installed at various blocks is as follows:

Training Block 150
Accounts Block 30
Admin Block 40

1) Suggest the most appropriate block/location to house the SERVER in the CHENNAI office (out of the 3 blocks) to get the best and effective connectivity. Justify your answer.

2) Suggest the best-wired medium and draw the cable layout (Block to Block) to efficiently connect various blocks within the CHENNAI office compound.

3) Suggest a device/software and its placement that would provide data security for the entire network of the CHENNAI office.

4) Suggest a device and the protocol that shall be needed to provide wireless Internet access to all smartphone/laptop users in the CHENNAI office

Chapter: [5] Python - Communication Technologies
Concept: Network Devices - Modem, RJ45 Connector, Ethernet Card, Router, Switch, Gateway, Wifi Card
S