ai2002

10
Examination Paper 1 Examination Papers, 2002 [All India] Maximum Marks : 70 Duration : 3 Hours Note. All the questions are compulsory. Programming Language : C++ 1. (a) Illustrate the concept of Inheritance with the help of an example. 2 (b) Name the header files of C++ to which the following functions belong: 2 (i ) get( ) ( ii) open( ) (iii ) abs( ) (iv) strcat( ) (c) Find the syntax error(s), if any, in the following program : 2 #include <iostream.h> void main( ) { int x; cin >> x; for(int y=0, y<10, y++); cout << x+y; } (d) Write the output of the following program : 2 void main( ); { int x = 5, y = 5; cout << x––; cout << ","; cout << ––x; cout << ","; cout << y–– << ","<< ––y; } (e) Write the output of the following program : 3 #include <iostream.h> void X(int &A, int &B) { A = A+B; B = A–B; A = A–B; } void main( ) { int a=4, b=18; X(a, b); cout << a << "," << b; } (f ) Write a function called zero_Small( ) that has two integer arguments being passed by reference and sets the smaller of the two numbers to 0. Write the main program to access this function. 4 Ans. (a) Inheritance is a capability to define custom data types using classes, enables you to reuse the code you develop. Inheritance enables you to more readily reuse an object, making slight adjustments, wherever necessary. For Example, class Student {

Upload: ajay-rana

Post on 20-Nov-2015

229 views

Category:

Documents


1 download

DESCRIPTION

comp science board paper

