#include <iostream> using namespace std; struct rectangle { int length; int breadth; }; void initialize(struct rectangle *r, int l, int b) { r->length = l; r->breadth = b; } int area(rectangle r) { return r.length*r.breadth; } int perimeter(rectangle r) { int p = 2*(r.length*r.breadth); return p; } int main() { rectangle r={0,0}; int l,b; cout << "Enter length and breadth : "; cin >> l >> b; initialize(&r,l,b); int a = area(r); cout <<"Area is : "<<a << endl; int peri = perimeter(r); cout <<"perimeter is :"<<peri; return 0; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter