Cs Questions

Embed Size (px)

Citation preview

  • 7/29/2019 Cs Questions

    1/47

    CBSE Question Class, Constructor and Destructor Marks: 4 + [2/4]

    CBSE 2012Define a class SUPPLY in C++ with following description:

    Private Members

    Code of type int FoodName of type string Sticker of type string FoodType of type string A member function GetType() to assign the following values for FoodType as per the

    given Sticker:

    Sticker FoodType

    GREEN Vegetarian

    YELLOW Contains Egg

    RED Non-Vegetarian

    Public Members

    A function FoodIn() to allow user to enter values for Code, FoodName, Sticker andcall function GetType() to assign respective FoodType.

    A function FoodOut() to allow user to view the content of all the data members. CBSE 2011Define a class Candidate in C++ with following description:

    Private Members

    A data member RNo (Registeration Number) of type long A data member Name of type string A data member Score of type float A data member Remarks of type string

    A member function AssignRem() to assign Remarks as per the Score obtained by acandidate. Score range and the respective Remarks are shown as follows:

    Score Remarks

    >= 50 Selected

    Less than 50 Not Selected

    Public Members

    A function ENTER() to allow user to enter values for RNo, Name, Score & call functionAssignRem() to assign the remarks.

    A function DISPLAY() to allow user to view the content of all the data members. CBSE 2010

    Define a class ITEM in C++ with following description:Private Members

    Code of type integer (Item Code) Iname of type string (Item Name) Price of type float (Price of each item) Qty of type integer (Quantity of item in stock) Offer of type float (Offer percentage on the item) A member function GetOffer() to calculate Offer percentage as per the following

    rule:

    If Qty

  • 7/29/2019 Cs Questions

    2/47

    CBSE Question Class, Constructor and Destructor Marks: 4 + [2/4]

    Public Members

    A function GetStock() to allow user to enter values for Code, Iname, Price, Qtyand call function GetOffer to calculate the offer.

    A function ShowItem() to allow user to view the content of all the data members. CBSE 2009

    Define a class RESORT in C++ with the following description:

    Private Members:

    Rno // Data member to store Room No

    Name // Data member to store customer name

    Charges // Data member to store per day charges

    Days // Data member to store number of days to stay

    COMPUTE() // A function to calculate and return Amount as Days*Charges and if

    the value of Days*Charges more than 11000 then as 1.02*Days*Charges

    Public Members:

    Getinfo() // A function to enter the content Rno, Name, Charges and Days

    Dispinfo() // A function to display Rno, Name, Charges, Days and Amount(Amount to be displayed by calling function COMPUTE() )

    CBSE 2008Define a class Garments in C++ with the following description:

    Private Members:

    GCode of type string

    GType of type string

    GSize of type integer

    GFebric of type string

    GPrice of type float

    A function Assign() which calculates and assigns the value of GPrice as follows:For the value of GFabric COTTON

    GType Gprice (Rs.)

    TROUSER 1300

    SHIRT 1100

    For GFabrice other than COTTON the above mentioned

    GPrice gets reduced by 25%

    Public Members:

    A constructor to assign initial values of GCode, GType and GFebric with the wordNOT INITIALISED and GSize and Gprice with 0.

    A function Input () to input the values of the data members GCode, GType, Gsize,and GFebric and invoke the Assign() function.

    A function Display () which displays the contents of all the data members for anGarments.

    CBSE 2007Define a class Tour in C++ with the following description:

    Private Members:

    TCode of type string

    NoofAdults of type integer

    NoofKids of type integer

    Kilometers of type integerTotalFare of type float

  • 7/29/2019 Cs Questions

    3/47

    CBSE Question Class, Constructor and Destructor Marks: 4 + [2/4]

    Public Members:

    A constructor to assign initial values of follows:TCode with the word NULL , NoofAdults as 0

    NoofKids as 0 , Kilometers as 0, TotalFare as 0

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

    For each Adult

    Fare (Rs.) For Kilometers

    500 >= 1000300 = 500200 < 500

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

    For Example: If Kilometer is 850, NoofAdults = 2 and NoofKids = 3

    Then TotalFare should be calculated as

    NoofAdults*300 + NoofKids * 150

    i.e., 2*300 + 3*150 = 1050

    A function EnterTour() to input the values of the data members TCode,NoofAdults, NoofKids and Kilometers and invoke the AssignFare() function.

    A function ShowTour() which displays the contents of all the data members for aTour.

    CBSE 2006Define a class ADMISSION in C++ with the following description:

    Private Members:

    AD_NO integer (10-2000)

    NAME Array of characters (String)

    CLASS CharacterFEES Float

    Public Members:

    A function Read_Data() to read and object of ADMISSION type. Function Display() to display the details of an object. Function Draw_Nos() to choose 2 students randomly and display the details. Use

    random function to generate admission nos. to match with AD_NO.

    Constructor and Destructor

    CBSE 2012a) What is the difference between the members in private visibility mode and the

    members in public visibility mode inside a class? Also, give a suitable C++ code to

    illustrate both.

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

    { int LocationCode; char Location[20]; float Charges;

    public:

    Tour() // Function 1

    { LocationCode=1; strcpy(Location,PURI); Charges=1200;

    }

    void TourPlan(float C) // Function 2

    { cout

  • 7/29/2019 Cs Questions

    4/47

    CBSE Question Class, Constructor and Destructor Marks: 4 + [2/4]

    }

    Tour(int LC, char L[], float C) // Function 3

    { LocationCode=LC; strcpy(Location, L); Charges=C;

    }

    ~Tour() // Function 4

    { cout

  • 7/29/2019 Cs Questions

    5/47

    CBSE Question Class, Constructor and Destructor Marks: 4 + [2/4]

    { RegNo=101; Max=100; Min=40; Score=75; }

    TEST (int Pregno, int Pscore) // Function 2

    { Regno = Pregno; Max=100; Min=40; Score=Pscore; }

    ~TEST () // Function 3

    { cout

  • 7/29/2019 Cs Questions

    6/47

    CBSE Question Class, Constructor and Destructor Marks: 4 + [2/4]

    Bazar () // Function 1

    { strcpy(Type, Electronic); strcpy(Product, Calculator);

    Qty = 10; Price = 225;

    }

    public:

    void Disp () // Function 2

    { cout

  • 7/29/2019 Cs Questions

    7/47

    CBSE Question Inheritance

    CBSE 2012 Marks : 41) Answer the questions (i) to (iv) based on the following:

    class ORGANIZATION

    {

    char Address[20];

    double Budget, Income;

    protected:

    void Compute();

    public:

    ORGANIZATION();

    void Get();

    void Show();

    };

    class WORKAREA : public ORGANIZATION

    {

    char Address[20];int Staff;

    protected:

    double Pay;

    void Calculate()l

    public:

    WORKAREA();

    void Enter();

    void Display();

    };

    class SHOWROOM : private ORGANIZATION{

    char Address[20];

    float Area;

    double Sale;

    public:

    SHOWROOM();

    void Enter();

    void Show();

    };

    (i) Name the type of inheritance illustrated in the above C++ code.(ii) Write the names of data members, which are accessible from memberfunctions of class SHOWROOM.

    (iii) Write the names of all the member functions, which are accessible fromobjects belonging to class WORKAREA.

    (iv) Write the names of all the members, which are accessible from objects ofclass SHOWROOM.

    CBSE 2011 Marks : 42) Answer the questions (i) to (iv) based on the following:

    class Student{

  • 7/29/2019 Cs Questions

    8/47

    CBSE Question Inheritance

    int Rno;

    char Name[20];

    float Marks;

    protected:

    void Result();

    public:

    Student();

    void Register(); void Display();

    };

    class Faculty

    {

    long FCode;

    char FName[20];

    protected:

    float Pay;

    public:Faculty();

    void Enter();

    void Show();

    };

    class Cource : public Student, private Faculty

    {

    long CCode[10]; char CourceName[50];

    char StartDate[8], EndDate[8];

    public:

    Cource();void Commence();

    void CDetail();

    };

    (i) Which type of inheritance is illustrated in the above C++ code?(ii) Write the name of all the data members, which is/are accessible from

    member function Commence of class Course.

    (iii) Write the names of member functions, which are accessible from objects ofclass Cource.

    (iv) Write the names of all the members, which are accessible from objects ofclass Faculty.

    CBSE 2010 Marks : 43) Answer the questions (i) to (iv) based on the following:

    class Chairperson

    { long CID; // Chairperson Identification Number

    char CName[20];

    protected:

    char Description[40];

    void Allocate();

    public:

    Chairperson();void Assign();

  • 7/29/2019 Cs Questions

    9/47

    CBSE Question Inheritance

    void Show();

    };

    class Director

    { int DID; // Director ID

    char DName[20];

    protected:

    char Profile[30];

    public:

    Director();

    void Input();

    void Output();

    };

    class Company : private Chairperson, public Director

    { int COID; // Company Identification Number

    char City[20], Country[20];

    public:Company();

    void Enter();

    void Display();

    };

    (i) Which type of inheritance out of the following is specifically is illustrated in theabove C++ code?

    (a)Single Level Inheritance(b)Multi Level Inheritance(c) Multiple Inheritance

    (ii) Write the name of data members, which are accessible by objects of class typeCompany?

    (iii) Write the names of all member functions, which are accessible by objects of classtype Company.

    (iv) Write the names of all members, which are accessible from member functions ofclass Director.

  • 7/29/2019 Cs Questions

    10/47

    CBSE Question Inheritance

    CBSE 2009 Marks : 44) Answer the questions (i) and (iv) based on the following code:

    class FaceToFace

    { char CenterCode[10];

    public:void Input();

    void Output();

    };

    class Online

    { char website[50];

    public:

    void SiteIn();

    void SiteOut();

    };

    class Training : public FaceToFace, private Online

    { long Tcode;

    float charge;

    int period;

    public:

    void Register();

    void Show();

    };

    (i) Which type of inheritance is shown in the above example?(ii) Write the name of all the member functions accessible from Show() function of class

    Training.

    (iii) Write the names of all members accessible through object of class Training.(iv) Is the function Output() accessible inside the function SiteOut()? Justify your answer. CBSE 2008 Marks : 45) Answer the questions (i) and (iv) based on the following code:

    class Dolls

    { char DCode[5];

    protected:

    float Price;

    void CalcPrice(float);

    public:Dolls();

    void DInput();

    void DShow();

    };

    class SoftDolls : public Dolls

    { char SDName[20];

    float Weight;

    public:

    SoftDolls();

    void SDInput();void SDShow();

  • 7/29/2019 Cs Questions

    11/47

    CBSE Question Inheritance

    };

    class ElectronicDolls : public Dolls

    { char EDName[20];

    char BatteryType[10];

    int Batteries;

    public:

    ElectronicDolls();

    void EDInput();

    void EDShow();

    };

    (i) Which type of inheritance is shown in the above example?(ii) How many bytes will be required by an object of the class ElectronicDolls?(iii) Write the names of all data members accessible from member functions of the

    class SoftDolls.

    (iv) Write name of all the member functions accessible by an object of the classElectronicDolls.

    CBSE 2007 Marks : 46) Answer the questions (i) and (iv) based on the following code:

    class Trainer

    { char Tno[5], Tname[20],Specialisation[10];

    int Days;

    protected:

    float Remuneration;

    void AssignRem(float);

    public:Trainer();

    void TEntry();

    void TDisplay();

    };

    class Learner

    { char Regno[10], Lname[20], Program[10];

    protected:

    int Attendence,Grade;

    public:

    Learner ();void LEntry();

    void LDisplay();

    };

    class Institute : public Learner, public Trainer

    { char Icode[10], Iname[20];

    public:

    Institute();

    void IEntry();

    void IDisplay();

    };

  • 7/29/2019 Cs Questions

    12/47

    CBSE Question Inheritance

    (i) Which type of inheritance is depicted by the above example?(ii) Identity the member functions that cannot be called directly from the object of

    class Institute from the following:

    TEntry()

    LDisplay()

    IEntry()

    (iii) Write the names of all members accessible from member functions of the classInstitute.

    (iv) IF class Institute was derived privately from class Learner and privately from classTrainer then name the member functions that could be accessed through objects

    of class Institute.

    CBSE 2006 Marks : 47) Answer the questions (i) and (iv) based on the following code:

    class Stationary

    { char Type;char Manufacturer[10];

    public:

    Stationary();

    void Read_sta_details();

    void Disp_sta_details();

    };

    class Office : public Stationary

    { int no_of_types;

    float cost_of_sta;

    public:

    void Read_off_details();void Disp_off_details();

    };

    class Printer : private Office

    { int no_of_users;

    char delivery_date[10];

    public:

    void Read_pri_details();

    void Disp_pri_details();

    };

    void main()

    { Printer MyPrinter;

    }

    (i) Mention the member names which are accessible by MyPrinter declared in main() function.(ii) What is the size of MyPrinter in bytes?(iii) Mention the names of functions accessible from the member function Read_pri_details () of

    class Printer.

  • 7/29/2019 Cs Questions

    13/47

    CBSE Question Data File Handling

    CBSE 2012 Marks : 61. (a) Observe the program segment given below carefully and the questions that follow:

    class Inventory

    {

    int Ano, Qty; char Article[20];

    public:

    void Input() { cin>>Ano; gets(Article); cin>>Qty; }

    void Issue(int Q) { Qty += Q; }

    void Procure(int Q) { Qty -= Q; }

    int GetAno() { return Ano; }

    };

    void ProcureArticle ( int TAno, int TQty )

    {

    fstream File;

    File.open(STOCK.DAT, ios::binary|ios::in|ios::out);

    Inventory Iint Found=0;

    while(Found==0 && File.read((char*)&I, sizeof(I)))

    {

    if ( TAno == S.GetAno())

    {

    I.Procure(TQty);

    _______________________________ // Statement 1

    ________________________________ // Statement 2

    Found++;

    }}

    if( Found == 1 )

    cout

  • 7/29/2019 Cs Questions

    14/47

    CBSE Question Data File Handling

    void Enter() { gets(Number); cin>Calls; }

    void Billing() { cout

  • 7/29/2019 Cs Questions

    15/47

    CBSE Question Data File Handling

    class LAPTOP

    {

    long ModelNo;

    float RAM, HDD;

    char Details[120];

    public:

    void StockEnter() { cin>>ModelNo>>RAM>>HDD; gets(Details); }

    void StockDisplay() { cout

  • 7/29/2019 Cs Questions

    16/47

    CBSE Question Data File Handling

    (c) Write a function in C++ to search and display details of all flights, whose destination is

    Mumbai from a binary file FLIGHT.DAT. Assuming the binary file is containing the

    objects of the following class. [3]

    class FLIGHT

    { int Fno;

    char From[20];

    char To[20];

    public:

    char* GetFrom() { return From; }

    char* GetTo() { return To; }

    void Enter() { cin>>Fno; gets(From); gets(To); }

    void Display() { cout

  • 7/29/2019 Cs Questions

    17/47

    CBSE Question Data File Handling

    }

    (b) Write a function COUNT_DO () in C++ to count the presence of a word do in a text file

    MEMO.TXT. [2]

    Example:

    If the content of the file MEMO.TXT is as follows:

    I will do it, if you

    Request me to do it.

    It would have been done which earlier.

    The function COUNT_DO() will display the following message:

    Count of do- in file : 2

    Note: In the above example, do occurring as a part of word done is not considered.

    (c) Write a function in C++ to read and display the detail of all the users whose status is A

    (i.e., Active) from a binary file USER.DAT. Assuming the binary USER.DAT is containing

    objects of class USER, which is defined as follows: [3]class USER

    {

    int Uid; // User Id

    char Uname[20]; // User name;

    char Status; // User Type : A Active I Inactive

    public:

    void Register (); // Function to enter the content

    void Show (); // Function to display all data members

    char Getstatus () { return Status; }

    }; CBSE 2008 Marks : 65. (a) Observe the program segment given below carefully, and answer the question that

    follows:

    class Applicant

    { long AId; // Applicants ID

    char Name[20]; // Applicants Name

    float Score; // Applicants Score

    public:

    void Enroll ();

    void Disp ();

    void MarksScore(); // Function to change score

    long R_AId() { return AId; }

    };

    void Score_Update(long ID)

    { fstream File;

    File.open(APPLI.DAT, ios::binary | ios::in | ios::out);

    Applicant A;

    int Record = 0, Found = 0;

    while (!Found && File.read((char*) &A, sizeof(A)))

    {

    if( ID == A.R_AId())

  • 7/29/2019 Cs Questions

    18/47

    CBSE Question Data File Handling

    {

    cout

  • 7/29/2019 Cs Questions

    19/47

    CBSE Question Data File Handling

    // Function to assign marks

    void Assignmarks (int M)

    { Marks = M; }

    };

    void AllocateMarks ()

    {

    fstream File;

    File.open (MARKS.DAT, ios::binary | ios::in | ios::out);

    PracFile P;

    int Record = 0;

    while( File.read((char*) &P, sizeof(P)))

    {

    if(P.RTime() > 50 )

    P.Assignmarks(0);

    else

    P.Assignmarks(10);____________________ // Statement 1

    ____________________ // Statement 2

    Record++;

    }

    File.close();

    }

    If the function AllocateMarks() is supposed to Allocate Marks for the records in the file

    MARKS.DAT based on their values of the member TimeTaken. Write C++ statements for the

    statement 1 and statement 2, where statement 1 is required to position the file write

    pointer to an appropriate place in the file and statement 2 is to perform the write operationwith the modified record.

    (b) Write a function in C++ to print the count of the word is as an independent word in a

    text file DIALOGUE.TXT. [2]

    For example, if the content of the file DIALOGUE.TXT is

    This is his book. Is this book good?

    Then output of the program should be 2.

    (c) Given a binary file GAME.DAT, containing records of the following structure type:

    struct Game [3]

    {

    char GameName[20];char Participant[10][30];

    };

    Write a function in C++ that would read contents from the file GAME.DAT and creates a file

    named BASKET.DAT copying only those records from GAME.DAT where game name is

    Basket Ball.

    CBSE 2006 Marks : 57. (a) Write a function to count the number of words present in a text file named

    PARA.TXT. Assume that each word is separated by a single blank space character and no

    blank spaces in the beginning and end of the file. [2]

    (b) Following is the structure of each record in a data file named COLONY.DAT.

  • 7/29/2019 Cs Questions

    20/47

    CBSE Question Data File Handling

    struct COLONY [3]

    {

    char Colony_Code[10];

    char Colony_Name[10];

    int No_of_People;

    };

    Write functions in C++ to update the file with a new value of No_of_People are read during

    the execution of the program.

    CBSE 2005 Marks : 68. (a) Observe the program segment given below carefully, and answer the question that follows:

    class Book

    {

    int Book_no;

    char Book_name[20];

    public:

    void enterdetails(); // Function to enter Book Details

    void showdetails(); // Function to display book details

    int RBook_No() { return Book_no; } // Function to return Book_no

    };

    void Modify (Book NEW)

    { fstream File;

    File.open (Book.DAT, ios::binary | ios::in | ios::out);

    Book OB;

    int Recordsread = 0, Found = 0;

    while (! Found && File.read((char *) &OB, sizeof (OB)))

    { Recordsread++;

    If (NEW.RBook_No() == OB.RBook_No())

    { _______________________ // Missing Statement

    File.wirte ((char *)&NEW, sizeof(NEW));

    Found = 1;

    }

    else

    File.write((char *)&OB, sizeof(OB));

    }

    if(!Found)

    cout

  • 7/29/2019 Cs Questions

    21/47

    CBSE Question Data File Handling

    (c) Given a binary file STUDENT.DAT, containing records of the following class Student type [3]

    class Student

    { char S_Admno[10];

    char S_Name[30];

    int Percentage;

    public:void EnterData() { gets(S_Admno); gets(S_Name); cin>>Percentage; }

    void DisplayData()

    { cout

  • 7/29/2019 Cs Questions

    22/47

    CBSE 20121. (a) Write a function SWAP2CHANGE( int p[ ], int N ) in C++to modify the contentof the array in such a way that elements, which are multiples of 10 swap with the valuepresent in the very next position in the array.For example:

    If the content of array P is91, 50, 54, 22, 30, 54The content of array P should become

    91, 54, 50, 22, 54, 30

    (b) An array S[10][30] is stored in the memory along the column with each of theelement occupying 2 bytes. Find out the memory location of S[5][10], if the elementS[2][15] is stored at the location 8200.

    (c) Write a function in C++to perform Insert operation in Dynamic Queue containingDVDs information (represented with the help of an array of structure DVD).

    struct DVD{long No;char Title[20];DVD *Link;

    };

    (d) Write a function SKIPEACH( int H[][3], int C, int R) in C++to display all alternateelements from two-dimensional array H (starting from H[0][0] ).

    For example:If the array is containing:

    12 45 6733 90 7621 43 59

    The output will be12 67 90 21 59

    (e) Evaluate the following POSTFIX notation. Show status of Stack after every step ofevaluation (i.e. after each operator).False, NOT, True, AND, True, False, OR, AND

    CBSE 20112. (a) Write GetFrom2() function in C++to transfer the content from two arrays FIRST[ ]and SECOND[ ] to array ALL[ ]. The even places (0, 2, 4, .....) of array ALL[ ] shouldget the content from the array FIRST[ ] and odd places (1, 3, 5, ....) of the array ALL[ ]should get the content from the array SECOND[ ].Example:

    If the FIRST[ ] array contains

    22

  • 7/29/2019 Cs Questions

    23/47

    30, 60, 90

    And the SECOND[ ] array contains10, 50, 80

    The ALL[ ] array should contains30, 10, 60, 50, 90, 80

    (b) An array P[20][50] is stored in the memory along the column with each of its elementoccupying 4 bytes, find out the location of P[15][10], if P[0][0] is stored at 5200.

    (c) Write a function in C++to perform Insert operation on a dynamically allocatedQueue containing Passenger details as given in the following definition of NODE.

    struct NODE{

    long Pno; // Passenger Number

    char PName[20]; // Passenger NameNODE *Link;};

    (d) Write a COLSUM( ) function in C++to find sum of each column of NxM Matrix.

    (e) Evaluate the following postfix notation of expression :50, 60, +, 20, 10, -, *

    CBSE 20103. (a) Write a function CHANGE( ) in C++, which accepts an array of integer and its

    size as parameters and divide all those array elements by 7 which are divisible by 7 andmultiply other array elements by 3.Sample Input Data of the array

    A[0] A[1] A[2] A[3] A[4]21 12 35 42 18

    Sample Output of the arrayA[0] A[1] A[2] A[3] A[4]3 36 5 6 54

    (b) An Array P[50][60] is stored in the memory along with each of the elementoccupying 2 bytes, find out the memory location for the element P[10][20], if the BaseAddress of the array is 6800.

    (c) Write complete program in C++ to implement a dynamically allocated Stackcontaining names of Countries.

    23

  • 7/29/2019 Cs Questions

    24/47

    (d) Write a function int SKIPSUM( int A [ ] [3], int N, int M) in C++to find andreturn the sum of elements from all alternate elements of a two-dimensional array startingfrom A[0][0].

    Hint:

    If the following is the content of the arrayA[0][0] A[0][1] A[0][2]4 5 1

    A[1][0] A[1][1] A[1][2]2 8 7

    A[2][0] A[2][1] A[2][2]9 6 3

    The function SKPSUM() should add elements A[0][0], A[0][2], A[1][1], A[2][0]

    and A[2][2].

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

    CBSE 20094. (a) Write a function SORTPOINTS( ) in C++to sort an array of structure Game indescending order of Points using Bubble Sort.

    Note: Assume the following definition of structure Game

    struct Game{long Pno; // Player Numberchar PName[20];long Points;

    };Sample content of the array (before sorting)

    Pno PName Points103 Ritika Kapur 3001104 John Philip 2819101 Razia Abbas 3451105 Tarun Kumar 2971

    Sample content of the array (after sorting)

    Pno PName Points101 Razia Abbas 3451103 Ritika Kapur 3001105 Tarun Kumar 2971104 John Philip 2819

    24

  • 7/29/2019 Cs Questions

    25/47

    (b) An array S[40][30] is stored in the memory along the column with each of theelement occupying 4 bytes, find out the base address and address of element S[20][15], ifan element S[15][10] is stored at the memory location 7200.

    (c) Write a function QUEINS( ) in C++ to insert an element in a dynamicallyallocated Queue containing nodes of the following given structure:

    struct Node{

    int Pid // Product idchar Pname[20];Node *Next;

    };

    (d) Define a function SWAPCOL( ) in C++to swap (interchange) the first column

    elements with the last column elements, for a two dimensional integer array passed as theargument of the function.

    Example: If the two dimensional array contains

    2 1 4 91 3 7 75 8 6 37 2 1 2

    After swapping the content of first column and last column, it should be:

    9 1 4 27 3 7 13 8 6 52 2 1 7

    (e) Convert the following infix expression to its equivalent postfix expressionshowing stack contents for the conversion:

    X - Y / ( Z +U ) * V

    CBSE 20085. (a) Write a function in C++, which accepts an integer array and its size as parametersand rearranges the array in reverse.

    Example: If an array of nine elements initially contains the elements as

    25

  • 7/29/2019 Cs Questions

    26/47

    4, 2, 5, 1, 6, 7, 8, 12, 10

    then the function should rearrange the array as

    10, 12, 8, 7, 6, 1, 5, 2, 4

    (b) An array Arr[40][10] is stored in the memory along the column with each elementoccupying 4 bytes. Find out the address of the location Arr[3][6] if the location A[30][10]is stored at the address 9000.

    (c) Write a function in C++to insert an element into a dynamically allocated Queuewhere each node contains a name ( of type string ) as data.

    Assume the following definition of THENODE for the same.struct THENODE{

    char Name[20];THENODE *Link;};

    (d) Write a function in C++to print the product of each column of a two dimensionalinteger array passed as the argument of the function.

    Example: If the two dimensional array contains

    1 2 43 5 64 3 22 1 5

    Then the output should appear as:

    Product of Column 1 = 24Product of Column 2 = 30Product of Column 3 = 240

    (e) Evaluate the following postfix notation of expression(Show status of stack after execution of each operation)

    4, 10, 5, +, *, 15, 3, /, -

    CBSE 20076. (a) Write a function in C++which accepts an integer array and its size as argumentsand replaces elements having odd values with thrice its value and elements having evenvalues with twice its value.

    26

  • 7/29/2019 Cs Questions

    27/47

    Example: If an array of five elements initially contains the elements as

    3, 4, 5, 16, 9

    then the function should rearrange the content of the array as

    9, 8, 15, 32, 27

    (b) An array Array[20][15] is stored in the memory along the column with eachelement occupying 8 bytes. Find out the Base Address and address of the elementArray[2][3] if the element Array[4][5] is stored at address 1000.

    (c) Write a function in C++to delete a node containing Book's information, from adynamically allocated Stack of Books implemented with the help of the followingstructure.

    struct Book{ int BNo;

    char BName[20];Book *Next;};

    (d) Write a function in C++which accepts a 2D array of integers and its size asarguments and displays the elements which lie on diagonals.[ Assuming the 2D Array to be a square matrix with odd dimension i.e., 3x3, 5x5, 7x7..]

    Example, if the array content is5 4 36 7 81 2 9

    Output through the function should be:Diagonal One: 5 7 9Diagonal Two: 3 7 1

    (e) Evaluate the following postfix notation of expression:25 8 3 - / 6 * 10 +

    CBSE 20067. (a) Write a function in C++which accepts an integer array and its size as arguments/parameters and assign the elements into a two dimensional array of integers in thefollowing format :

    If the array is 1, 2, 3, 4, 5, 6 If the array is 1, 2, 3The resultant 2 D array is given below The resultant 2 D array is given below

    1 2 3 4 5 6 1 2 31 2 3 4 5 0 1 2 01 2 3 4 0 0 1 0 01 2 3 0 0 01 2 0 0 0 0

    27

  • 7/29/2019 Cs Questions

    28/47

    1 0 0 0 0 0

    (b) An array MAT[30][10] is stored in the memory column wise with each elementoccupying 8 bytes of memory. Find out the base address and the address of elementMAT[20][5], if the location of MAT[5][7] is stored at the address 1000.

    (c)class queue{ int data[10];

    int front, rear;public:

    queue() { front =-1; rear =-1; }void add(); // to add an element into the queuevoid remove(); // to remove an element from the queuevoid Delete(int ITEM); // to delete all elements which are equal to ITEM

    };

    Complete the class with all function definitions for a circular array Queue. Use anotherqueue to transfer data temporarily.

    (d) Write a function in C++to perform a PUSH operation on a dynamically allocatedstack containing real number.

    (e) Write the equivalent infix expression for : a, b, AND, a, c, AND, OR

    CBSE 20058. (a) Write a function in C++which accepts an integer array and its size as arguments/

    parameters and exchanges the value of first half side elements with the second half sideelements of the array.Example:

    If an array of eight elements has initial content2, 4, 1, 6, 7, 9, 23, 10

    The function should rearrange the array as7, 9, 23, 10, 2, 4, 1, 6

    (b) An array Arr[15][35] is stored in the memory along the column with each of itselements occupying 8 bytes. Find out the base address and the address of an elementArr[2][5], if the location Arr[5][10] is stored at the address 4000.

    (c) Write a function in C++to perform a PUSH operation in dynamically allocatedstack considering the following:

    struct Node{

    int X, Y ;Node *Link;

    };

    28

  • 7/29/2019 Cs Questions

    29/47

    class STACK{

    Node * Top;public:

    STACK() { Top =NULL; }

    void PUSH();void POP();~STACK();

    };

    (d) Write a function in C++ to print the sum of all the values which are eitherdivisible by 2 or are divisible by 3 present in a two dimensional array passed as theargument to the function.

    (e) Evaluate the following postfix notation of expression:10, 20, +, 25, 15, -, *, 30, /

    CBSE 20049. (a) Define a function Reversearray ( int [ ], int), that would accept a one dimensionalinteger array NUMBERS and its size N. The function should reverse the contents of arraywithout using any second array.Note: Use the concept of swapping elements (If the array initially contains)

    { 2, 15, 3, 14, 7, 9, 19, 6, 1, 10 } then after reversal the array should contain{ 10, 1, 6, 19, 9, 7, 14, 3, 15, 2 }

    (b) An array ARR[5][5] is stored in the memory with each element occupying 4 bytes

    of space. Assuming the base address of ARR to be 1000, compute the address ofARR[2][4], when the array is stored:(i) Row Wise (ii) Column Wise

    (c) Write a function in C++to find and display the sum of each row and each columnof a 2 dimensional array of type float.

    (d) Evaluate the following Postfix notation of expression, show status of stack foreach operation: 500, 20, 30, +, 10, *, +(e) Define functions stackpush() to insert nodes and stackpop() to delete nodes, for alinked list implemented stack having the following structure for each node:

    struct node{ char name[20]; int age;

    node *Link;};class stack{ node *top;

    public:

    29

  • 7/29/2019 Cs Questions

    30/47

    stack() { top =NULL; }void stackpush(); void stackpop();

    };

    30

  • 7/29/2019 Cs Questions

    31/47

    1. Write the output of the following program:

    a) #includeint func(int &x, int y=10){ if( x%y ==0)

    return ++x;elsereturn y--;

    }void main(){

    int P=20, Q=23;Q =func(P,Q);cout

  • 7/29/2019 Cs Questions

    32/47

    c) #includevoid main(){

    int x=5, y=5;cout

  • 7/29/2019 Cs Questions

    33/47

    f) #includeint Calc ( int U ){ if( U%2 ==0)

    return U +10;else

    return U * 2;}void Pattern( char M, int B =2 ){ for ( int CNT=0; CNT

  • 7/29/2019 Cs Questions

    34/47

    void main(){ char Text[ ] ="CBSE Exam 2012";

    int Size =strlen(Text);Convert( Text, Size );cout

  • 7/29/2019 Cs Questions

    35/47

    2. In the following program, find the correct possible output(s) from the options:#include#includevoid main(){ randomize();

    char Color[ ][10] ={ "RED", "BLUE", "PINK", "BLACK" };int Paint;for(int i=0; i

  • 7/29/2019 Cs Questions

    36/47

    5. Give the output of the following program:#includeint & max ( int & X, int &Y ){

    if (X >Y)

    return(X);elsereturn(Y);

    }void main(){

    int A =10, B =13;max( A, B ) =-1;cout

  • 7/29/2019 Cs Questions

    37/47

    void main(){ char data[100] ="bEsTOfLUck";

    cout

  • 7/29/2019 Cs Questions

    38/47

    9. In the following program, if the value of N given by the user is 15, what is themaximum and minimum values the program could possible display?#include#includevoid main()

    { int N, Guessme ;randomize();cin>>N;Guessme =random ( N ) +10;cout

  • 7/29/2019 Cs Questions

    39/47

    12. Find the output of the following program:#includevoid main(){ int X[ ] ={10, 25, 30, 55, 110 };

    int *P =X ;

    while( *P =1; i-- ){ cout

  • 7/29/2019 Cs Questions

    40/47

    14. Study the following program and select the possible output from it:#include#includeconst int LIMT =4;void main()

    { randomize();int Points;Points =100 +random ( LIMIT);for(int P =Points; P>=100; P--)

    cout

  • 7/29/2019 Cs Questions

    41/47

    void main ( ){ int A =5, B =7;

    max ( A, B ) =-1;cout

  • 7/29/2019 Cs Questions

    42/47

    18. Find the output of the following program:#include#includevoid ChangeIt( char Test[ ], char C ){

    for( int K=0; Text[K] !='\0'; K++){if( Text[K] >='F' && Text[K]

  • 7/29/2019 Cs Questions

    43/47

    20. Find the output of the following program:#includevoid ChangeArray ( int Number, int ARR[ ], int Size ){

    for ( int L=0; L

  • 7/29/2019 Cs Questions

    44/47

    22. Write the output of the following C++code.#includevoid Print(){

    for( int K=1; K

  • 7/29/2019 Cs Questions

    45/47

    Dimension(B3);B2=B3;B2.Height +=5;B3.Length--;Dimension( B2 );

    }

    24. Find the output of the following program:#includevoid main(){ long Number =7583241;

    int First=0, Second=0;do{ int R =Number%10;

    if( R%2 ==0 )First +=R;

    else Second +=R;} while( Number>0 );cout

  • 7/29/2019 Cs Questions

    46/47

    26. Find the output of the following program:#includevoid Changethecontent( int Arr[ ], int Count ){

    for( int C=1; C

  • 7/29/2019 Cs Questions

    47/47

    28. Find the output of the following program:#include#includevoid main(){

    char Text[ ] ="Mind@Work!";for( int i=0; Text[i] !='\0' ; i++){

    if( ! isalpha(Test[i]) )Text[i] ='*';

    else if( !isupper( Text[i] ) )Text[i] =Text[i] +1;

    elseText[i] =Text[i+1];

    }cout