TRANSCRIPT

  • Examination Paper 1

    Examination Papers, 2002[All India]

    Maximum Marks : 70 Duration : 3 HoursNote. All the questions are compulsory.

    Programming Language : C++

    1. (a) Illustrate the concept of Inheritance with the help of an example. 2(b) Name the header files of C++ to which the following functions belong: 2

    (i) get( ) (ii) open( ) (iii) abs( ) (iv) strcat( )(c) Find the syntax error(s), if any, in the following program : 2

    #include void main( ){

    int x;cin >> x;for(int y=0, y

  • 2 Together with Computer Science (C++) XII

    private :char name[20];int check (int e);

    public :void getdata( );void putdata( );

    protected :int total;void calc( );

    };class School : private Student{

    protected :char class_stu[10];

    public :void getdata( );void putdata( );

    };In the above example Student is the base class and School is the derived class.

    (b) (i) iostream.h (ii) fstream.h (iii) math.h (iv) string.h(c) The errors are :

    #includevoid main( ){

    int x;cin>>x;for(int y=0, yx;for(int y=0;y

  • Examination Paper 3

    cout > x >> y;zero_small(x, y);cout

  • 4 Together with Computer Science (C++) XII

    float percentage;float calculate( );

    public :void readmarks( );void displaymarks( );

    };float student :: calculate( ){

    float total = 0;for (int I = 0; I < 5; I++)

    total += marks[I];return (total / 5);

    }void student :: readmarks( ){

    cout > marks[I];percentage = calculate( );

    }void student :: displaymarks( ){

    cout

  • Examination Paper 5

    (e) Considering the following key set : 42, 29, 74, 11, 65, 58, use insertion sort to sort the data inascending order and indicate the sequences of steps required. 3

    Ans. (a) An array is a sequence of objects all of which have the same type. The objects are called elements ofthe array and are numbered consecutively 0, 1, 2, ...... These numbers are called index values orsubscripts of the array.A pointer is a variable that contains the memory address of an item rather its value. A pointer canpoint to any type of data item or to a function.

    (b) The function is :void Stack :: pop( ){

    if (top == 0)err_rep(1);

    elsecout

  • 6 Together with Computer Science (C++) XII

    (e) Using bubble sort, the sequence of steps are :

    42 29 74 11 65 58

    29 42 74 11 65 58

    29 42 74 11 65 58

    11 29 42 74 65 58

    11 29 42 65 74 58

    11 29 42 58 65 75

    4. (a) What is the difference between put( ) and write( ) ? 1(b) Write a C++ program, which initializes a string variable to the content. Time is a great teacher but

    unfortunately it kills all its pupils. Berlioz and outputs the string one character at a time to the diskfile OUT.TXT. You have to include all the header files if required. 4

    Ans. (a) The put( ) is used in context of Text file/Binary file.The write( ) is used in context of character/multiple character.

    (b) The program is :#include void main( ){

    char line[80= {"time is a great teacher but unfortunately ........."};int C = 0;fstream fout;fout.open("out.txt", ios::out);while (line[C] != \0){

    fout

  • Examination Paper 7

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901

    fout

  • 8 Together with Computer Science (C++) XII

    (f) Given the following truth table, write the product of sums form of the function F(x, y, z) 2

    x y z F0 0 0 00 0 1 10 1 0 10 1 1 01 0 0 11 0 1 01 1 0 01 1 1 1

    Ans. (a) The distributive law statesX.(Y + Z ) = X.Y + X.Z (ii) X + Y.Z = (X + Y) . (X+Z)The truth table for X(Y+Z) = XY + XZ is given below :

    Input OutputX Y Z Y+Z XY XZ X(Y+Z) XY+XZ0 0 0 0 0 0 0 00 0 1 1 0 0 0 00 1 0 1 0 0 0 00 1 1 1 0 0 0 01 0 0 0 0 0 0 01 0 1 1 0 1 1 11 1 0 1 1 0 1 11 1 1 1 1 1 1 1

    Both the columns X(Y+Z) and XY+YZ are identical, hence proved.(b) L.H.S. = X.Y + Y.Z + Y'.Z

    = X.Y + (Y.+Y')Z= X.Y + 1.Z= X.Y + Z = R. H. S.

    (c) F = (2, 3, 6, 10, 11, 14)

    F = YZ' + X'Y

    00 0100

    WXYZ

    11 10

    01

    11

    10

    1111

    1

    1

  • Examination Paper 9

    (d) The truth table of Full Adder is :

    x y z sum carry0 0 0 0 00 0 1 1 00 1 0 1 00 1 1 0 11 0 0 1 01 0 1 0 11 1 0 0 11 1 1 1 1

    The logic circuit of Full Adder is :

    (e) (X+Y)(Y+Z)(X+Z)Take the double complement.= [(X+Y)(Y+Z)(X+Z)''= ((X+Y) + (Y+Z) + (X+Z)']'i.e.,

    (f) F (X, Y, Z) = x'y'z + x'yz' + xy'z' + xyz7. (a) What is a MODEM ? 1

    (b) Write the following abbreviations in their full form : 1FTP, WAN, WWW

    (c) Mention one difference between circuit switching and packet switching. 2

    y

    x

    carry = x . y + y . z + x . z

    sum = x + y + zz

    yx

    zy

    xz

    (x + y)'

    (y + z)'

    (z + x)'

    (x + y) + (y + z) + (z + x)

  • 10 Together with Computer Science (C++) XII

    (d) Write two advantages and disadvantages of the following topologies in network : 1(i) Bus

    (ii) RingAns. (a) A modem is a device which is used to convert data from digital bit strream into an analog signal and

    vice versa.(b) FTP. File Transfer Protocol

    WAN. Wide Area NetworkWWW. World Wide Web.

    (c) Circuit Switching. In this technique, firstly the complete physical connection between two computersis established and then data is transmitted from the source computer to the destination computer.A Packet Switching network divides the data traffic into blocks called packets that have a maximumlength. Each packet of user data travels in a data envelope, which gives the destination address ofthe packet and a variety of control information.

    (d) Advantages of BUS topology :(i) Short cable length Because there is single common data path connecting all nodes.

    (ii) Easy to extend Additional nodes can be connected to an existing bus network at any pointalong its length.

    Disadvantages of BUS topology :(i) Fault diagnosis is difficult Although the bus topology is very simple, but in this topology

    fault detection is very difficult.(ii) Nodes must be intelligent Each node on the network is directly connected to the central bus.

    This means that some way of deciding who can use the network at any given time must beperformed in each node. It tends to increase the cost of the nodes irrespective of whether thisis performed in hardware or software.

    Advantages of Ring topology :(i) Short cable length In ring topology less connections will be needed which increases network

    reliability.(ii) The amount of cable needed in this topology is comparable to bus and relatively smallto star.

    Disadvantages of Ring topology :(i) Node failure causes network failure Since each node in this network is connected to its

    neighbouring node and data travels through each node, there is one traffic flow until defectivenode is removed.

    (ii) Each node must handle the data being transferred on the ring.

    /ColorImageDict > /JPEG2000ColorACSImageDict > /JPEG2000ColorImageDict > /AntiAliasGrayImages false /DownsampleGrayImages true /GrayImageDownsampleType /Bicubic /GrayImageResolution 300 /GrayImageDepth -1 /GrayImageDownsampleThreshold 1.50000 /EncodeGrayImages true /GrayImageFilter /DCTEncode /AutoFilterGrayImages true /GrayImageAutoFilterStrategy /JPEG /GrayACSImageDict > /GrayImageDict > /JPEG2000GrayACSImageDict > /JPEG2000GrayImageDict > /AntiAliasMonoImages false /DownsampleMonoImages true /MonoImageDownsampleType /Bicubic /MonoImageResolution 1200 /MonoImageDepth -1 /MonoImageDownsampleThreshold 1.50000 /EncodeMonoImages true /MonoImageFilter /CCITTFaxEncode /MonoImageDict > /AllowPSXObjects false /PDFX1aCheck false /PDFX3Check false /PDFXCompliantPDFOnly false /PDFXNoTrimBoxError true /PDFXTrimBoxToMediaBoxOffset [ 0.00000 0.00000 0.00000 0.00000 ] /PDFXSetBleedBoxToMediaBox true /PDFXBleedBoxToTrimBoxOffset [ 0.00000 0.00000 0.00000 0.00000 ] /PDFXOutputIntentProfile (None) /PDFXOutputCondition () /PDFXRegistryName (http://www.color.org) /PDFXTrapped /False

    /Description >>> setdistillerparams> setpagedevice