fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. class rectangle{
  5. public:
  6. float length, width ;
  7. void input(){
  8. cout<<"enter length and width "<<endl;
  9. cin>>length>>width;
  10.  
  11. }
  12. void area(){
  13. cout<<"area of rectangle="<<length*width<<endl; }
  14. void perimeter(){
  15. cout<<"perimeter="<<2*(length+width)<<endl;
  16. }
  17.  
  18. };
  19. int main(){
  20. rectangle r;
  21. r.input();
  22. r.area();
  23. r.perimeter();
  24.  
  25. }
  26.  
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
enter length and width 
area of rectangle=0
perimeter=3.30988e-31