object oriented programming c++-2008

Upload: duval-pearson

Post on 04-Apr-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 Object Oriented Programming C++-2008

    1/6

    Page 1 of 6

    UIVERSITY COLLEGE OF THE CARIBBEAMember of the OAS & Commonwealth Consortia of Universities

    ASSOCIATE OF SCIECE DEGREE

    I

    MAAGEMET IFORMATIO SYSTEMS

    GROUPS: K12 [eve]

    ED OF MODULE EXAMIATIO

    CETRE : OXFORD TERRACE CAMPUS

    MODULE : OBJECT ORIETED PROGRAMMIG C++ [ITT 200]

    DATE : DECEMBER 18, 2008

    TIME : 10:00 AM

    DURATIO : 3 HOURS

    ISTRUCTIOS:

    1. Please read all instructions carefully before attempting any question.

    2. This paper consists of seven (7) printed pages and four (4) sections [A, B, C & D].

    3. Sections [A, B C & D] are compulsory.

    4. No electronic devices capable of storing and retrieving text,

    including electronic dictionaries, calculators may be used

    ALL QUESTIONS MUST BE ANSWERED IN THE ANSWER BOOKLET

    PLEASE ENSURE THAT YOU NUMBER YOUR QUESTIONS CORRECTLY.

    CLEARLY WRITE THE NUMBER OF THE QUESTION ON EACH OF THE RELEVANT PAGES.

    WHERE QUESTIOS HAVE MULTIPLE PARTS, ALL PARTS MUST BE ASWERED.

    START THE RESPOSE TO EACH QUESTIO O A EW PAGE.

    Write yourREGISTRATIO UMBERclearly on each page ofyouranswer booklet.

    DO OT WRITE YOUR AME.

    B. Your script will not be marked if it has your name.

    DO NOT TURN OVER UNTIL YOU ARE TOLD TO DO SO

  • 7/29/2019 Object Oriented Programming C++-2008

    2/6

    Page 2 of 6

    SECTION A

    Answer ALL questions in this section. Each question worth 3 marks.

    1. What is the purpose of the line below:using namespace std;

    2. Which of the following declaration are illegal:int 44;int last?;int NextNumber;int round-up;int the_cats_paws;int main;

    3. What will be output by the following code fragment:char * s1 = pear;

    char * s2 = pear;int cmp = strcmp(s1,s2);cout

  • 7/29/2019 Object Oriented Programming C++-2008

    3/6

    Page 3 of 6

    SECTION B

    Answer ALL questions in this section. Each question worth 4 marks.

    6. Locate the error in the program and classify it as either a syntax error,

    compile error, a run-time error or a logical error.#includeusing namespace std;int main(){

    int a +=22;cout

  • 7/29/2019 Object Oriented Programming C++-2008

    4/6

    Page 4 of 6

    SECTION C

    Answer ALL questions in this section. Each question worth 5 marks.

    11. Draw picture to show the effect of the following code:

    double * p = new double;*p = 3.141592653589793;short * q = new short [5];*q = 44;*(q + 4) = 88;

    12. Consider the following code. What will be printed to the screen?class Vehicle{

    public:void display(){

    cout

  • 7/29/2019 Object Oriented Programming C++-2008

    5/6

    Page 5 of 6

    13. Consider the following code. What does the code fragment do and what isthe output?

    void print_binary(int n)

    { if (n>2)print_binary(n/2);

    cout

  • 7/29/2019 Object Oriented Programming C++-2008

    6/6

    Page 6 of 6

    SECTION D

    Answer ALL questions in this section. Each question worth 8 marks.

    16. Write a for statement that outputs the even numbers in the range 2 to 20,each on a separate line.

    17. Write a Person class interface. Each object of this class will represent ahuman being. Data members should include the persons name, year of birthand year of death. Include a default constructor, a destructor, accessorfunctions are name, born and died and print function for its data members.

    18. Write statements for each of the following:a. Initialize a pointer p to point to a Person object x.

    b. Assign the Person object y to the object to which p points.c. Initial a reference r to the Person object x.d. Declare a static array myarray of 8 string objects.e. Declare a dynamic array larray of 8 string objects.

    19. Write a function called CalAvg to calculate the average of two integer values.

    20. Write a recursive function that returns the power xn, using the following code

    algorithm below as a guide.

    float power( float x, int n){//return 1 if n is equal to 0// calculate and call the recursive function

    }

    END OF QUESTION PAPER