Topic Wise Solved Problems Question – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
CPP All :Topicwise Exam Questions: creating-and-using-class-objects siteicon
01E-2016 3

Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.

class Stock
{
  long int ID;
  float Rate; int Date;
  public:
  Stock(){ID=1001;Rate=200;Date=1;}
  void RegCode(long int I,float R)
  {
    ID=I; Rate=R;
  }
  void Change(int New,int DT)
  {
    Rate+=New; Date=DT;
  }
  void Show()
  {
    cout<<”Date :”<<Date<<endl;
    cout<<ID<<”#”<<Rate<<endl;
  }
};
void main()
{
  Stock A,B,C;
  A.RegCode(1024,150);
  B.RegCode(2015,300);
  B.Change(100,29);
  C.Change(20,20);
  A.Show();
  B.Show();
  C.Show();
}
CBSE12D-2016

01E 3

Write the output of the following C++ program code:
Note: Assume all the required header files are already being included in the program.

class Calc
{
  char Grade;
  int Bonus;
public:
  Calc(){Grade='E' ; Bonus=0;}
  void Down(int G)
  {
  Grade-=G;
  }
  Void Up(int G)
  {
    Grade+=G;
    Bonus++;
  }
  void Show()
  {
    cout<<Grade<<"#"<<Bonus<<end1;
  }
};
void main()
{
  Calc c;
  C.Down(2);
  C.Show();
  C.Up(7);
  C.Show();
  C.Down(2)
  C.Show();
}
CBSE12D-2015

02B 2

Observe the following C++ code and answer the questions (i) and (ii) :

class Traveller
{
  long PNR;
  char TName[20];
public :
  Traveller()                  //Function 1
  {cout<<"Ready"<<endl;}
  void Book(long P,char N[])   //Function 2
  {PNR = P; strcpy(TName, N);}
  void Print()                 //Function 3
  {cout<<PNR << TName <<endl;}
  ~Traveller()                 //Function 4
  {cout<<"Booking cancelled!"<<endl;}
};

(i) Fill in the blank statements in Line 1 and Line 2 to execute Function 2 and Function 3 respectively in the following code:

v oid main{)
{
  Traveller T;
  _____________ //Line 1
  _____________ //Line 2
}//Stops here

(ii) Which function will be executed at }//Stops here? What is this
function referred as ?

CBSE12D-2015

Output writing parameterized class methods 3

Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.

class Share
 {
 long int Code;
 float Rate;
 int DD;
 public:
 Share(){Code=1000;Rate=100;DD=1;}
 void GetCode(long int C,float R)
 {
  Code=C;
  Rate=R;
 }
 void Update(int Change,int D)
 {
  Rate+=Change;
  DD=D;
 }
 void Status()
 {
  cout<<"Date:"<<DD<<endl;
  cout<<Code<<"#"<<Rate<<endl;
 }
};
void main()
{
 Share S,T,U;
 S.GetCode(1324,350);
 T.GetCode(1435,250);
 S.Update(50,28);
 U.Update(25,26);
 S.Status();
 T.Status();
 U.Status();
}
CBSE12A-2016

01E-2015 3

Write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.

class Eval
{
  char Level;
  int Point;
public:
  Eval() {Level='E';Point=0;}
  void Sink(int L)
{
  Level=L;
}
void Float(int L)
{
  Level += L;
  Point++;
}
void Show()
{
  cout<<Level<<"#"<<Point<<endl;
}
};
void main()
{
  Eval E;
  E.Sink(3);
  E.Show();
  E.Float(7);
  E.Show();
  E.Sink(2);
  E.Show();
}
CBSE12A-2015