CBSE Computer Science Question Paper Class 12th (2010)

  CBSE You are here

Series OSS                                                                                                                            Code No. 91

                                                                               COMPUTER SCIENCE

Time allowed : 3 hours                                                                                                    Max. Marks: 70

Instructions :
(i)  All questions are compulsory.
(ii) Programming Language : C++

1. (a) What is the difference between call by value and call by reference ? Also, give a suitable C++ code to illustrate both.                                 2

(b) Which  C++  header  file(s)  will  be  essentially  required  to  be included to run/execute the following C++ code :    1

      void  main ()
{
      int  Rno=24;   char  Name[]=:”Aman  Singhania” ;
      cout<<setw (10) <<Rno<<setw (20) <<Name<<endl ;
}

 

 

(c) Rewrite  the  following C++  program code  after removing the syntax error(s) (if any). Underline each correction.     2

include <iostream.h>
class FLIGHT
{
    long FlightCode;
    char Description [25] ;
public
    void Addlnfo()
   {
   cin>>FlightCode; gets(Description);
   }
   void Showlnfo()
   {
   cout<<FlightCode«“ : “<<Description<<endl;
   }
} ;
void  main ()
{
   FLIGHT   F;
   AddInfo.F() ; Showlnfo.F();
}

 

 

(d) Find the output of the following program;

#include <iostream.h>
struct  THREE_D
{ int  X, Y, Z; } ;
void  Moveln(THREE_D &T, int  Step=1)
{
   T.X+=Step;
   T. Y-=Step;
   T. Z+=Step;
}
void  MoveOut (THREE_D &T, int Step=1)
{
   T. X-=Step;
   T. Y+=Step;
   T. Z-=Step;
}
void  main ()
{
   THREE_D T1={10,20,5},T2={30,10,40};
   Moveln (T1) ;
   MoveOut(T2,5);
   cout<<T1.X<<“, “<<T1. Y<<“, “<<T1.Z<<end1;
   cout<<T2. X<< “ , “<<T2. Y<< “ , “<<T2.. Z<<end1;
   Moveln(T2,10);
   cout<<T2 . X<<“ , “<<T2 . Y<<“ , “<<T2 . Z<<end1;
}

 

 

(e) Find the output of the following program :    2

