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++) 2017 - 2018 CBSE (Science) Class 12

SubjectComputer Science (C++)
Year2017 - 2018 (March)

Marks: 70
[12]1
[2]1.1

Write the type of C++ token (keywords) and the User-defined identifier from the following.

1) else

2) Long

3) 4Queue

4) _count

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

The following C++ code during compilation reports errors as follows:

Error: 'ofstream' not declared

Error: 'strupr' not declared

Error: 'strcat' not declared

Error: 'FIN' not declared

Write the names of the correct header files, which must be included  to compile the code successfully

void main()
{
   of stream FIN ("WISH. TXT") ;
   char TEXT2[]="good day";
   char TEXTl []="John! ";
   
   strupr(TEXT2);
   strcat(TEXTl , TEXT2);
   FIN<<TEXTl<
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 error with each correction underline

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

Typedef Count(int);
void main()
(
    Count C;
    cout<<"Enter the count:";
    cin>>C;
    for (K = 1 ; K<=C;K++)
        cout<< C "*" K <<end1;
}
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 all required header files are already included in the program

void Revert(int &Num, int Last=2)
{
   Last =(Last%2==0)?Last+l: Last - l;
   for(int C=l; C <= Last; C++)
      Num+=C;
)

void main()
{
    int A=20, B=4;
    Revert(A, B) ;
    cout<<A<<"&"<<B<<end1;
    B--;
    Revert{A,B);
    cout<<A<<"#"<<B<<endl;
    Revert{B);
    cout<<A<<"#"<<B<<endl;
}
Chapter: [6] Object Oriented Programming in C++
Concept: Member of a Class - Data Members and Member Functions (Methods)
[3]1.5

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

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

#define Modify(N) N*3+10
void main()
(
    int LIST(]:{l0,15,12,17);
    int *P-LIST, C;
    for(C=3; C>=O; C--)
        LIST[c]=Modify(LIST[c) ;
    for (C=O; C<=3; C++)
    {
        cout<<*P<<":";
        P++;
    }
}
Chapter: [7] Data Structures
Concept: Introduction to Data Structure - Array, Stack Queues Primitive and Non-primitive Data Structure
[2]1.6

Look at the following C++ code and find the possible output from the options (i) to (iv) following it. Also, write the highest and lowest values that can be assigned to the array A.

Note:

  • Assume all the required header files are already being included in the code
  • The function random(n) generates an integer between 0 and -1
void main()
{
   randomize();
   int A(4], C;
   for(C=0; C<4; C++)
      A(C] = random(C+l) + 10;
   for (C=3; C >= 0; c--)
       cout<<A(C]<<"@";
}

1) 13@10@11@10@

2) 15$14$12$10$

3) 12@11@13@10@

4) 12@11@10@10@

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
[12]2
[2]2.1

Which function(s) out of the following can be considered as an overloaded function(s) in the same program? Also, write the reason for not considering the other(s) as an overloaded function(s)

void Execute(char A,int B);    // Function 1

void Execute(int A,char B);    // Function 2

void Execute(int P=10) ;       // Function 3

void Execute();                    // Function 4

int Execute(int A);               // Function 5

void Execute(int &K);          // Function 6

Chapter: [6] Object Oriented Programming in C++
Concept: Overloaded Constructors
[2]2.2

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

Note: Assume all necessary files are included.

class FIRST
{
   int Numl;
public:
    void Display()
    {
        cout<<Numl<<endl;            //Member Function 1
    }
};

class SECOND: public FIRST
{
    int Num2;
public:
     void Display()                //Member Function 2
     {
         cout<<Num2<<endl;
     }
};

Void main()
{
   SECOND S;
   ___________                    // Statement 1
   ___________                    // Statement 2
  
}

 

1) Which Objected Programming features is illustrated by the definition of classes FIRST and SECOND?

2) Write Statement 1 and Statement 2 to execute Member Function 1 and Member Function 2 respectively using the object S

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 CONTAINER in C++ with the following description.

Private Members

-Radius, Height      // float

