Tuesday, April 8, 2008

Tips to get good marks for computer science

The students who have taken computer science as a subject need to take the subject seriously at first. They should concentrate most of their attention on the programming part. As it is the most vital part of the subject. They should try to use flow charts and algorithm for their help. As this tools help you to learn programming.

Monday, February 11, 2008

New sample paper


 

Time Duration: 3 Hrs                                    M. M. 70


 

1.


 

  1. Name the header file, to which the following build in functions belong:

    i) strcmp()    ii) isalpha()    iii) isalnum()    iv) strcat()

  1. Will the following program execute successfully? If not, state the reason(s)

    #include<stdio.h>

    void main()

    {

        int s1, s2, num;

        s1=s2=0;

        for(x=0;x<11;x++)

        {

            cin<<num;

            if(num>0(s1+=num; else s2=/num;

        }

        cout<<s1<<s2;

    }

  1. Write definition for a function SumSequence() in C++ with arguments/parameters-double x and int n. the function should return a value of type double and it should perform sum of the following series:

        1/x-3!/x2+5!/x3+7!/x4+9!/x5…….upto n terms

    (Note: the Symbol ! represents factorial of a number i. e., 4!=5x4x3x2x1)

  1. Write an interactive program in C++ to read a string and make a table displaying different types of character in the following format:

For Example:

Input String: The QUICK BROWN fox jumps over the LAZY LITTLE dog.

Uppercase Vowels        6

Uppercase consonants     15

Lowercase Vowels        7

    Uppercase consonants        13

  1. What is this pointer? Explain with example.

2


 

1


 


 


 


 


 


 


 


 


 


 


 


 

4


 


 


 


 

2


 


 


 


 


 


 


 

1

2. 

  1. Rewrite the given program after correcting all errors.

    Class student

    {

        int age;

        char name[25];

        student(char *sname, int a)

        {

            strcpy(name, sname);

            age=a;

        }

        public:

        void display()

        {

            cout<<"age="<<age;

            cout<<"Name="<<name;

        }

    };

    student stud;

    student stud1("Rohit", 17);

    main()

    {

    -------

    ------

    }

  2. Why should I use inline functions in spite of using plain old #define macros?
  3. Write significance of constructor and destructor? What is copy constructor?
  4. Why do we need constructor in class? What do you mean by constructor overloading?
  5. What will be the output of the following code:

    #include<iostream.h>

    clasws dube

    {

        int heingt, width, depth;

        public:

        cube()

        {

            cube(int ht, int wd, int dp)

            {

                height=ht; width=wd; depth=dp;

            }

            int volume()

        {

        return height * width * depth;

    }

2


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 

2

2

2


 

3. 

  1. Differentiate between single inheritance and multiple inheritance? How is containership differ from inheritance?
  2. Define a class Travel in C++ with the description given below

    Private Members :

    T_Code of type string

    No_of_Adults of type integer

    No_of_Children of type integer

    Distance of type integer

    TotalFare of type float

    Public Members :

    • A constructor to assign initial values as follows :

    T_Code with the word "NULL"

    No_of_Adults as 0

    No_of_Children as 0

    Distance as 0

    TotalFare as 0

    • A function AssignFare( ) which calculates and assigns the value of the data     member TotalFare as follows :

    For each Adult

    Fare (Rs) For Distance (Km)

    500 >=1000

    300 <1000 & >=500

    200 <500

    For each Child the above Fare will be 50% of the Fare mentioned in the above     table.

    For example :

    If Distance is 750, No_of_Adults = 3 and No_of_Children = 2

    Then TotalFare should be calculated as

    No_of_Adults * 300 + No_of_Children * 150

    i.e. 3 * 300 + 2 * 150 = 1200

    • A function EnterTraveK ) to input the values of the data members T_Code,     No_of_Adults, No_of_Children and Distance; and invoke the AssignFare( )     function.

    • A function ShowTraveK) which displays the content of all the

    data members for a Travel.

  1. Assuming the class ZOO given below, write functions in C++ to perform following:
    1. Write the objects of ZOO to a binary file.
    2. Read the objects of ZOO from binary file and display them on screen.

    Class ZOO

    {

        char location[20];

        int no_of_animals[10];

        public:

            void readdata()

            {

                cin>>location;

                gets(no_of_animals);

            }

            void writedata()

            {

                cout<<location<<" "<<no_of_animals<<endl;

            }

    };

  1. What is pointer? What is the difference between un-initialized pointer and NULL pointer?

2


 

4


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 

2


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 

  1. Binary search is more efficient than linear search. Why?
  2. Given an array x[6][16] whose base address is 100. calculate the location x[2][5] if each element occupies 4 bytes and array is stored row wise.
  3. Write a menu driven program in C++ to sort the array using selection sort and the bubble sort.
  4. Write a program in C++ to interchange the values of the row and column.
  5. Following is the number of students in different classes, boys and girls separately:

    Class    V    VI    VII    VIII    IX

    Boys    23    18    35    28    31

    Girls    15    18    03    12    07

    Create two linked list called BOYS and GIRLS so that they are stored in the increasing order of the number of students. Merge two lists BOYS and GIRLS so as to make a single list called STUDENTS. Draw the structure of BOYS, GIRLS and STUDENTS.

  6. Define linear and linked list.. Explain with example.    

1

2


 

4


 

2

2


 


 


 


 


 


 


 

3

  1. Write down any two disadvantages of using a database system.
  2. What is a primary key in a table? Define first normal form.
  3. Given the following relation. Answer the questions.

Roll 

Name 

Course 

Class 

Section

1

Punnet

Computer

12

A

2 

Rohit 

Electronics 

12 

B 

3 

Rahul 

Commerce 

12 

C 

4 

Rakesh 

Computer 

12 

A 

5 

Yatin 

Computer 

12 

A 

6 

Jish 

Civil 

12 

D 

7 

Vidhi 

Electronics 

12 

B 

  1. p Roll, Name(Student)
  2. p class, Section(student)
  1. Write the SQL commands for (i) to (vi) and output for (vii) on the basis of the table HSOPITAL:

HOSPITAL

No 

Name 

Age 

Department 

Dateofadm 

Charges 

Sex

1

Sandeep

65

Surgery

23/02/07

300

M

2 

Ravina

24

Orthopaedic

20/01/07

200

F

3 

Karan

45

Orthopaedic

19/02/07

200

M

4 

Tarun

12

Surgery

01/01/07

300

M

5 

Zubin

36

ENT

12/01/07

250

M

6 

Ketaki

16

ENT

24/02/07

300

F

7 

Ankita

29

Cardiology

20/02/07

800

F

8 

Zareen

45

Gynaecology

22/02/07

300

F

9 

Kush

19

Cardiology

13/01/07

800

M

10 

Shailya

31

Nuclear Medicine

19/02/07

400

M

  1. To show all information about the patients of cardiology department.
  2. To list the name of female patients who are in orthopaedic department.
  3. To list names of all patients with their date of admission in ascending order.
  4. Display the patient's name, charges, age for male patients only.
  5. To count the number of patients with age>20.
  6. to insert a new row in the HOSPITAL table with the following data:

        11, 'Ghulam Mustafa', 37, 'ENT',{25/02/07},250,'M'

  1. Give the output of following SQL statements:
    1. Select COUNT(DISTINCT Charges) from HOSPITAL;
    2. Select MIN(Age) from HOSPITAL where Sex='M';
    3. Select SUM(Charges) from HOSPITAL where sex='F';
    4. Select AVG(Charges) from HOSPITAL where Dateofadm<{12/02/07};

2

2

2


 


 


 


 


 


 


 


 


 


 

  1. Give Boolean expression for the logic diagram shown below. Also find out its outputs when a=1, b=1 and c=1.


 


 


 


 


 


 


 


 


 


 

  1. Represent NOT using only NOR gate(s).
  2. Minimise F(w,x,y,z) using Karnaugh map.
  3. Prove (A+B).(A'+C)=(A+B+C).(A'+B+C').(A'+B+C).(A'+B'+C) Algebrically.
  4. Given the following truth table, write the product of sums form of the function F(x,y,z)

x 

y 

z 

F

0

0

0

0

0 

0 

1 

1 

0 

1 

0 

1 

0 

1 

1 

0 

1 

0 

0 

1 

1 

0 

1 

0 

1 

1 

0 

0 

1 

1 

1 

1 

2


 


 


 


 


 


 


 


 


 


 


 

1

2

2

1

  1. Mention one difference between circular and star topologies in networking.
  2. Write the following abbreviations in their full form:

    i.) OSI        ii) GSM    iii) WLL    iv) FTP

  3. What is the function of telnet?
  4. "Bhartiya Connectivity Association" is planning to spread their offices in four major cities in India to provide regional IT infrastructure support in the field of Education & Culture. The company has planned to setup their head office in New Delhi in three locations and have named their New Delhi offices as "Front Office", "Back Office" and "Work Office". The company has three more regional offices as "South Office", "East Office" and "West Office" located in other three major cities of India. 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

BackOffice Front Office 10KM

Back Office Work Office 70 Meter

Back Office East Office 1291 KM

BackOffice West Office 790 KM

Back Office South Office 1952 KM

In continuation of the above, the company experts have planned to install the

following number of computers in each of their offices :

Back Office 100

Front Office 20

Work Office 50

East Office 50

West Office 50

South Office 50

(i)    Suggest network type (out of LAN, MAN, WAN) for connecting each of the     following set of their offices :

    • Back Office and Work Office

    • Back Office and South Office

(ii)    Which device you will suggest to be procured by the company for connecting all     the computers with in each of their offices out of the following devices?

    • Switch/Hub

    • Modem

    • Telephone

(iii)    Which of the following communication medium, you will suggest to be     procured by the company for connecting their local offices in New Delhi for     very effective and fast communication?

    • Telephone Cable

    • Optical Fiber

    • Ethernet Cable

(iv)    Suggest a cable/wiring layout for connecting the company's local offices     located in New Delhi. Also, suggest an effective method/technology for     connecting the company's regional offices-"East Office", "West Office" and     "South Office" with offices located in New Delhi.

1

2


 

1


 

**********

*****

**********

Saturday, February 9, 2008

Sample papers

Class – XII

Subject – Computer Science (c++)


 

Set- 1

MM : 70                                                    TIME : 3 HRS


 

General Instructions :

  1. This paper is not based on CBSE marking scheme ,and contains only important questions .
  2. In this question paper the number of questions are more than the question in actual board paper.


 


 

Q. 1.     a) Define the following :                                

    a.    Data abstraction. b.    Data Encapsulation    c.    Data Hiding    

b)    What is copy constructor? What do you understand by constructor overloading?    

c)    Name the header file to which following belog:            

    (i) atoi()    (ii) isalnum()    (iii) setw()    (iv) puts()

d) What will be the output of the following program:                [3]

        #include<iostream.h>

        #include<ctype.h>

        #include<conio.h>

        #include<string.h>

        void PointersFun(char Text[], int &count)

        {

            char *ptr=Text;

            int length=strlen(Text);

            for(; count<length-2; count+=2, ptr++)

            {

                *(ptr + count) = toupper( * (ptr + count) );

            }

        }

        void main()

        {

            clrscr();

            int position=0;

            char Data[]= "ChangeString";

            PointersFun(Data, position);

            cout<<Data<< "@"<< position;

            cout.write(Data + 3, 4);

        }

e) Find the output of the following program:                        [2]

        #include<iostream.h>

        #include<conio.h>

        #include<string.h>

        struct KEY

                {

                    char word[10];

                    int count;

                };

        void changekeyword(KEY somekey);

         void main()

        {

            KEY aKEY;

            strcpy(aKEY.word, "#define");

            aKEY.count=0;

            changekeyword(aKEY);

            cout<<aKEY.word<< "\t"<<aKEY.count<< "\n";

            getch();

        }

        void changekeyword(KEY somekey)

        {

            strcpy(somekey.word, "const");

            somekey.count=1;

            cout<<somekey.word<< "\t" <<somekey.count<< "\n";        }

Q 2. a)    Define a class ELECTION with the following specifications . Write a suitable main ( ) function also to declare 3 objects of ELECTION type and find the winner and display the details .    ( 3 )


 

    Private members :

    Data    :     candidate_name , party , vote_received

    Public members :

    Functions     :    enterdetails ( ) – to input data

                Display ( ) – to display the details of the winner

                Winner ( ) – To return the details of the winner trough the object after comparing the votes received by three candidates .


 

b.    class data                                    ( 2 )

    {

        int num ;

    public :

    data ( int n )

    {    num = n ;     }

    

    void show ( )

    {

        cout << n <<endl;

    }

};


 

class database : public data

{

char name[12];

data d ;

public :

__________________________


 

};


 

Fill in the blanks to define a constructor for the derived class assigning values of the data passed from main ( ) and to assign a data 15 o base class constructor data n .


 

c) Assume that you are writing a text based medieval video game. Your video game will have two types of

characters, the player and the monsesters. A player has to know the values of certain attributes of characters.

            Health             integer

            Strength            integer

            Agility            integer

            Type of weapon        String

            Type of armor        String

    A player must be able to perform the following actions:

        Move()    /*Initialize Health by 16, Strength by 12, Agility by 14, Type of weapon by

                    Mace and Type of armor by leather */

        Attackmonsester()    // Display the following message 'Attack monsester with' Type of weapon             Gettreasure()    // Increments the value of the players health by 1

Define player class with the above specifications.                                

d) Consider the following C++ declarations and answer the questions given below:            

        class Aaryuved

            {

            void anyval();

            protected:

                int x,y;

                void procval();

            public:

                void getvalA();

                void putvalA() const;

            };

        class yoga : protected Aaryuved

                {

                int a, b;

                protected:

                    int c, d;

                    void getvalB();

                public:

                    void putvalB()

const ;

                };


 

        class Wisdom: private yoga

                {

                int p;

                protected:

                    int q;

                    void getval();

                public:

                    void showval();

                };

  1. Name all the member functions, which are accessible by the objects of class wisdom.
  2. Name all the protected members of class yoga.
  3. Name the base class and derived class of yoga
  4. Name the data members, which are accessible from member functions of class wisdom
  5. Give the size of object of wisdom.
  6. Name the OOPS concept implemented above and its type
  7. Name the members accessible by function get putvalB().


 


 

e)    


 

Array

Q.1 write a user define function xyz() which takes a two dimensional array with size N rows and N columnsas argument and store all 1)even in one dimensional array2) All odd in one dimensional array 3) display product of all the number except those which are not divisible by either 5 or 3.

Q. 2 write a user define function unitdigit() which takes a two dimensional array with size N rows and M columns as argument and store all i) unit digit ii) except unit digit

In two dimensional array. i.e

    A[2][3] = 200        213

56        657

Resultant array should be

i)     A[2][3] =     0        3

  1. 7

ii)     A[2][3] =     20        21

5        65

Q. 3 write a user define function repeat() which takes a two dimensional array with size N rows and M columns as argument and convert all repeated element into zero.

Q. 4 write a user define function convert() which takes a one dimensional array with size N as argument and convert it into two dimensional array.

Suppose arr[6]= { 1,2,3,4,5,6}

Resultant array should be

    Arr[6][6] = 2     1 4 3 6 5

  1. 1 4 3 6 0
  2. 1 4 3 0 0
  3. 1 4 0 0 0
  4. 1 0 0 0 0
  • 0 0 0 0 0


 

  • Write a function in C++ to replace the repeating elements in an array by 0 . The zeros should be shifted to the end. Do not use parallel array . The order of the array should not change.     ( 2 )                         

