Answer to Question #193795 in C++ for Rishabh SINGH

Question #193795

CODE

#include <iostream>

class Rectangle

{

public:

Rectangle() {}

explicit Rectangle(float i) : length(i), breadth(i)

{}

Rectangle(float a, float b) :length(a), breadth(b)

{}

void Calculate() { std::cout << length * breadth<<std::endl; }



private:

float length {0},

   breadth {0};

};

int main()

{

Rectangle r1;

Rectangle r2{ 10 };

Rectangle r3{ 15,45 };

r1.Calculate();

r2.Calculate();

r3.Calculate();

return 0;

}

How do I write my name in beginning of this program ?

1
Expert's answer
2021-05-15T13:47:16-0400
#include <iostream>




class Rectangle


{


public:


	Rectangle() {}


	explicit Rectangle(float i) : length(i), breadth(i)


	{}


	Rectangle(float a, float b) :length(a), breadth(b)


	{}


	void Calculate() { std::cout << length * breadth<<std::endl; }










private:


	float length {0},


		breadth {0};


};


int main(){
	std::cout <<"Your name here\n\n";
	Rectangle r1;
	Rectangle r2{ 10 };
	Rectangle r3{ 15,45 };
	r1.Calculate();
	r2.Calculate();
	r3.Calculate();


	return 0;


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog