DSA 1.24 : procedural or modular programming

PHOTO EMBED

Tue Mar 07 2023 15:22:03 GMT+0000 (Coordinated Universal Time)

Saved by @saakshi #c++

#include <iostream>
using namespace std;

int area(int length, int breadth)
{
    return length*breadth;
}

int perimeter(int length, int breadth)
{
    int p = 2*(length*breadth);
    return p;
}

int main() 
{
    int length = 0, breadth =0;
    cout << "Enter length and breadth : ";
    cin >> length >> breadth;
    
    int a = area(length,breadth);
    cout <<"Area is : "<<a << endl;
    
    int peri = perimeter(length,breadth);
    cout <<"perimeter is :"<<peri;

    return 0;
}
content_copyCOPY

this is a procedural or modular programming approach where the program is divided into small parts called as functions.