NPTEL( 14 Sep - 06 Nov ) | Week 3 Programming Qs1 and Programming Qs2 Programming in CPP 2020

  



       Programming in C++       



W3_Programming-Qs 1:


Consider the following program and fill the blanks (in LINE-1, LINE-2, and LINE-3) with
appropriate definitions for constructordestructor and area(). Please check the sample input
and output.

PROGRAM:

    triangle(int b, int h): _base(new int(b)) , _height(new int (h)){} 

    ~triangle() {
      delete(_base);
      delete(_height);
    }
    double area();
};

double triangle ::area()
{  
  
  


W3_Programming-Qs 2:


Consider the following program. Fill in the blanks at LINE-2 and LINE-3 to make the function
constant and at LINE-1 to make the variable editable from the constant function. Consider
the following test cases.

PROGRAM:

    mutable int _sem;        // LINE-1
public:
    Student(int roll, string name, int sem)
        : _roll(roll), _name(name), _sem(sem) { }

    void promote() const { // LINE-2
        _sem++;
    }

    void display() const { // LINE-3
 

FOLLOW OUR WEBSITE FROM THE BUTTON PROVIDED TO THE BOTTOM OF PAGE TO GET SOON ANSWERS OF PROGRAMS.
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100%  correct solutions.

No comments:

Post a Comment

If you have any problems related to solutions or any concept please let me know.

Copyright (c) 2020 Custom Programs All Right Reserved

Pages