- Type                  // int (1 for Cone, 2 for Cylinder)

- Volume              // float

- CalVolume()       // Member function to calculate

                          // volume as per the Type

Type Formula to calculate Volume
1 3.14*Radius*Height
2 3.14*Radius*Height/3

Public Members

- GetValues ()    //A function to allow a user to enter of Radius, Height and Type. Also, call function CalVolume() from it.

- ShowAll ()      // A function to display Radius, Height, Type and Volume of Container

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

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

class Teacher
{
   int TCode;
protected:
      char Name[20];
public:
      Teacher();
      void Enter() ; void Show();
};

class Course
(
   int ID;
protected:
      Char Title[30];
public:
      Course();
      void Initiate();
      void Display();
};

class Schedule : public Course, private Teacher
{
    int DD, MM, YYYY;
public:
    Schedule();
    void Start();
    void View();
};

void main()
{
   Schedule S;
}

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

2) Write the name of all the member which are directly accessible by the member function View() of Class Schedule.

3) Write the names of all the members, which are directly accessible by the object S of Class Schedule declared in the main() function.

4) What will be the order of execution of the constructors, when the object S of the Class Schedule Schedule is declared inside the main() function?

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

Write the definition of a function SumEO(int VALUES[], int N) in C++, which should display the 4 sum of even value and sum of odd values of the array separately.

Example: If the array VALUES contains

25 20 22 21 53

Then the functions should display the output as:

Sum of even values = 42 (i.e., 20+22)

Sum of odd values= 99 (i.e., 25+21+53)

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

Write a definition for a function UpperHalf(int Mat[4][4]) in C++ which displays the elements in the same way as per the example is shown below.

For example, if the content of the array Mat is as follows:

25 24 23 22
20 19 18 17
15 14 13 12
10 9 8 7

Thew function should display the content in the following format:

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

Let us assume Data[20][15] is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 2 bytes. Find the address of the element Data(10][5], if the element Data[10][l5] is stored at the memory location 15000.

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

Wnte the definition of a member function AddPac ket() for a class QUEUE in C++, to remove/delete a Packet from a dynamically allocated QUEUE of Packets' considering the following code is already written as a part of the program.

struct Packet
{
   int PID;
   char Address[20];
   Packet *LINK;
};

class QUEUE
{
    Packet *Front, *Rear;
public:
    QUEUE(){Front=NULL;Rear=NULL;}
    void AddPacket();
    void DeletePacket();
    ~QUEUE();
};
Chapter: [7] Data Structures
Concept: Queue (Array and Linked Implementation)
[2]3.5

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

U * V + (W - Z)/X

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

A text file named MATTER.TXT contains some text which needs to be displayed such that every next character is separated by a symbol '#'.

Write a function definition for HashDisplay() in C++ that would display the entire content of the file MATTER.TXT in the desired format:

Example:

if the file Matter.TXT has the following content stored in it:

THE WORLD IS ROUND

The function HashDisplay() should display the following content:

T#H#E #W#O#R#L#D# #I#S# #R#O#U#N#D#

Chapter: [6] Object Oriented Programming in C++
Concept: Implementation of Basic File Operations on Text and Binary File in C++
[2]4.2

Write a definition for a function TotalTeachers( ) in C++ to read each object of a binary file SCHOOLS.DAT, find the total number teachers, whose data is stored in the file and display the same. Assume that the file SCHOOLS.DAT is created with the help objects of class SCHOOLS, which is defined below :