Eg : Array     : 10 , 20 , 30 , 10 , 40 , 20 , 30


 

Result : 10 , 20 , 30 , 40 , 0 , 0 , 0


 

f) Write a function in C++ called shift( ) to rearrange the matrix as shown . Do not use parallel matrix .                                ( 2 )


 

Original Matrix                Rearranged Matrix


 

1    2    -3    -2        -3    -2    1    2

0    -1    2    1        -1    0    2    1

-3    9    -4    4        -3    -4    9    4


 

g) Convert to postfix form :                            ( 2 )


 

A + ( B * C ) ^ D / ( E * ( F – G ) – B ) * C ^ D

f) Evaluate the following postfix expression using a stack and show the contents of the

        stack after the execution of each operation.                        

TRUE, FALSE, TRUE, FALSE, NOT, OR, TRUE, OR, OR, AND


 

3 , 5, + , 6 , 4 , - , * , 4 , 1 , - , 2 , ^ , +


 

3.     a) . Write C++ function insert and delete in double link list.            ( 2 )

b)    Write a function in C++ to find the sum of alternate diagonal elements from a two dimensional array of type float. Use the array and its size as parameters with float as its return type.             

    c) An array A[25][10] is stored in memory in column wise with each of its element occupying 4 bytes . Find out the base address and the address of the element A[12][7] , if the location of A[15][9] is stored at address 7500 .                        ( 2 )    


 


 

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

#include<fstream.h>

class employee

{

int Eno; char Ename[20];

public:

    //Function to count the total number of record

    int countrec();

};


 

int employee :: countrec()

{

    employee item;

fstream file;

    file.open("EMP.DAT",ios::binary|ios::in);

    ------------------------//statement 1

    int Bytes = -------------------- //statement 2

    int count = Bytes / sizeof(item);

    file.close();

    return count;

}             

(b)    Assuming that a text file UN.TXT contains some text written into it, write a function named countalpha() , countdigit() .                        

"between 1980 and 1995 a joint UNICEF-WHO effort raised global immunization coverage against 6 killer diseases- polio , tetanus, measles,whooping cough,diphtheriaand tuberculosis- from 5 to 80 percent.


 


 

Q.5

a. What do you understand by Foreign key and cardinality in a data base    ( 2 )

b. Consider the following tables SCHOOL and ADMIN. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii).

SCHOOL

CODE 

TEACHERNAME 

SUBJECT 

DOJ 

PERIODS 

EXPERIENCE 

1001 

RAVI SHANKAR 

ENGLISH 

12/03/2000 

24 

10 

1009 

PRIYA RAI 

PHYSICS 

03/09/1998 

26 

12 

1203 

LISA ANAND 

ENGLISH 

09/04/2000 

27 

5 

1045 

YASHRAJ 

MATHS 

24/08/2000 

24 

15 

1123 

GANAN 

PHYSICS

16/07/1999 

28 

3 

1167 

HARISH B 

CHEMISTRY 

19/10/1999 

27 

5 

1215 

UMESH 

PHYSICS 

11/05/1998 

22 

16 

ADMIN

CODE 

GENDER 

DESIGNATION 

1001 

MALE 

VICE PRINCIPAL 

1009 

FEMALE 

COORDINATOR 

1203 

FEMALE 

COORDINATOR 

1045 

MALE 

HOD 

1123 

MALE 

SENIOR TEACHER 

1167 

MALE 

SENIOR TEACHER 

1215 

MALE 