#include <iostream.h>
#include <ctype.h>
void  MyCode(char  Msg[],char  CH)
{
   for (int Cnt=O;Msg[Cnt] !=‘O’ ;Cnt++)
   {
   if (Msg[Cnt]>=‘B’ && Msg[Cnt] <=‘G’    )
     Msg[Cnt]=tolower(Msg[Cnt]);
   else
   if (Msg[Cnt]==‘A’ II Msg[Cnt]==‘a’
     Msg[Cnt]=CH;
   else
   if (Cnt%2==O)
     Msg[Cnt]=toupper(Msg[Cnt]);
   else
     Msg[Cnt]=Msg[Cnt-1];
   }
}
void  main()
{
   char  MyText[]=“ApEACeDriVE”;
   MyCode(MyText,’@’);
   cout<<“NEW  TEXT:” <<MyText<<endl;
}

 

 

(f) The following code is from a game,  which  generates  a  set  of 4 random numbers. Praful is playing this game, help him to identify the correct option(s) out of the four choices given below as the possible set of such numbers generated from the program code so that he wins the game. Justify your answer.

#include <iostream.h>
#include <stdlib.h>
const int LOW=25;
void  main ()
{
   randomize() ;
   int POINT=5,Number;
   for (int  I=1;I<=4;I++)
   {
     Number=LOW+random(POINT);
     cout<<Number<<“ : “ ;
     POINT—;.
   }
}

(i) 29:26:25:28:
(ii) 24:28:25:26:
(iii) 29:26:24:28:
(iv) 29:26:25:26:

 

 

2. (a) What  do  you understand. by Data Encapsulation and Data Hiding ? Also, give an example in C++ to illustrate both.

    (b) Answer the questions (i) and (ii) after going through the following class    :                  2

class  Exam
{
   int Rno,MaxMarks,MinMarks,Marks;
public:
   Exam()                       //Module    1
{
   Rno=101;MaxMarks=100;MinMarks=40;Marks=75;
}
   Exam(int Prno,int Pmarks)    //Module    2
{
   Rno=Prno;MaxMarks=100;MinMarks=40;Marks=Pmarks;

  ~Exam                         //Module    3
{
   cout<<“Exam  Over” <<endl;
}
void Show()                    //Module    4
{
   cout<<Rno«“ : “<<MaxMarks<<” : “«MinMarks<<endl;
   cout<<“ [Marks  Got] “<<Marks<<endl;
   }
} ;

 

(i)     As  per Object Oriented Programming, which concept is illustrated by Module 1 and Module 2 together ?
(ii)    What is Module 3 referred as ?  When  do you think, Module 3 will be invoked/called ?

 

 

(c) Define a class STOCK in C++ with following description :

 

     Private Members
• ICode of type integer (Item Code)
• Item of type string (Item Name)
• Price of type float (Price of each item)
• Qty of type. integer (Quantity in stock)
• Discount of type float (Discount percentage on the item)
• A member function FindDiscO to calculate discount as per the following rule :

If Qty<=50    Discount is 0
If 50<Qty<=100    Discount is.5
If Qty>100    Discount is 10

     Public Members
• A function Buy() to allow user to enter values for ICode, Item, Price, Qty and call function FindDiscO to calculate the Discount.
• A function ShowAll() to allow user to view the content of all the data members.

 

 

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

class  Director
{
   long DID;      //Director Identification Number
   char Name[20];
protected:
   char Description[40];
   void  Allocate();
public:
   Director();
   void  Assign();
   void  Show();
} ;
class  Factory:public Director
{
   int FID;       //Factory   ID
   char  Address[20];
protected:
   int  NOE;      //No. of Employees
public:
   Factory();
   void  Input();
   void  Output O ;
} ;
class  ShowRoom:private  Factory {
   int   SID;     //Showroom  ID
   char  City[20];
public:
   ShowRoom();
   void  Enter();
   void  Display();
} ;

 

 

(i)  Which type of inherits out of the, following is illustrated in the above C++ code ?
     (a)    Single Level I  efitance
     (b)    Multi Level In  itance
     (c)    Multiple Inheritance
(i)   Write the names of data members, which are accessible by objects of class type ShowRoom.
(iii) Write  the  names  of all  member  functions  which are accessible by objects of class type ShowRoom.
(iv) Write the names of all members, which are accessible from member functions of class Factory.

 

 

3. (a) Write a function REASSIGN() in C++, which accepts an array of integers and its size as parameters and divide all those array elements by 5 which are divisible by 5 and multiply other array elements by 2.                         3

Sample Input Data of the array

A[0] A[1] A[2] A[3] A[4]
20 12 15 60 32

Content of the array after calling REASSIGNO function

A[0] A[1] A[2] A[3] A[4]
4 24 3 12 64

 

(b) An array T[90][1001 is stored in, the memory along the column with each of the elements occupying 4 bytes.  Find out the memory location for the element T[10][40], if the Base Address of the array is 7200.

 

(c) Write a complete program in C++ to implement a dynamically allocated Queue containing names of Cities.

 

(d) Write the following table function  in C++ to find and return the sum of elements from all alternate elements of a two-dimensional array starting from B[0][0].                               2

Function:

int ALTERSUM (int_B [ ] [5] , int N, int M

Hint :
If the following is the content of the array

B[0][0] B[0][1] B[0][2]
4 5 1
B[1][0] B[1][1] B[1][2]
2 8 7
B[2][0] B[2][1] B[2][2]
9 6 3


The function should add elements B[0][0], B[0][2], B[1][1], B[2][0] and B[2][2].


(e)    Evaluate the following postfix notation of expression :    2
        (Show status of Stack after each operation)
        True, False, NOT, OR, False, True, OR, AND

 

 

4. (a) Observe the program segment given below carefully and fill the blanks marked as Statement 1 and Statement 2 using tellg() and seekp() functions for performing the required task.                        1

#include <fstream.h>
class  Customer
{
     long Cno;char Name[20],Mobile[12];
public:
     //Function to allow user to enter the Cno, Name, Mobile
void Enter();
     //Function to allow user to enter (modify) mobile number
void Modify();
     //Function to return value of Cno
long GetCno() {return Cno;)
) ;
void ChangeMobile()
{
     Customer C;
     fstream   F;
     F.open(“CONTACT.DAT”, ios::binarylios::inlios::out);
     long Cnoc;    //Customer no. whose mobile number needs to be chanced.’
     cin>>Cnoc;
     while (F.read((char*)&C,sizeof(C)))
     {
       if (Cnoc==C.GetCno())
       {
         C.Modify();
                              //Statement 1
       in.t Pos=        //To find the current position of file poin.ter,
                             //Statement  2
                            //To move the file pointer to write the 
                             //modified record back onto the file
                             //for the desired Cnoc
       F.write ( (char*) &C, sizeof (C)) ;
       }
     }
     F.Close () ;
}

 

 

 

(e1) Suggest a cable layout of connections between the buildings.
(e2) Suggest the most suitable place (i.e. building) to house the server for this NGO. Also, provide a suitable reason for your suggestion.
(e3) Suggest  the  placement  of  the  following  devices  with justification :
     (i)     Repeater
     (ii)    Hub/Switch
(e4) The NGO is planning to connect its International office situated  in  Delhi. Which out of the  following wired
communication links, will you suggest for a very high speed connectivity ?
    (i)    Telephone Analog Line
   (ii)    Optical Fiber
  (iii)    Ethernet Cable


(f)   Write the full forms of the following                      1
   (i)    FTP
  (ii)    FSF

(g)    Name any two common Web browsers.                      1