class SCHOOLS
{
    int SCode;        //School Code
    char SName[20];   //School Name
    int NOT;          // Name of Teachers in the school

public:
    void Display()
    {
       cout<<SCode<<"#"<<SName<<"#" << NOT << endl;
       int RNOT() {return NOT;}
};
Chapter: [6] Object Oriented Programming in C++
Concept: Implementation of Basic File Operations on Text and Binary File in C++
[1]4.3

Find the output of the following C++ code considering that the binary file SCHOOL.DAT exists on the hard disk with the following records of 10 schools of the class SCHOOLS as declared in the previous question(4 b)

SCode SName NOT
1001 Brains School 100
1003 Child Life School 115
1002 Care Share School 300
1006 Educa t for Life School 50
1005 Guru Shiahya Sadan 195
1004 Holy Education School 140
1010 Play School 95
1008 Innovate Excel School 300
1011 Premier Education School 200
1012 Uplifted Minds School 100
void main()
{
     fstream SFIN;
     SFIN.open("SCHOOLS.DAT", ios::binary|ios::in) ;
     SCHOOLS S;
     SFIN.seekg(S*sizeof(S));
     SFIN.read((char*)&S, sizeof(S));
     S.Display();
     cout<<"Record : "<<SFIN.tellg()/sizeof(S) + l <<endl;
     SFIN.close();
}
Chapter: [6] Object Oriented Programming in C++
Concept: Implementation of Basic File Operations on Text and Binary File in C++
[8]5
[2]5.1

Observe the following tables VIDEO and 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 below. Also, find the
Degree and Cardinality of the final result.

TABLE: VlDEO

VNO VNAME TYPE
F101 The Last Battle Fiction
C101 Angels and Devils Comedy
A102 Daredevils Adventure

TABLE: MEMBER

MNO MNAME
M101 Namish Gupta
M102 Sana Sheikh
M103 Lara James

TABLE: FINAL RESULT

VNO VNAME TYPE MNO MNAME
F101 The Last Battle Fiction M101 Namish Gupta
F101 The Last Battle Fiction M102 Sana Sheikh
F101 The Last Battle Fiction M103 Lara James
C101 Angels and Devils Comedy M101 Namish Gupta
C101 Angels and Devils  Comedy M102 Sana Sheikh
C101 Angels and Devils  Comedy M103 Lara James
A102 Daredevils Adventure M101 Namish Gupta
A102 Daredevils Adventure M102 Sana Sheikh
A102 Daredevils Adventure M103 Lara James

 

Chapter: [3] Python - Databases and SQL
Concept: Relational Data Model
[6]5.2

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

TABLE: Account

ANO ANAME ADDRESS
101 Nirja Singh Bangalore
102 Rohan Gupta Chennai
103 Ali Reza Hyderabad
104 Rishabh Jain Chennai
105 Simran Kaur Chandigarh

TABLE: TRANSACT

TRNO ANO AMOUNT TYPE DOT
T001  101 2500 Withdraw 2017-12-21
T002 103 3000 Deposit 2017-06-01
T003  102 2000 Withdraw 2017-0S-12
T004  103 1000 Deposit 2017-10-22
T005  101 12000 Deposit 2017-11-06

1) To display details of all transaction of TYPE Depos1t from Table TRANSACT.

2) To display the ANO and AMOUNT of all Depos1ts and Withdrawals done in the month of October 2017 from table TRANSACT.

3) To display the last date of the transaction (DOT) from the table TRANSACT for the Accounts having ANO as 103

4) To display all ANO, ANAME and DOT of those persons from tables ACCOUNT and TRANSACT who have done transactions less than or equal to 3000?

5) SELECT ANO, ANAME FROM ACCOUNT WHERE ADDRESS NOT IN ('CHENNAI', 'BANGALORE');

6) SELECT DISTINCT ANO FROM TRANSACT

7) SELECT ANO, COUNT(*), MIN(AMOUNT) FROM TRANSACT GROUP BY AND HAVING COUNT(*) > 1;

8) SELECT COUNT(*), SUM(AMOUNT) FROM TRANSACT WHERE DOT <= '2017-06-01'

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

State any one Absorption Law of Boolean Algebra and verily it using truth table.

Chapter: [4] Python - Boolean Algebra
Concept: Truth Tables (Boolean Algebra)
[2]6.2

Draw the Logic Circuit of the following Boolean Expression