HOD 


 

  1. To display TEACHERNAME, PERIODS of all teachers whose periods less than 25 and name start with either R or U..
  2. Display the contents of school table in descending order of teacher name.
  3. Display all from table school from where period is between 10 and 20.
  4. To display TEACHERNAME, CODE and DESIGNATION from tables SCHOOL and ADMIN for female teacher..
  5. To display the TEACHERNAME who have minimum PERIODS.
  6. Increase 2 years experience in all the female records.
  7. Delete all the records of subject physics.
  8. Insert a row in ADMIN TABLE.
  9. CREATE a view of table school. .
  10. Display the highest experience among all male teachers.
  11. Display code ,teachername, salary to be paid for the teacher using the table school ,where the salary to be paid = period * 507.50.
  12. To display CODE, TEACHERNAME and SUBJECT of all teachers who have joined the school after 01/01/1999.
  13. SELECT MAX(EXPERIENCE), SUBJECT FROM SCHOOL GROUP BY SUBJECT;
  14. SELECT TEACHERNAME, GENDER

    FROM SCHOOL, ADMIN

    WHERE DESIGNATION = 'COORDINATOR' AND

    SCHOOL.CODE=ADMIN.CODE ;

vii) SELECT DESIGNATION, COUNT(*) FROM ADMIN

GROUP BY DESIGNATION HAVING COUNT(*) <3;

viii) SELECT COUNT(DISTINCT SUBJECT) FROM SCHOOL;


 


 

    6. (a)     State and verify De-Morgan's, absorption Law in Boolean Algebra.     

(b)     Draw the circuit diagram for F = AB'C + C'B using NAND to NAND logic only.

(c)     Write the Products of summand SOP form of the function G(U,V,W). Truth table representation of G is as follows:                     

U

V

W

G

0

0

0

0

0

0

1

0

0

1

0

1

0

1

1

1

1

0

0

1

1

0

1

0

1

1

0

0

1

1

1

1


 

(d)     Reduce the following Boolean expression using K - Map :         3

        F (A, B, C, D) =  ∑ (0, 1, 2, 3, 4, 5, 10, 11, 15) and

        F (A, B, C, D) =  ∏ (0, 6, 8, 9, 10, 11, 13, 15)

e) Write short note on principles of Duality.                                    

f) Prove algebraically (X + YZ) =(X+Y) (X+Z)                                

g) A Boolean function F defined on three input variables A, B, C and is 1(one) if and if only if number of 0(zero) inputs is odd (e.g. F is 1(one) if A=0, B=1, C=1). Draw the truth table for the above function and express it in canonical sum of product form.                

h) Simplify the following Boolean expression using K-map :                        

        F(A, B, C, D)=m0 + m1 + m4 + m5 + m7 + m8

  1. Draw the diagram of digital circuit for the function

    F(X,Y,Z)=(X+Y) . (X+Y) .(Y+Z)


 


 

7     (a)     Write the difference between coaxial and optical fiber cable.         

(b)     Explain the following terms in short :                     

(i) GSM        ii) CDMA

©    What us the difference between Message switching technique and Packet switching technique ?                                        

(d)    Expand the following :                                

  1. TCP/IP,XML,CDMA,WLL

(e)    Write two applications of Cyber Law.                        

    

(f)     East and West Public Ltd. has decided to network all its offices spread

    in five buildings of C.P. (Shown below).                    


 


 


 


 


 


 


 


 


 


 


 

                        

            

    The distance between buildings are given below:    

Between 1 & 2 

20 Mts 

 

Between 3 & 5 

70 Mts 

Between 2 & 3 

50 Mts

 

Between 1 & 5 

65 Mts 

Between 3 & 4 

120 Mts 

 

Between 2 & 5 

50 Mts 

Between 4 & 5 

30 Mts 

   


 

(i)     Suggest cable layout(s) for connecting the buildings.                1

(ii)     Suggest the most suitable building to install the server of this organization with a suitable reason, with justification.                                        1

(iii)     Building3 is used for many critical operations. It is tried that PC gets maximum possible bandwidth. Which network device is/should be used for this?                    1

(iv)     The company also has another office in the same city but at a distant location about 25-30 kms away. How can link be established with this building.                    1

        (i.e. suggest the transmission medium).