Visitors Online: 0 | Tuesday 10th December 2019
REGISTRATION
Online Fashion Store

Important Questions

CBSE Guess > Papers > Important Questions > Class XII > 2009 > Computer Science > Computer Science By Mr. Pradumna Singh

CBSE CLASS XII

Q. 1. a. What is the difference between #define & const ? Explain through example.

b. Name the header files that shall be required for successful compilation of the following C++ program :

main( )
    {          char str[20];
                  cout<<fabs(-34.776);
                  cout<<”\n Enter a string : ”;
                   cin.getline(str,20);
                 return 0; }

c. Rewrite the following program after removing all the syntactical errors underlining each correction. (if any) 

             #include<iostream.h>
           #include<stdio.h>
              struct NUM
       {             int x;
             float y;
}*p;
      void main( )
{
                 NUM A=(23,45.67);
             p=A;
           cout<<”\n Integer = “<<*p->x;
           cout<<”\n Real = “<<*A.y;
}

d. Find the output of the following program segment ( Assuming that all required header files are  included in the program ) :

                void FUNC(int *a,int n)
{                   int i,j,temp,sm,pos;
                      for(i=0;i<n/2;i++)
                     for(j=0;j<(n/2)-1;j++)
                    if(*(a+j)>*(a+j+1))
{                   temp=*(a+j);
                 *(a+j)=*(a+j+1);
                *(a+j+1)=temp; }
               for(i=n-1;i>=n/2;i--)
{                               sm=*(a+i);
         pos=i;
                for(j=i-1;j>=n/2;j--)
             if(*(a+j)<sm)
{     pos=j;
                        sm=*(a+j); }
                     temp=*(a+i);
                 *(a+i)=*(a+pos);
                    *(a+pos)=temp;  } }
      void main( )
{
            int w[ ]={-4,6,1,-8,19,5},i;
                  FUNC(w,6);
                             for(i=0;i<6;i++)
                  cout<<w[i]<<' ';}

e. Give the output of the following program ( Assuming that all required header files are  included in the program ) :

               class state
{
        private:
               char *stname;
    int size;
       public:
           state( )
{          size=0;
               stname=new char[size+1];}
                   state(char *s)
 {          size=strlen(s);
                        stname=new char[size+1];
              strcpy(stname,s); }
       void disp( )
{                  cout<<stname<<endl; }
                 void repl(state &a, state &b)
{               size=a.size+b.size;
                     delete stname;
                    stname=new char[size+1];
            strcpy(stname,a.stname);
         strcat(stname,b.stname);  }  };
      void main( )
{         char *st1="Punjab";
   clrscr( );
           state ob1(st1),ob2("Uttaranchal"),ob3("Madhyapradesh"),s1,s2;
             s1.repl(ob1,ob2);
             s2.repl(s1,ob3);
           s1.disp( );
          s2.disp( ); getch( ); }

f. Observe the following program carefully & choose  the correct possible output from the options (i) to (iv) justifying your answer.

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main( )
{
       clrscr( );
          randomize( );
           int RN;
         RN=random(4)+5;
           for(int i=1;i<=RN;i++)
             cout<<i<<' ';
        getch();             }

  1. 0 1 2
  2. 1 2 3 4 5 6 7 8 
  3. 4 5 6 7 8 9
  4. 5 6 7 8 9 10 11 12

Q. 2. a.  Differenciate between default & parameterized constructor with suitable example.

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

                        #include<iostream.h>
                        #include<string.h>
                        #include<stdio.h>
class wholesale
                        { char categ[20],item[30];
                          float pr;
                           int qty;
                                                wholesale( )                              // Function 1
                                                { strcpy(categ ,”Food”);
                                                   strcpy(item,”Biscuits”);
                                                   pr=150.00;
qty=10 }
                                    public :
                                                void SHOW( )                           //Function 2
                                                {
                                                cout<<categ<<”#”<<item<<”:”<<pr<<”@”<<qty<<endl;
                                                }
                                                };                    
                        void main( )
                        { wholesale ob;                                                 //Statement 1
                         ob.SHOW( );                                                   //Statement 2
                        }

i) Will statement 1 initialize all the data members for object ob with the values given in function 1?(Y/N). 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 correction(s) are made in the program.


c. Defne a class WEAR in C++ with following description :


            Private members :


            code                                         string
            Type                                         string
            Size                                          integer
            material                                    string
            Price                                        real number

A function calprice( ) that calculates and assign the value of price as follows :

For the value of material as “WOOLEN”
                                    Type                 Price(Rs.)
                                    -------               -------------
                                    Coat                 2400
                                    Sweater                        1600
            For material other than “WOOLEN” the above mentioned price gets reduced by 30%.

Public members :

A constructor to get initial values for code, Type & material as “EMPTY” & size and price with 0.
A function INWEAR( ) to input the values for all the data members except price which will be initialized by function calprice( ).

Function DISPWEAR( ) that shows all the contents of  data members
                       
d. Answer the questions (i) to (iv) based on the following :

class COMP
{ private :
           char Manufacturer [30];
char addr[15];

      public:
      toys( );
      void RCOMP( );
      void DCOMP( );
};
class TOY: public COMP
{    private:
      char bcode[10];
           public:
      double cost_of_toy;
      void RTOY ( );
      void DTOY( );
};
      class BUYER: public TOY
      { private:
      char nm[30];
      char delivery date[10];
char *baddr;
      public:
      void RBUYER( );
      void DBUYER( );
};
void main ( )
{       BUYER MyToy;      }

  1. Mention the member names that are accessible by MyToy declared in main( ) function.                       
  2. Name the data members which can be accessed by the functions of BUYER class.               
  3. Name the members that can be accessed by  function RTOY( ). 
  4. How many bytes will be occupied by the objects of class BUYER?

Q. 3. a. Define a function that would accept a one dimensional integer array and its size. The function should reverse the contents of the array without using another array. (main( ) function is not required)

b. A two dimensional array A[15][25] having integers (long int), is stored in the memory along the column, find out the memory location for the element A[8][12], if an element A[10][6] is stored at the memory location 2800. 

c. Evaluate the following postfix notation of expression : 
                        5, 8,  7, +, /,  7, * , 13,  -

d. Write a user defined function in C++ which accepts a squared integer matrix with odd dimensions (3*3, 5*5 …) & display the sum of the middle row & middle column elements. For ex. :

                                    2          5          7  
                                    3          7            2
                                    5          6            9

The output should be :
                        Sum of middle row = 12
                        Sum of middle column = 18

e. Consider the following program for linked QUEUE : 
                        struct NODE
                        { int x;
                          float y;
                          NODE *next; };

class QUEUE
{ NODE *R,*F;;
 public :
            QUEUE( )
            { R=NULL;
   F=NULL;
}
void INSERT( );
void DELETE( );
void Show( );
~QUEUE( ); };
         Define INSERT( ) & DELETE( ) functions outside the class.

Q. 4. a. Observe the following program carefully and fill in the blanks using seekg( ) and tellg( ) functions :

            #include<fstream.h>
            class school
            { private :
                        char scode[10],sname[30];
                        float nofstu;
                        public:
                                    void INPUT( );
                                    void OUTPUT( );
                                    int COUNTREC( ); };
                        int school::COUNTREC( )
{ fstream fin(“scool.dat”,ios::in|ios::binary);
_________________ //statement 1
int B=_______________ //statement 2
int C=B/sizeof(school);
fin.close( );
return C; }

b. Write a function in c++ to count the number of words starting with capital alphabet present in a text file   DATA.TXT.