(U' + v).(V' + W')

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 FN, represented by the following truth truth table:

X y z FN (X, Y, Z)
0 0 0 1
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0  1
1 0 1 0
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:

`G(U, V,W, Z) = sum(3,5 , 6 , 7 , 11 , 12 ,13, 15)`

Chapter: [1] Boolean Algebra
Concept: Reducing Boolean Expression (SOP and POS) to Its Minimal Form
[10]7
[2]7.1

Differentiate bel ween Bus Topology and Star Topology of Networks

Chapter: [5] Python - Communication Technologies
Concept: Network Topologies and Types - Bus, Star, Tree, PAN, LAN, WAN, MAN

What are the advantages and disadvantages of Star Topology over Bus Topology

Chapter: [5] Python - Communication Technologies
Concept: Network Topologies and Types - Bus, Star, Tree, PAN, LAN, WAN, MAN
[2]7.2

Classify the following Web Scripting as Client-Side Scripting and Server Side Scripting

Java Scripting

Chapter: [10] Networking and Open Source Software
Concept: Web Scripting - Client Side (VB Script, Java Script, PHP)

Classify the following Web Scripting as Client-Side Scripting and Server Side Scripting

ASP

Chapter: [10] Networking and Open Source Software
Concept: Web Scripting - Client Side (VB Script, Java Script, PHP)

Classify the following Web Scripting as Client-Side Scripting and Server Side Scripting

VB Scripting

Chapter: [10] Networking and Open Source Software
Concept: Web Scripting - Client Side (VB Script, Java Script, PHP)

Classify the following Web Scripting as Client-Side Scripting and Server Side Scripting

JSP

Chapter: [10] Networking and Open Source Software
Concept: Web Scripting - Client Side (VB Script, Java Script, PHP)
[2]7.3

Write the expanded names for the given abbreviated terms used in Networking and Communications

SMTP

Chapter: [10] Networking and Open Source Software
Concept: Internet Wireless/Mobile Communication Protocol - GSM, CDMA, GPRS, and WLL

Write the expanded names for the given abbreviated terms used in Networking and Communications

VoIP

Chapter: [10] Networking and Open Source Software
Concept: Internet Wireless/Mobile Communication Protocol - GSM, CDMA, GPRS, and WLL

Write the expanded names for the given abbreviated terms used in Networking and Communications

GSM

Chapter: [10] Networking and Open Source Software
Concept: Internet Wireless/Mobile Communication Protocol - GSM, CDMA, GPRS, and WLL

Write the expanded names for the given abbreviated terms used in Networking and Communications

WLL

Chapter: [10] Networking and Open Source Software
Concept: Internet Wireless/Mobile Communication Protocol - GSM, CDMA, GPRS, and WLL
[4]7.4

CASE STUDY BASED QUESTION

Ayurveda Training Educational Institute is setting up its centre in Hyderabad with four specialised departments for Orthopedics, Neurology and Pediatrics along with an administrative office in separate buildings. The physical distance between these department buildings and the number of computers to be installed in these departments and administrative office are given as follows.

Shortest distance between various locations in meters:

Administrative Office to Orthopedics Unit 55
Neurology Unit to Administrative Office 30
Orthopedics Units to Neurology Unit 70
Pediatrics Unit to Neurology Unit 50
Pediatrics Unit to Administrative Office 40
Pediatrics Unit to Orthopedics Unit 110

Number of Computers installed at various locations are as follows

Pediatrics Unit 40
Administrative Office 140
Neurology 50
Orthopedics Unit 80

1) Suggest the most suitable location to install the main server of this institution to get efficient connectivity.

2) Suggest the best cable layout for effective network connectivity of the building having server with all the other buildings.

3) Suggest the devices to be installed in each of these building for connecting computers installed within the building out of the following

  • Gateway
  • Modem
  • Switch

4) Suggest the topology of the network and network cable for efficiently connecting each computer installed in each of the building out of the following:

Topologies: Bus Topology, Star Topology

Network Cable: Single Pair Telephone Cable, Coaxial Cable, Ethernet Cable

Chapter: [5] Python - Communication Technologies
Concept: Network Topologies and Types - Bus, Star, Tree, PAN, LAN, WAN, MAN
S