C++ Program To Find Area And Perimeter Of Rectangle Last Updated : 23 Feb, 2023 Suggest changes Share 5 Likes Like Report A rectangle is a flat figure in a plane. It has four sides and four equal angles of 90 degrees each. In a rectangle all four sides are not of equal length like squares, sides opposite to each other have equal length. Both diagonals of the rectangle have equal lengths. Examples: Input: 4 5 Output: Area = 20 Perimeter = 18 Input: 2 3 Output: Area = 6 Perimeter = 10 Formulae : Area of rectangle: a*b Perimeter of rectangle: 2*(a + b) Below is the implementation of the above topic: C++ // C++ program to find area // and perimeter of rectangle #include<iostream> using namespace std; // Utility function int areaRectangle(int a, int b) { int area = a * b; return area; } int perimeterRectangle(int a, int b) { int perimeter = 2*(a + b); return perimeter; } // Driver code int main() { int a = 5; int b = 6; cout << "Area = " << areaRectangle(a, b) << endl; cout << "Perimeter = " << perimeterRectangle(a, b); return 0; } Output: Area = 30 Perimeter = 22 Time Complexity: O(1) Space Complexity: O(1) as no extra space has been used. Create Quiz K kartik Follow 5 Article Tags : C++ Programs C++ C Basic Programs Explore C++ BasicsIntroduction to C++3 min readData Types in C++6 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++3 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++12 min readFile Handling in C++8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++6 min readPolymorphism in C++5 min readEncapsulation in C++3 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL2 min readIterators in C++ STL10 min readC++ STL Algorithm Library3 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like