(Paper) Class - XII Computer Science 2008

Disclaimer: This website is NOT associated with CBSE, for official website of CBSE visit - www.cbse.gov.in

Class - XII Computer Science 2008

Sample Paper - 2008
Class – XII
Subject - Computer Science

 

Time allowed : 3 Hours
Maximum Marks : 70

 

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

1.  (a) Define any two features of OOPs. Also give suitable example in C++.        (2)

2.  (b) Name the Header file(s) that shall be needed for successful compilation of the following C++ code

void main()

{

            int a[10];

            for(int i=0;i<10;i++)

            {

cin>>a[i];

            if(a[i]%2==0)

                        a[i]=pow(a[i],3);

            else

                        a[i]=sqrt(a[i]);

            if(a[i]>32767)

                        exit(0);

            }

            getch();

}                                         (1)

 

 

(c) Rewrite the following program after removing syntactical error(s) if any.

      Underline each correction.   (2)

            #include<iostream.h>

            type def int integer;

            struct number

            {

                        integer a [5];

            }

            void main()

            {

                        number x;

                        for(int i=0;i<5;i++)

                                    cin>>x[i].a;

                        getch();

            }

 

 

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

            #include<iostream.h>

            #include<string.h>

            void main()

            {

                        char *a[2]={”Amit”,”Sumit”};

                        for(int i=0;i<2;i++)

                        {

                                    int l=strlen(a[i]);

                                    for(int j=0;j<l;j++,a[i]++)

                                                cout<<*a[i]<<” :  “;

                                    cout<<endl;

                        }

}

 

 

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

                        #include<iostream.h>

                        class student

                        {

                                    public:

                                    student()

                                    {

                                                cout<<”\n Computer Science“;

                                    }

                                    ~student()

                                    {

                                                cout<<”  subject”;

                                    }

                        }st;

                        void main()

                        {

                                    cout<<” is my best“

                        }

 

 

(f) In the following C++ program , what will the maximum and minimum value of r generated with the help of random function.         (2)

             #include<iostream.h>

            #include<stdlib.h>

            void main()

            {

                        int r;

                       

                        randomize();

                        r=random(20)+random(2);

                        cout<<r;

            }

 

(g) Define macro  with a suitable example.                                                         (2)

2.
(a) Differentiate between a Constructor and Destructor in context of class and object . Give suitable example in C++.  
(2)

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

class Computer

            {

                        char C_name[20];

                        char Config[100];

                        public:

                                    Computer(Computer &obj); // function1

                                    Computer();                 //function 2

                                    Computer(char *n,char *C); // function3

                        };

(i)                  Complete the definition of the function 1.

(ii)                Name the specific feature of the OOPs shown in the above example.

(c) Define a class Student in C++ with the description given below :      (4)

            private members

                        rno                   integer

                        name                array of 40 characters

                        address            array of 40 characters

                        marks               array of 5 integers

                        percentage        float variable

calper()            a function which will calculate & return the percentage of a student.

            public members

init()                 function to ask and store the values of rno, name, address and marks in 5 subjects.

display()           function to which will invoke calper () and display the details of the item in the following format :

 

MARK SHEET           

Roll No :          <Roll no of student>

Name   :           <Student Name >

Address :          <ADDRESS >

Marks :            <subject1 marks><subject 2 marks ><….subject 5 marks>

Percentage :      <percentage of the student>

            Also create main() function which will invoke all the public member functions.



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

class Employee

{

            int id;

            protected :

            char name[20];

            char doj[20];

            public :

            Employee();

            ~Employee();

            void get();

            void show();

};

class Daily_wager : protected Employee

{

            int wphour;

           

protected :

            int nofhworked;

            public :

            void getd();

            void showd();

};

class Payment : private Daily_wager

{

 

            char date[10];

            protected :

            int amount;

            public :

            Payment();

            ~Payment();

            void show();

};

(i)   Name the type of Inheritance depicted in the above example.

(ii)  Name the member functions accessible through the object of class Payment.

(iii) From the following, Identify the member function(s) that can be called directly from the object of class Daily_wager class

show()

getd()

get()

(iv)  Name the base & derived class of Daily_wager class.

 



3. (a) Write a function in C++ which accepts a integer  array and its size as an arguments and prints the output (using nested loops) in following format :

Example : if the array is having

1 2 4 5 9

Then the output should be  

1

2 2

4 4 4 4

5 5 5 5 5

9 9 9 9 9 9                                             (4)

 

 

(b)  An array A[10][20] is stored in the memory with each element occupying 2 bytes of storage. If the Base address of array in the memory is 800 , determine the location of A[9][10] when the array is stored as (i) Row Major (ii) column major.

 

(c) Write a function in C++ to delete a node containing names of student , from a dynamically allocated Queue of names implemented with the help of following structure :          (3)

struct student

{

            char name[20];

            student *next;

 

}*front , *rear;

 

 

(d)   Consider the following portion of a program , which implements a linked stack for Library . Write the definition of function PUSH(),to insert a new node in the stack with required information      (3)

struct Library

{

            int id;

            char names[20];

};

class stack

{

            Library *top;

            public :

stack()

            {

            top=NULL;     

}

            void PUSH();

            void POP();

};

 

 

(e)    Convert the following infix expression into postfix. show the stack status after execution of each operation:   (2)

TRUE  OR   FALSE   AND    NOT    FALSE   OR    FALSE