c. Write a function in c++ to add new objects at the bottom of binary file “FAN.DAT”, assuming  the binary file is containing the objects of following class :

      class FAN
                               { private:
int srno;
                            char name[25];
float pr;
                       public:
                   void Enter( ){ cin>>srno; gets(name); cin>>pr; }
                  void Display( ){ cout<<srno<<name<<pr<<endl;} };

Q. 5. a) What do you mean by degree & cardinality of a relation? Explain with example.

b. Consider the tables FLIGHTS & FARES. Write SQL commands for the statements (i) to (iv) and give the outputs for SQL queries (v) & (vi) .

Table : FLIGHTS

FNO

SOURCE

DEST

NO_OF_FL

NO_OF_STOP

IC301

MUMBAI

BANGALORE

3

2

IC799

BANGALORE

KOLKATA

8

3

MC101

DELHI

VARANASI

6

0

IC302

MUMBAI

KOCHI

1

4

AM812

LUCKNOW

DELHI

4

0

MU499

DELHI

CHENNAI

3

3

        

Table : FARES

FNO

AIRLINES

FARE

TAX

IC301

Indian Airlines

9425

5%

IC799

Spice Jet

8846

10%

MC101

Deccan Airlines

4210

7%

IC302

Jet Airways

13894

5%

AM812

Indian Airlines

4500

6%

MU499

Sahara

12000

4%

  1.  Display flight number & number of flights from Mumbai from the table flights.
  2. Arrange the contents of the table flights in the descending order of destination.
  3. Increase the tax by 2% for the flights starting from Delhi.
  4. Display the flight number and fare to be paid for the flights from Mumbai to Kochi using the tables, Flights & Fares, where the fare to be paid =fare+fare*tax/100.
  5. SELECT COUNT(DISTINCT SOURCE) FROM FLIGHTS;
  6. SELECT FNO, NO_OF_FL, AIRLINES FROM FLIGHTS,FARES WHERE SOURCE=’DELHI’ AND FLIGHTS.FNO=FARES.FNO;

Q. 6. a. State and verify De Morgan’s law.

 b. If F(A,B,C,D) = å (0,1,2,4,5,7,8,10) , obtain the simplified form using K-Map.

c. Convert the following Boolean expression into its equivalent Canonical Sum of Products form (SOP) :
            (X+Y+Z) (X+Y+Z’) (X’+Y+Z) (X’+Y’+Z’)

d. Write the equivalent Boolean Expression F for the following circuit diagram :

Q. 7.  

  1. What is a switch? How is it different from hub?
  2. What is the difference between optical fibre & coaxial transmission media.
  3. Define cookies & firewall.
  4. Expand WLL & XML
  5. “Kanganalay Cosmetics” is planning to start their offices in four major cities in Uttar Pradesh to provide cosmetic product support in its retail fields. The company has planned to set up their offices in Lucknow at three different locations and have named them as “Head office”,  “Sales office”, & “Prod office”. The company’s regional offices are located at  Varanasi, Kanpur & Saharanpur. A rough layout of the same is as follows : 

                                                                                                                                                                                                  


Approximate  distances between these offices as per network survey team is as follows :

Place from

Place to

Distance

Head office

Sales office

15 KM

Head office

Prod office

8 KM

Head office

Varanasi Office

295 KM

Head office

Kanpur Office

195 KM

Head office

Saharanpur office

408 KM

Number of computers :

Head office

156

Sales office

25

Prod office

56

Varanasi Office

85

Kanpur Office

107

Saharanpur office

105

  • Suggest the placement of the repeater with justification. 
  • Name the branch where the server should be installed. Justify your answer.
  • Suggest the device to be procured by the company for connecting all the computers within each of its offices out of the following devices :
  • Modem
  • Telephone
  • Switch/Hub

The company is planning to link its head office situated in Lucknow with the office at Saharanpur. Suggest an economic way to connect it; the company is ready to compromise on the speed of connectivity. Justify your answer.  

Paper By Mr. Pradumna Singh