bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

pgrm_005.cpp (961B)


      1 /*
      2  * Author: Amit Dutta <amitdutta4255@gmail.com> | Date: 29 Jun 2026
      3  * Repo: https://github.com/notamitgamer/bsc
      4  * License: MIT
      5  */
      6 
      7 /* Write a program to calculate area and perimeter of a rectangle. */
      8 
      9 #include<iostream>
     10 using namespace std;
     11 
     12 class rectangle {
     13     private: 
     14         double len, bre;
     15     public: 
     16         rectangle() {
     17             len = 0;
     18             bre = 0;
     19         }
     20 
     21         void getData() {
     22             cout << "Enter the length: ";
     23             cin >> len;
     24             cout << "Enter the breadth: ";
     25             cin >> bre;
     26         }
     27 
     28         double getArea() {
     29             return len * bre;
     30         }
     31 
     32         double getPeri() {
     33             return 2 * (len + bre);
     34         }
     35 
     36         void display() {
     37             cout << "Area: " << getArea() << endl;
     38             cout << "Perimeter: " << getPeri();
     39         }
     40         
     41         ~rectangle() {}
     42 };
     43 
     44 int main() {
     45     rectangle rec;
     46     rec.getData();
     47     rec.display();
     48     return 0;
     49 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror