Page 94 - C++
P. 94

(f) Go through the C++ code shown below, and find out the possible output or output from the suggested
        output options (i) to (iv). Also, write the least value and highest value, which can be assigned to the
        variable Guess.                                                                                      [2]

        # include <iostream.h>

        #include <stdlib.h>

        void main ( )

        {

        randomize ();

        int Guess, High=4 ;

        Guess=random (High) +50;

        for (int C=Guess ; C<=55 ; C++)

        cout<<C<<“#”;
        }


        (i) 50 # 51 # 52 # 53 # 54 # 55 #
        (ii) 52 # 53 # 54 # 55 #


        (iii) 53 # 54 #
        (iv) 51 # 52 # 53 # 54 # 55

        2. (a) Differentiate between members, which are present within the private visibility mode with those
        which are present within the public visibility modes.                                                [2]

        (b) Write the output of the following C++ code. Also, write the name of feature of Object Oriented
        Programming used in the following program jointly illustrated by the functions [I] to [IV].          [2]

        #include<iostream.h>

        void Print ( )               // Function [I]

        {

        for (int K=1;K<=60; K++) cout<< “-”;

        cout<<endl;

        }

        void Print (int N)           //Function[II]

        {

        for (int K=1;K<=N; L++) cout<<“*”;

        cout<<endl;

        }

        void Print(int A, int B)     //Function[III]

        {
   89   90   91   92   93   94   95   96   97   98   99