0

I need help here guy

Write a program to print the area of two rectangles having sides (4,5) and (5,8) respectively by creating a class named 'Rectangle' with a method named 'Area' which returns the area and length and breadth passed as parameters to its constructor.

25th Mar 2021, 7:08 AM
NASHON ODERO
NASHON ODERO - avatar
5 Respostas
+ 3
NASHON ODERO just put a closing curly bracket } after return 0; Your code is working fine.
25th Mar 2021, 7:40 AM
TOLUENE
TOLUENE - avatar
0
Which language are you talking about and where's your code/attempt ?
25th Mar 2021, 7:10 AM
Soumik
Soumik - avatar
0
C++
25th Mar 2021, 7:11 AM
NASHON ODERO
NASHON ODERO - avatar
0
#include<iostream> #include<cmath> using namespace std; class Rectangle { public: Rectangle(double length,double breadth) { rectangleLength=length; rectangleWidth=breadth; } double area() { return rectangleLength*rectangleWidth; } private: double rectangleLength; double rectangleWidth; }; int main() { Rectangle rectangle1(12.3,14.98); cout<<"Area = "<<rectangle1.area()<<endl; return 0;
25th Mar 2021, 7:35 AM
NASHON ODERO
NASHON ODERO - avatar
0
Write a program to print the area of two rectangles having sides (4,5) and (5,8) respectively by creating a class named 'Rectangle' with a function named 'Area' which returns the area. Length and breadth are passed as parameters to its constructor
24th May 2023, 4:27 PM
aliraza jutt
aliraza jutt - avatar